yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::PaletteGroupPanel Class Referenceabstract

Base class for palette group editing cards. More...

#include <palette_group_panel.h>

Inherits yaze::editor::EditorPanel.

Inherited by yaze::editor::DungeonMainPalettePanel, yaze::editor::EquipmentPalettePanel, yaze::editor::OverworldAnimatedPalettePanel, yaze::editor::OverworldMainPalettePanel, yaze::editor::SpritePalettePanel, yaze::editor::SpritesAux1PalettePanel, yaze::editor::SpritesAux2PalettePanel, and yaze::editor::SpritesAux3PalettePanel.

Collaboration diagram for yaze::editor::PaletteGroupPanel:

Public Member Functions

 PaletteGroupPanel (const std::string &group_name, const std::string &display_name, Rom *rom, zelda3::GameData *game_data=nullptr)
 Construct a new Palette Group Panel.
 
void SetGameData (zelda3::GameData *game_data)
 
virtual ~PaletteGroupPanel ()=default
 
void Draw (bool *p_open) override
 Draw the card's ImGui UI.
 
std::string GetId () const override
 Unique identifier for this panel.
 
std::string GetDisplayName () const override
 Human-readable name shown in menus and title bars.
 
std::string GetIcon () const override
 Material Design icon for this panel.
 
std::string GetEditorCategory () const override
 Editor category this panel belongs to.
 
int GetPriority () const override
 Get display priority for menu ordering.
 
void Show ()
 
void Hide ()
 
bool IsVisible () const
 
bool * visibility_flag ()
 
absl::Status SaveToRom ()
 Save all modified palettes to ROM.
 
void DiscardChanges ()
 Discard all unsaved changes.
 
void ResetPalette (int palette_index)
 Reset a specific palette to original ROM values.
 
void ResetColor (int palette_index, int color_index)
 Reset a specific color to original ROM value.
 
void SetColor (int palette_index, int color_index, const gfx::SnesColor &new_color)
 Set a color value (records change for undo)
 
void Undo ()
 
void Redo ()
 
bool CanUndo () const
 
bool CanRedo () const
 
void ClearHistory ()
 
bool HasUnsavedChanges () const
 
bool IsPaletteModified (int palette_index) const
 
bool IsColorModified (int palette_index, int color_index) const
 
int GetSelectedPaletteIndex () const
 
void SetSelectedPaletteIndex (int index)
 
int GetSelectedColorIndex () const
 
void SetSelectedColorIndex (int index)
 
std::string ExportToJson () const
 
absl::Status ImportFromJson (const std::string &json)
 
std::string ExportToClipboard () const
 
absl::Status ImportFromClipboard ()
 
- Public Member Functions inherited from yaze::editor::EditorPanel
virtual ~EditorPanel ()=default
 
virtual void OnOpen ()
 Called when panel becomes visible.
 
virtual void OnClose ()
 Called when panel is hidden.
 
virtual void OnFocus ()
 Called when panel receives focus.
 
virtual PanelCategory GetPanelCategory () const
 Get the lifecycle category for this panel.
 
virtual bool IsEnabled () const
 Check if this panel is currently enabled.
 
virtual std::string GetDisabledTooltip () const
 Get tooltip text when panel is disabled.
 
virtual std::string GetShortcutHint () const
 Get keyboard shortcut hint for display.
 
virtual float GetPreferredWidth () const
 Get preferred width for this panel (optional)
 
virtual bool IsVisibleByDefault () const
 Whether this panel should be visible by default.
 
virtual std::string GetParentPanelId () const
 Get parent panel ID for cascade behavior.
 
virtual bool CascadeCloseChildren () const
 Whether closing this panel should close child panels.
 

Protected Member Functions

virtual gfx::PaletteGroupGetPaletteGroup ()=0
 Get the palette group for this card.
 
virtual const gfx::PaletteGroupGetPaletteGroup () const =0
 
virtual const PaletteGroupMetadataGetMetadata () const =0
 Get metadata for this palette group.
 
virtual void DrawPaletteGrid ()=0
 Draw the palette grid specific to this palette type.
 
