feat: Add Palette Editor for Enhanced Color Management

- Introduced a new PaletteEditorWidget for visual editing of dungeon palettes, allowing users to select and modify colors.
- Integrated palette editor into DungeonEditorV2, enabling real-time updates and re-rendering of rooms upon palette changes.
- Enhanced GUI layout to include a dedicated palette editor card, improving user experience and accessibility.
- Implemented callback functionality to notify when palette changes occur, ensuring seamless integration with room rendering.
This commit is contained in:
scawful
2025-10-07 03:39:49 -04:00
parent d100162f69
commit 167dc86819
6 changed files with 267 additions and 95 deletions

View File

@@ -0,0 +1,56 @@
#ifndef YAZE_APP_GUI_WIDGETS_PALETTE_EDITOR_WIDGET_H
#define YAZE_APP_GUI_WIDGETS_PALETTE_EDITOR_WIDGET_H
#include <functional>
#include <vector>
#include "app/gfx/snes_palette.h"
#include "app/rom.h"
#include "imgui/imgui.h"
namespace yaze {
namespace gui {
/**
* @brief Simple visual palette editor with color picker
*
* Displays dungeon palettes in a grid, allows editing colors,
* and notifies when palettes change so rooms can re-render.
*/
class PaletteEditorWidget {
public:
PaletteEditorWidget() = default;
void Initialize(Rom* rom);
void Draw();
// Callback when palette is modified
void SetOnPaletteChanged(std::function<void(int palette_id)> callback) {
on_palette_changed_ = callback;
}
// Get/Set current editing palette
int current_palette_id() const { return current_palette_id_; }
void set_current_palette_id(int id) { current_palette_id_ = id; }
private:
void DrawPaletteSelector();
void DrawColorGrid();
void DrawColorPicker();
Rom* rom_ = nullptr;
int current_palette_id_ = 0;
int selected_color_index_ = -1;
// Callback for palette changes
std::function<void(int palette_id)> on_palette_changed_;
// Temp color for editing (RGB 0-1 range for ImGui)
ImVec4 editing_color_{0, 0, 0, 1};
};
} // namespace gui
} // namespace yaze
#endif // YAZE_APP_GUI_WIDGETS_PALETTE_EDITOR_WIDGET_H