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.

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 ()
 
void SetToastManager (ToastManager *toast_manager)
 
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 OnFirstDraw ()
 Called once before the first Draw() in a session.
 
virtual bool RequiresLazyInit () const
 Whether this panel uses lazy initialization.
 
void InvalidateLazyInit ()
 Reset lazy init state so OnFirstDraw() runs again.
 
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 PanelContextScope GetContextScope () const
 Optional context binding for this panel (room/selection/etc)
 
virtual PanelScope GetScope () const
 Get the registration scope 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.
 
void DrawWithLazyInit (bool *p_open)
 Execute lazy initialization if needed, then call Draw()
 

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 Member Functions inherited from yaze::editor::EditorPanel
void InvalidateCache ()
 Invalidate all cached computations.
 
template<typename T >
T & GetCached (const std::string &key, std::function< T()> compute)
 Get or compute a cached value.
 
bool IsCacheValid () const
 Check if cache has been invalidated.
 
void ClearCache ()
 Clear all cached values (more aggressive than InvalidateCache)
 

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
 
ToastManagertoast_manager_ = nullptr
 

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 73 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 130 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 87 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 102 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 103 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 104 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 105 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 106 of file palette_group_panel.h.

◆ Show()

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

Definition at line 110 of file palette_group_panel.h.

References show_.

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

◆ Hide()

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

Definition at line 111 of file palette_group_panel.h.

References show_.

◆ IsVisible()

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

Definition at line 112 of file palette_group_panel.h.

References show_.

◆ visibility_flag()

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

Definition at line 113 of file palette_group_panel.h.

References show_.

◆ SetToastManager()

void yaze::editor::PaletteGroupPanel::SetToastManager ( ToastManager * toast_manager)
inline

Definition at line 115 of file palette_group_panel.h.

References toast_manager_.

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

◆ SaveToRom()

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

Save all modified palettes to ROM.

Definition at line 561 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 566 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 574 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 579 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)

Definition at line 541 of file palette_group_panel.cc.

References auto_save_enabled_, yaze::gfx::PaletteManager::Get(), group_name_, yaze::editor::kError, yaze::gfx::PaletteManager::SetColor(), yaze::editor::ToastManager::Show(), toast_manager_, and WriteColorToRom().

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ Undo()

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

Definition at line 587 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 592 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 622 of file palette_group_panel.cc.

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

Here is the call graph for this function:

◆ CanRedo()

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

Definition at line 627 of file palette_group_panel.cc.

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

Here is the call graph for this function:

◆ ClearHistory()

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

Definition at line 597 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 617 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 604 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 161 of file palette_group_panel.h.

References selected_palette_.

◆ SetSelectedPaletteIndex()

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

Definition at line 162 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 164 of file palette_group_panel.h.

References selected_color_.

◆ SetSelectedColorIndex()

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

Definition at line 165 of file palette_group_panel.h.

References selected_color_.

◆ ExportToJson()

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

Definition at line 661 of file palette_group_panel.cc.

References yaze::Json::array(), display_name_, yaze::Json::dump(), GetPaletteGroup(), group_name_, and yaze::Json::object().

Here is the call graph for this function:

◆ ImportFromJson()

absl::Status yaze::editor::PaletteGroupPanel::ImportFromJson ( const std::string & json)

◆ ExportToClipboard()

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

Definition at line 828 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 ( )

Definition at line 848 of file palette_group_panel.cc.

References editing_color_, yaze::gfx::PaletteManager::Get(), GetMutablePalette(), group_name_, selected_color_, and selected_palette_.

Referenced by DrawBatchOperationsPopup(), and DrawToolbar().

Here is the call graph for this function:

◆ 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 204 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 209 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 411 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 449 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 514 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 642 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 649 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_

◆ display_name_

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

Definition at line 274 of file palette_group_panel.h.

Referenced by DrawToolbar(), ExportToJson(), and GetDisplayName().

◆ rom_

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

Definition at line 275 of file palette_group_panel.h.

Referenced by Draw(), and WriteColorToRom().

◆ game_data_

◆ show_

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

Definition at line 277 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 285 of file palette_group_panel.h.

Referenced by SetColor().

◆ show_snes_format_

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

Definition at line 286 of file palette_group_panel.h.

Referenced by DrawColorInfo().

◆ show_hex_format_

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

Definition at line 287 of file palette_group_panel.h.

Referenced by DrawColorInfo().

◆ toast_manager_

ToastManager* yaze::editor::PaletteGroupPanel::toast_manager_ = nullptr
protected

Definition at line 289 of file palette_group_panel.h.

Referenced by DrawToolbar(), SetColor(), and SetToastManager().


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