virtual int GetColorsPerRow () const =0
 Get the number of colors per row for grid layout.
 
virtual void DrawCustomToolbarButtons ()
 Draw additional toolbar buttons (called after standard buttons)
 
virtual void DrawCustomPanels ()
 Draw additional panels (called after main content)
 
void DrawToolbar ()
 Draw standard toolbar with save/discard/undo/redo.
 
void DrawPaletteSelector ()
 Draw palette selector dropdown.
 
void DrawColorPicker ()
 Draw color picker for selected color.
 
void DrawColorInfo ()
 Draw color info panel with RGB/SNES/Hex values.
 
void DrawMetadataInfo ()
 Draw palette metadata info panel.
 
void DrawBatchOperationsPopup ()
 Draw batch operations popup.
 
gfx::SnesPaletteGetMutablePalette (int index)
 Get mutable palette by index.
 
gfx::SnesColor GetOriginalColor (int palette_index, int color_index) const
 Get original color from ROM (for reset/comparison)
 
absl::Status WriteColorToRom (int palette_index, int color_index, const gfx::SnesColor &color)
 Write a single color to ROM.
 
void MarkModified (int palette_index, int color_index)
 Mark palette as modified.
 
void ClearModified (int palette_index)
 Clear modified flags for palette.
 

Protected Attributes

std::string group_name_
 
std::string display_name_
 
Romrom_
 
zelda3::GameDatagame_data_ = nullptr
 
bool show_ = false
 
int selected_palette_ = 0
 
int selected_color_ = -1
 
gfx::SnesColor editing_color_
 
bool auto_save_enabled_ = false
 
bool show_snes_format_ = true
 
bool show_hex_format_ = true
 

Detailed Description

Base class for palette group editing cards.

Provides common functionality for all palette group editors:

  • ROM persistence with transaction-based writes
  • Undo/redo history management
  • Modified state tracking with visual indicators
  • Save/discard workflow
  • Common toolbar and color picker UI
  • PanelManager integration

Derived classes implement specific grid layouts and palette access.

Definition at line 70 of file palette_group_panel.h.

Constructor & Destructor Documentation

◆ PaletteGroupPanel()

yaze::editor::PaletteGroupPanel::PaletteGroupPanel ( const std::string & group_name,
const std::string & display_name,
Rom * rom,
zelda3::GameData * game_data = nullptr )

Construct a new Palette Group Panel.

Parameters
group_nameInternal palette group name (e.g., "ow_main", "dungeon_main")
display_nameHuman-readable name for UI
romROM instance for reading/writing palettes
game_dataGameData instance for palette access

Definition at line 24 of file palette_group_panel.cc.

◆ ~PaletteGroupPanel()

virtual yaze::editor::PaletteGroupPanel::~PaletteGroupPanel ( )
virtualdefault

Member Function Documentation

◆ SetGameData()

void yaze::editor::PaletteGroupPanel::SetGameData ( zelda3::GameData * game_data)
inline

Definition at line 84 of file palette_group_panel.h.

References game_data_.

◆ Draw()

void yaze::editor::PaletteGroupPanel::Draw ( bool * p_open)
overridevirtual

◆ GetId()

std::string yaze::editor::PaletteGroupPanel::GetId ( ) const
inlineoverridevirtual

Unique identifier for this panel.

Returns
Panel ID in format "{category}.{name}" (e.g., "dungeon.room_selector")

IDs should be:

  • Lowercase with underscores
  • Prefixed with editor category
  • Unique across all panels

Implements yaze::editor::EditorPanel.

Definition at line 99 of file palette_group_panel.h.

References group_name_.

◆ GetDisplayName()

std::string yaze::editor::PaletteGroupPanel::GetDisplayName ( ) const
inlineoverridevirtual

Human-readable name shown in menus and title bars.

Returns
Display name (e.g., "Room Selector")

Implements yaze::editor::EditorPanel.

Definition at line 100 of file palette_group_panel.h.

References display_name_.

◆ GetIcon()

