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::WindowContent.

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)
 
void SetProject (const project::YazeProject *project)
 
bool IsOwnedByRom (const Rom *rom) const
 
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::WindowContent
virtual ~WindowContent ()=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 WindowLifecycle GetWindowLifecycle () const
 Get the lifecycle category for this window.
 
virtual WindowContextScope GetContextScope () const
 Optional context binding for this window (room/selection/etc)
 
virtual WindowScope GetScope () const
 Get the registration scope for this window.
 
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 std::string GetWorkflowGroup () const
 Optional workflow group for hack-centric actions.
 
virtual std::string GetWorkflowLabel () const
 Optional workflow label for menus/command palette.
 
virtual std::string GetWorkflowDescription () const
 Optional workflow description for menus/command palette.
 
virtual int GetWorkflowPriority () const
 Optional workflow ordering priority (lower sorts first).
 
virtual float GetPreferredWidth () const
 Get preferred width for this panel (optional)
 
virtual float GetPreferredHeight () const
 Get preferred height for this panel (optional)
 
virtual bool PreferAutoHideTabBar () const
 Whether the dock node hosting this panel should auto-hide its tab bar.
 
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)
 
bool IsManagedSession () const
 Return true only while PaletteManager is bound to this panel's session.
 
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::WindowContent
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
 
const project::YazeProjectproject_ = nullptr
 
bool show_ = false
 
int selected_palette_ = 0
 
int selected_color_ = -1
 
gfx::SnesColor editing_color_
 
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
  • WorkspaceWindowManager integration

Derived classes implement specific grid layouts and palette access.

Definition at line 76 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 133 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 90 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::WindowContent.

Definition at line 105 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::WindowContent.

Definition at line 106 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::WindowContent.

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

Definition at line 107 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::WindowContent.

Definition at line 110 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::WindowContent.

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

Definition at line 111 of file palette_group_panel.h.

◆ Show()

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

Definition at line 117 of file palette_group_panel.h.

References show_.

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

◆ Hide()

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

Definition at line 118 of file palette_group_panel.h.

References show_.

◆ IsVisible()

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

Definition at line 119 of file palette_group_panel.h.

References show_.

◆ visibility_flag()

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

Definition at line 120 of file palette_group_panel.h.

References show_.

◆ SetToastManager()

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

Definition at line 122 of file palette_group_panel.h.

References toast_manager_.

◆ SetProject()

void yaze::editor::PaletteGroupPanel::SetProject ( const project::YazeProject * project)
inline

Definition at line 125 of file palette_group_panel.h.

References project_.

◆ IsOwnedByRom()

bool yaze::editor::PaletteGroupPanel::IsOwnedByRom ( const Rom * rom) const
inline

Definition at line 126 of file palette_group_panel.h.

References rom_.

◆ SaveToRom()

◆ DiscardChanges()

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

Discard all unsaved changes.

Definition at line 592 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::DiscardGroup(), yaze::gfx::PaletteManager::Get(), group_name_, IsManagedSession(), 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 603 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, IsManagedSession(), 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 611 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, IsManagedSession(), 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 546 of file palette_group_panel.cc.

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

Referenced by DrawColorPicker().

Here is the call graph for this function:

◆ Undo()

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

Definition at line 622 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), IsManagedSession(), 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 630 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), IsManagedSession(), 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 675 of file palette_group_panel.cc.

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

Here is the call graph for this function:

◆ CanRedo()

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

Definition at line 683 of file palette_group_panel.cc.

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

Here is the call graph for this function:

◆ ClearHistory()

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

Definition at line 638 of file palette_group_panel.cc.

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

Here is the call graph for this function:

◆ HasUnsavedChanges()

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

◆ IsPaletteModified()

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

Definition at line 648 of file palette_group_panel.cc.

References yaze::gfx::PaletteManager::Get(), group_name_, IsManagedSession(), 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 170 of file palette_group_panel.h.

References selected_palette_.

◆ SetSelectedPaletteIndex()

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

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

References selected_color_.

◆ SetSelectedColorIndex()

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

Definition at line 174 of file palette_group_panel.h.

References selected_color_.

◆ ExportToJson()

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

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

◆ 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 213 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 218 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 416 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 454 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 519 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 701 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:

◆ IsManagedSession()

bool yaze::editor::PaletteGroupPanel::IsManagedSession ( ) const
protected

Return true only while PaletteManager is bound to this panel's session.

Definition at line 708 of file palette_group_panel.cc.

References game_data_, yaze::gfx::PaletteManager::Get(), and yaze::gfx::PaletteManager::IsManaging().

Referenced by CanRedo(), CanUndo(), ClearHistory(), DiscardChanges(), Draw(), HasUnsavedChanges(), ImportFromClipboard(), ImportFromJson(), IsColorModified(), IsPaletteModified(), Redo(), ResetColor(), ResetPalette(), SaveToRom(), SetColor(), and Undo().

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 280 of file palette_group_panel.h.

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

◆ rom_

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

Definition at line 281 of file palette_group_panel.h.

Referenced by Draw(), and IsOwnedByRom().

◆ game_data_

◆ project_

const project::YazeProject* yaze::editor::PaletteGroupPanel::project_ = nullptr
protected

Definition at line 283 of file palette_group_panel.h.

Referenced by SaveToRom(), and SetProject().

◆ show_

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

Definition at line 284 of file palette_group_panel.h.

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

◆ selected_palette_

◆ selected_color_

◆ editing_color_

◆ show_snes_format_

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

Definition at line 292 of file palette_group_panel.h.

Referenced by DrawColorInfo().

◆ show_hex_format_

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

Definition at line 293 of file palette_group_panel.h.

Referenced by DrawColorInfo().

◆ toast_manager_

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

Definition at line 295 of file palette_group_panel.h.

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


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