std::string yaze::editor::PaletteGroupPanel::GetIcon ( ) const
inlineoverridevirtual

Material Design icon for this panel.

Returns
Icon constant (e.g., ICON_MD_LIST)

Implements yaze::editor::EditorPanel.

Reimplemented in yaze::editor::SpritePalettePanel, yaze::editor::SpritesAux1PalettePanel, yaze::editor::SpritesAux2PalettePanel, and yaze::editor::SpritesAux3PalettePanel.

Definition at line 101 of file palette_group_panel.h.

References ICON_MD_PALETTE.

◆ GetEditorCategory()

std::string yaze::editor::PaletteGroupPanel::GetEditorCategory ( ) const
inlineoverridevirtual

Editor category this panel belongs to.

Returns
Category name matching EditorType (e.g., "Dungeon", "Overworld")

Implements yaze::editor::EditorPanel.

Definition at line 102 of file palette_group_panel.h.

◆ GetPriority()

int yaze::editor::PaletteGroupPanel::GetPriority ( ) const
inlineoverridevirtual

Get display priority for menu ordering.

Returns
Priority value (lower = higher in list, default 50)

Reimplemented from yaze::editor::EditorPanel.

Reimplemented in yaze::editor::SpritePalettePanel, yaze::editor::SpritesAux1PalettePanel, yaze::editor::SpritesAux2PalettePanel, and yaze::editor::SpritesAux3PalettePanel.

Definition at line 103 of file palette_group_panel.h.

◆ Show()

void yaze::editor::PaletteGroupPanel::Show ( )
inline

Definition at line 107 of file palette_group_panel.h.

References show_.

Referenced by yaze::editor::PaletteEditor::JumpToPalette().

◆ Hide()

void yaze::editor::PaletteGroupPanel::Hide ( )
inline

Definition at line 108 of file palette_group_panel.h.

References show_.

◆ IsVisible()

bool yaze::editor::PaletteGroupPanel::IsVisible ( ) const
inline

Definition at line 109 of file palette_group_panel.h.

References show_.

◆ visibility_flag()

bool * yaze::editor::PaletteGroupPanel::visibility_flag ( )
inline

Definition at line 110 of file palette_group_panel.h.

References show_.

◆ SaveToRom()

absl::Status yaze::editor::PaletteGroupPanel::SaveToRom ( )

Save all modified palettes to ROM.

Definition at line 418 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::SaveGroup().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ DiscardChanges()

void yaze::editor::PaletteGroupPanel::DiscardChanges ( )

Discard all unsaved changes.

Definition at line 423 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::DiscardGroup(), yaze::gfx::PaletteManager::Get(), group_name_, and selected_color_.

Referenced by DrawBatchOperationsPopup(), and DrawToolbar().

Here is the call graph for this function:

◆ ResetPalette()

void yaze::editor::PaletteGroupPanel::ResetPalette ( int palette_index)

Reset a specific palette to original ROM values.

Definition at line 431 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::ResetPalette().

Referenced by DrawPaletteSelector().

Here is the call graph for this function:

◆ ResetColor()

void yaze::editor::PaletteGroupPanel::ResetColor ( int palette_index,
int color_index )

Reset a specific color to original ROM value.

Definition at line 436 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::ResetColor().

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ SetColor()

void yaze::editor::PaletteGroupPanel::SetColor ( int palette_index,
int color_index,
const gfx::SnesColor & new_color )

Set a color value (records change for undo)

Todo
Show error notification

Definition at line 402 of file palette_group_panel.cc.

References auto_save_enabled_, yaze::gfx::PaletteManager::Get(), group_name_, yaze::gfx::PaletteManager::SetColor(), and WriteColorToRom().

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ Undo()

void yaze::editor::PaletteGroupPanel::Undo ( )

Definition at line 444 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), and yaze::gfx::PaletteManager::Undo().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ Redo()

void yaze::editor::PaletteGroupPanel::Redo ( )

Definition at line 449 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), and yaze::gfx::PaletteManager::Redo().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ CanUndo()

bool yaze::editor::PaletteGroupPanel::CanUndo ( ) const

Definition at line 479 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::CanUndo(), and yaze::gfx::PaletteManager::Get().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ CanRedo()

bool yaze::editor::PaletteGroupPanel::CanRedo ( ) const

Definition at line 484 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::CanRedo(), and yaze::gfx::PaletteManager::Get().

Referenced by DrawToolbar().

Here is the call graph for this function:

◆ ClearHistory()

void yaze::editor::PaletteGroupPanel::ClearHistory ( )

Definition at line 454 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::ClearHistory(), and yaze::gfx::PaletteManager::Get().

Here is the call graph for this function:

◆ HasUnsavedChanges()

bool yaze::editor::PaletteGroupPanel::HasUnsavedChanges ( ) const

Definition at line 474 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::IsGroupModified().

Referenced by yaze::editor::PaletteEditor::DrawControlPanel().

Here is the call graph for this function:

◆ IsPaletteModified()

bool yaze::editor::PaletteGroupPanel::IsPaletteModified ( int palette_index) const

Definition at line 461 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, and yaze::gfx::PaletteManager::IsPaletteModified().

Referenced by DrawPaletteSelector(), and DrawToolbar().

Here is the call graph for this function:

◆ IsColorModified()

◆ GetSelectedPaletteIndex()

int yaze::editor::PaletteGroupPanel::GetSelectedPaletteIndex ( ) const
inline

Definition at line 154 of file palette_group_panel.h.

References selected_palette_.

◆ SetSelectedPaletteIndex()

void yaze::editor::PaletteGroupPanel::SetSelectedPaletteIndex ( int index)
inline

Definition at line 155 of file palette_group_panel.h.

References selected_palette_.

Referenced by yaze::editor::PaletteEditor::JumpToPalette().

◆ GetSelectedColorIndex()

int yaze::editor::PaletteGroupPanel::GetSelectedColorIndex ( ) const
inline

Definition at line 157 of file palette_group_panel.h.

References selected_color_.

◆ SetSelectedColorIndex()

void yaze::editor::PaletteGroupPanel::SetSelectedColorIndex ( int index)
inline

Definition at line 158 of file palette_group_panel.h.

References selected_color_.

◆ ExportToJson()

std::string yaze::editor::PaletteGroupPanel::ExportToJson ( ) const
Todo
Implement JSON export

Definition at line 518 of file palette_group_panel.cc.

◆ ImportFromJson()

absl::Status yaze::editor::PaletteGroupPanel::ImportFromJson ( const std::string & json)
Todo
Implement JSON import

Definition at line 523 of file palette_group_panel.cc.

◆ ExportToClipboard()

std::string yaze::editor::PaletteGroupPanel::ExportToClipboard ( ) const

Definition at line 528 of file palette_group_panel.cc.

References GetPaletteGroup(), and selected_palette_.

Referenced by DrawBatchOperationsPopup(), and DrawToolbar().

Here is the call graph for this function:

◆ ImportFromClipboard()

absl::Status yaze::editor::PaletteGroupPanel::ImportFromClipboard ( )
Todo
Implement clipboard import

Definition at line 548 of file palette_group_panel.cc.

Referenced by DrawBatchOperationsPopup(), and DrawToolbar().

◆ GetPaletteGroup() [1/2]

◆ GetPaletteGroup() [2/2]

◆ GetMetadata()

◆ DrawPaletteGrid()

◆ GetColorsPerRow()

◆ DrawCustomToolbarButtons()

virtual void yaze::editor::PaletteGroupPanel::DrawCustomToolbarButtons ( )
inlineprotectedvirtual

Draw additional toolbar buttons (called after standard buttons)

Definition at line 197 of file palette_group_panel.h.

Referenced by DrawToolbar().

◆ DrawCustomPanels()

virtual void yaze::editor::PaletteGroupPanel::DrawCustomPanels ( )
inlineprotectedvirtual

Draw additional panels (called after main content)

Reimplemented in yaze::editor::SpritePalettePanel.

Definition at line 202 of file palette_group_panel.h.

Referenced by Draw().

◆ DrawToolbar()

◆ DrawPaletteSelector()

void yaze::editor::PaletteGroupPanel::DrawPaletteSelector ( )
protected

◆ DrawColorPicker()

◆ DrawColorInfo()

void yaze::editor::PaletteGroupPanel::DrawColorInfo ( )
protected

Draw color info panel with RGB/SNES/Hex values.

Definition at line 272 of file palette_group_panel.cc.

References editing_color_, yaze::gfx::SnesColor::rgb(), yaze::gui::SectionHeader(), selected_color_, show_hex_format_, show_snes_format_, and yaze::gfx::SnesColor::snes().

Referenced by Draw().

Here is the call graph for this function:

◆ DrawMetadataInfo()

void yaze::editor::PaletteGroupPanel::DrawMetadataInfo ( )
protected

Draw palette metadata info panel.

Definition at line 310 of file palette_group_panel.cc.

References GetMetadata(), yaze::gui::SectionHeader(), and selected_palette_.

Referenced by Draw().

Here is the call graph for this function:

◆ DrawBatchOperationsPopup()

void yaze::editor::PaletteGroupPanel::DrawBatchOperationsPopup ( )
protected

Draw batch operations popup.

Definition at line 375 of file palette_group_panel.cc.

References DiscardChanges(), ExportToClipboard(), ImportFromClipboard(), yaze::gui::SectionHeader(), and yaze::gui::ThemedButton().

Referenced by Draw().

◆ GetMutablePalette()

◆ GetOriginalColor()

gfx::SnesColor yaze::editor::PaletteGroupPanel::GetOriginalColor ( int palette_index,
int color_index ) const
protected

Get original color from ROM (for reset/comparison)

Definition at line 499 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), yaze::gfx::PaletteManager::GetColor(), and group_name_.

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ WriteColorToRom()

absl::Status yaze::editor::PaletteGroupPanel::WriteColorToRom ( int palette_index,
int color_index,
const gfx::SnesColor & color )
protected

Write a single color to ROM.

Definition at line 506 of file palette_group_panel.cc.

References yaze::gfx::GetPaletteAddress(), group_name_, rom_, and yaze::Rom::WriteColor().

Referenced by SetColor().

Here is the call graph for this function:

◆ MarkModified()

void yaze::editor::PaletteGroupPanel::MarkModified ( int palette_index,
int color_index )
protected

Mark palette as modified.

◆ ClearModified()

void yaze::editor::PaletteGroupPanel::ClearModified ( int palette_index)
protected

Clear modified flags for palette.

Member Data Documentation

◆ group_name_

std::string yaze::editor::PaletteGroupPanel::group_name_
protected

◆ display_name_

std::string yaze::editor::PaletteGroupPanel::display_name_
protected

Definition at line 267 of file palette_group_panel.h.

Referenced by GetDisplayName().

◆ rom_

Rom* yaze::editor::PaletteGroupPanel::rom_
protected

Definition at line 268 of file palette_group_panel.h.

Referenced by Draw(), and WriteColorToRom().

◆ game_data_

◆ show_

bool yaze::editor::PaletteGroupPanel::show_ = false
protected

Definition at line 270 of file palette_group_panel.h.

Referenced by Hide(), IsVisible(), Show(), and visibility_flag().

◆ selected_palette_

◆ selected_color_

◆ editing_color_

◆ auto_save_enabled_

bool yaze::editor::PaletteGroupPanel::auto_save_enabled_ = false
protected

Definition at line 278 of file palette_group_panel.h.

Referenced by SetColor().

◆ show_snes_format_

bool yaze::editor::PaletteGroupPanel::show_snes_format_ = true
protected

Definition at line 279 of file palette_group_panel.h.

Referenced by DrawColorInfo().

◆ show_hex_format_

bool yaze::editor::PaletteGroupPanel::show_hex_format_ = true
protected

Definition at line 280 of file palette_group_panel.h.

Referenced by DrawColorInfo().


The documentation for this class was generated from the following files: