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

WindowContent for browsing and selecting graphics sheets. More...

#include <sheet_browser_panel.h>

Inheritance diagram for yaze::editor::SheetBrowserPanel:

Public Types

using LabelSetter
 
using LabelImporter
 
using SavePlanner
 

Public Member Functions

 SheetBrowserPanel (GraphicsEditorState *state)
 
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 Initialize ()
 Initialize the panel.
 
void Draw (bool *p_open) override
 Draw the sheet browser UI.
 
absl::Status Update ()
 Legacy Update method for backward compatibility.
 
void SetDataSources (Rom *rom, zelda3::GameData *game_data, std::function< const project::YazeProject *()> project_getter)
 Where free-block and "used by" data come from. The project getter may return null (no project open).
 
void RefreshInventory ()
 Rebuild the sheet inventory from the ROM buffer. Runs lazily on the first draw and when the ROM changes.
 
const std::optional< zelda3::GfxSheetInventory > & inventory () const
 
void SetLabelCallbacks (LabelSetter setter, LabelImporter importer)
 Project-label writers. Unset callbacks disable label editing.
 
void SetUndoManager (UndoManager *undo_manager)
 Where PNG imports push their undo steps. Unset means no undo.
 
void SetSavePlanner (SavePlanner planner)
 Source of the "Pending graphics save" preflight list (GraphicsEditor::PlanGraphicsSave). Unset hides the list.
 
- 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 WindowPresentationPolicy GetPresentationPolicy () const
 How this content is hosted and advertised by workspace chrome.
 
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 bool HasExactPreferredWidth () const
 Whether GetPreferredWidth() is an exact content width.
 
virtual float GetPreferredHeight () const
 Get preferred height for this panel (optional)
 
virtual bool PrefersFloating () const
 
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()
 

Private Member Functions

void DrawSearchBar ()
 Draw the search/filter bar.
 
void DrawSheetGrid ()
 Draw the sheet grid view.
 
void DrawSheetThumbnail (int sheet_id, gfx::Bitmap &bitmap)
 Draw a single sheet thumbnail.
 
void DrawBatchOperations ()
 Draw batch operation buttons.
 
void DrawSelectedSheetInfo ()
 Storage, reserved state, free 16x16 blocks and "used by" for the current sheet.
 
std::string SheetLabel (uint16_t sheet) const
 
void DrawSheetLabelEditor (uint16_t sheet_id)
 
void DrawPngTransfer (uint16_t sheet_id)
 
absl::StatusOr< zelda3::SheetPalette > PngPalette (int sheet_id=-1)
 
void SetPngStatus (std::string message, bool is_error)
 
void DrawPendingSave ()
 
std::string SheetUsageSummary (uint16_t sheet_id) const
 

Private Attributes

GraphicsEditorState * state_
 
gui::Canvas thumbnail_canvas_
 
char search_buffer_ [16] = {0}
 
int filter_min_ = 0
 
int filter_max_ = 222
 
bool show_only_modified_ = false
 
float thumbnail_scale_ = 2.0f
 
int columns_ = 2
 
Rom * rom_ = nullptr
 
zelda3::GameData * game_data_ = nullptr
 
std::function< const project::YazeProject *()> project_getter_
 
std::optional< zelda3::GfxSheetInventory > inventory_
 
std::string inventory_error_
 
const Rom * inventory_rom_ = nullptr
 
bool show_free_blocks_ = true
 
LabelSetter label_setter_
 
LabelImporter label_importer_
 
int label_edit_sheet_ = -1
 
std::string label_buffer_
 
std::string label_status_
 
UndoManager * undo_manager_ = nullptr
 
int png_palette_mode_
 
int png_room_ = 0
 
int png_room_slot_ = -1
 
int png_palette_row_ = 2
 
int png_first_block_ = 0
 
std::string png_path_
 
std::vector< SheetPngImportPreview > png_pending_
 
std::string png_status_
 
bool png_status_is_error_ = false
 
SavePlanner save_planner_
 
std::vector< GraphicsSavePlanEntry > save_plan_
 
std::string save_plan_error_
 
std::set< uint16_t > save_plan_sheets_
 

Additional Inherited Members

- 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)
 

Detailed Description

WindowContent for browsing and selecting graphics sheets.

Displays a grid view of all 223 graphics sheets from the ROM. Supports single/multi-select, search/filter, and batch operations.

Definition at line 40 of file sheet_browser_panel.h.

Member Typedef Documentation

◆ LabelSetter

Initial value:
std::function<absl::Status(uint16_t sheet, const std::string& label)>

Definition at line 92 of file sheet_browser_panel.h.

◆ LabelImporter

Initial value:
std::function<absl::StatusOr<int>(const std::string& csv_text)>

Definition at line 94 of file sheet_browser_panel.h.

◆ SavePlanner

Initial value:
std::function<absl::StatusOr<std::vector<GraphicsSavePlanEntry>>()>

Definition at line 112 of file sheet_browser_panel.h.

Constructor & Destructor Documentation

◆ SheetBrowserPanel()

yaze::editor::SheetBrowserPanel::SheetBrowserPanel ( GraphicsEditorState * state)
inlineexplicit

Definition at line 42 of file sheet_browser_panel.h.

Member Function Documentation

◆ GetId()

std::string yaze::editor::SheetBrowserPanel::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 48 of file sheet_browser_panel.h.

◆ GetDisplayName()

std::string yaze::editor::SheetBrowserPanel::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 49 of file sheet_browser_panel.h.

◆ GetIcon()

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

Material Design icon for this panel.

Returns
Icon constant (e.g., ICON_MD_LIST)

Implements yaze::editor::WindowContent.

Definition at line 50 of file sheet_browser_panel.h.

References ICON_MD_VIEW_LIST.

◆ GetEditorCategory()

std::string yaze::editor::SheetBrowserPanel::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 51 of file sheet_browser_panel.h.

◆ GetPriority()

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

Get display priority for menu ordering.

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

Reimplemented from yaze::editor::WindowContent.

Definition at line 52 of file sheet_browser_panel.h.

◆ Initialize()

void yaze::editor::SheetBrowserPanel::Initialize ( )

Initialize the panel.

Definition at line 34 of file sheet_browser_panel.cc.

References columns_, and thumbnail_scale_.

◆ Draw()

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

Draw the sheet browser UI.

Implements yaze::editor::WindowContent.

Definition at line 40 of file sheet_browser_panel.cc.

References Update().

Here is the call graph for this function:

◆ Update()

absl::Status yaze::editor::SheetBrowserPanel::Update ( )

◆ SetDataSources()

void yaze::editor::SheetBrowserPanel::SetDataSources ( Rom * rom,
zelda3::GameData * game_data,
std::function< const project::YazeProject *()> project_getter )

Where free-block and "used by" data come from. The project getter may return null (no project open).

Definition at line 80 of file sheet_browser_panel.cc.

References game_data_, project_getter_, and rom_.

◆ RefreshInventory()

void yaze::editor::SheetBrowserPanel::RefreshInventory ( )

◆ inventory()

const std::optional< zelda3::GfxSheetInventory > & yaze::editor::SheetBrowserPanel::inventory ( ) const
inline

Definition at line 88 of file sheet_browser_panel.h.

References inventory_.

Referenced by RefreshInventory().

◆ SetLabelCallbacks()

void yaze::editor::SheetBrowserPanel::SetLabelCallbacks ( LabelSetter setter,
LabelImporter importer )
inline

Project-label writers. Unset callbacks disable label editing.

Definition at line 100 of file sheet_browser_panel.h.

References label_importer_, and label_setter_.

◆ SetUndoManager()

void yaze::editor::SheetBrowserPanel::SetUndoManager ( UndoManager * undo_manager)
inline

Where PNG imports push their undo steps. Unset means no undo.

Definition at line 108 of file sheet_browser_panel.h.

References undo_manager_.

◆ SetSavePlanner()

void yaze::editor::SheetBrowserPanel::SetSavePlanner ( SavePlanner planner)
inline

Source of the "Pending graphics save" preflight list (GraphicsEditor::PlanGraphicsSave). Unset hides the list.

Definition at line 118 of file sheet_browser_panel.h.

References save_planner_.

◆ DrawSearchBar()

void yaze::editor::SheetBrowserPanel::DrawSearchBar ( )
private

◆ DrawSheetGrid()

void yaze::editor::SheetBrowserPanel::DrawSheetGrid ( )
private

◆ DrawSheetThumbnail()

void yaze::editor::SheetBrowserPanel::DrawSheetThumbnail ( int sheet_id,
gfx::Bitmap & bitmap )
private

Draw a single sheet thumbnail.

Parameters
sheet_idSheet index (0-222)
bitmapThe bitmap to display

Definition at line 771 of file sheet_browser_panel.cc.

References yaze::gui::Canvas::AddRectFilledAt(), yaze::gui::Canvas::AddTextAt(), yaze::gui::BeginCanvas(), yaze::gui::CanvasFrameOptions::canvas_size, yaze::gui::BitmapPreviewOptions::canvas_size, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Bitmap::depth(), yaze::gui::BitmapPreviewOptions::dest_pos, yaze::gui::BitmapPreviewOptions::dest_size, yaze::gui::CanvasFrameOptions::draw_context_menu, yaze::gui::BitmapPreviewOptions::draw_context_menu, yaze::gui::CanvasFrameOptions::draw_grid, yaze::gui::BitmapPreviewOptions::draw_grid, yaze::gui::CanvasFrameOptions::draw_overlay, yaze::gui::BitmapPreviewOptions::draw_overlay, yaze::gui::DrawBitmapPreview(), yaze::gui::EndCanvas(), yaze::gui::BitmapPreviewOptions::ensure_texture, yaze::gui::Canvas::GetConfig(), yaze::gui::GetErrorColor(), yaze::gui::GetModifiedColor(), yaze::gui::GetSelectedColor(), yaze::gui::GetWarningColor(), yaze::gui::CanvasFrameOptions::grid_step, yaze::gui::BitmapPreviewOptions::grid_step, yaze::gfx::Bitmap::height(), inventory_, yaze::gfx::Bitmap::is_active(), yaze::gui::kPreviewOnly, yaze::editor::GraphicsEditorState::modified_sheets, yaze::editor::GraphicsEditorState::open_sheets, yaze::gui::CanvasFrameOptions::render_popups, yaze::gui::BitmapPreviewOptions::render_popups, yaze::gui::CanvasConfig::role, yaze::editor::GraphicsEditorState::selected_sheets, yaze::editor::GraphicsEditorState::SelectSheet(), SheetLabel(), show_free_blocks_, state_, thumbnail_canvas_, thumbnail_scale_, yaze::gfx::Bitmap::width(), and yaze::gui::Canvas::zero_point().

Referenced by DrawSheetGrid().

◆ DrawBatchOperations()

void yaze::editor::SheetBrowserPanel::DrawBatchOperations ( )
private

Draw batch operation buttons.

Definition at line 703 of file sheet_browser_panel.cc.

References filter_max_, filter_min_, yaze::gui::LayoutHelpers::GetSliderWidth(), ICON_MD_DESELECT, ICON_MD_SELECT_ALL, yaze::editor::GraphicsEditorState::selected_sheets, state_, and thumbnail_scale_.

Referenced by DrawSearchBar().

Here is the call graph for this function:

◆ DrawSelectedSheetInfo()

void yaze::editor::SheetBrowserPanel::DrawSelectedSheetInfo ( )
private

◆ SheetLabel()

std::string yaze::editor::SheetBrowserPanel::SheetLabel ( uint16_t sheet) const
private

Definition at line 132 of file sheet_browser_panel.cc.

References yaze::core::GetGraphicsSheetLabel(), and project_getter_.

Referenced by DrawSheetLabelEditor(), and DrawSheetThumbnail().

Here is the call graph for this function:

◆ DrawSheetLabelEditor()

void yaze::editor::SheetBrowserPanel::DrawSheetLabelEditor ( uint16_t sheet_id)
private

◆ DrawPngTransfer()

◆ PngPalette()

◆ SetPngStatus()

void yaze::editor::SheetBrowserPanel::SetPngStatus ( std::string message,
bool is_error )
private

Definition at line 359 of file sheet_browser_panel.cc.

References png_status_, and png_status_is_error_.

Referenced by DrawPngTransfer().

◆ DrawPendingSave()

◆ SheetUsageSummary()

std::string yaze::editor::SheetBrowserPanel::SheetUsageSummary ( uint16_t sheet_id) const
private

Definition at line 285 of file sheet_browser_panel.cc.

References inventory_.

Referenced by DrawPendingSave().

Member Data Documentation

◆ state_

◆ thumbnail_canvas_

gui::Canvas yaze::editor::SheetBrowserPanel::thumbnail_canvas_
private

Definition at line 152 of file sheet_browser_panel.h.

Referenced by DrawSheetThumbnail().

◆ search_buffer_

char yaze::editor::SheetBrowserPanel::search_buffer_[16] = {0}
private

Definition at line 155 of file sheet_browser_panel.h.

Referenced by DrawSearchBar().

◆ filter_min_

int yaze::editor::SheetBrowserPanel::filter_min_ = 0
private

Definition at line 156 of file sheet_browser_panel.h.

Referenced by DrawBatchOperations(), DrawSearchBar(), and DrawSheetGrid().

◆ filter_max_

int yaze::editor::SheetBrowserPanel::filter_max_ = 222
private

Definition at line 157 of file sheet_browser_panel.h.

Referenced by DrawBatchOperations(), DrawSearchBar(), and DrawSheetGrid().

◆ show_only_modified_

bool yaze::editor::SheetBrowserPanel::show_only_modified_ = false
private

Definition at line 158 of file sheet_browser_panel.h.

Referenced by DrawSearchBar(), and DrawSheetGrid().

◆ thumbnail_scale_

float yaze::editor::SheetBrowserPanel::thumbnail_scale_ = 2.0f
private

◆ columns_

int yaze::editor::SheetBrowserPanel::columns_ = 2
private

Definition at line 162 of file sheet_browser_panel.h.

Referenced by DrawSheetGrid(), and Initialize().

◆ rom_

Rom* yaze::editor::SheetBrowserPanel::rom_ = nullptr
private

◆ game_data_

zelda3::GameData* yaze::editor::SheetBrowserPanel::game_data_ = nullptr
private

◆ project_getter_

std::function<const project::YazeProject*()> yaze::editor::SheetBrowserPanel::project_getter_
private

Definition at line 167 of file sheet_browser_panel.h.

Referenced by RefreshInventory(), SetDataSources(), and SheetLabel().

◆ inventory_

std::optional<zelda3::GfxSheetInventory> yaze::editor::SheetBrowserPanel::inventory_
private

◆ inventory_error_

std::string yaze::editor::SheetBrowserPanel::inventory_error_
private

Definition at line 169 of file sheet_browser_panel.h.

Referenced by DrawSelectedSheetInfo(), RefreshInventory(), and Update().

◆ inventory_rom_

const Rom* yaze::editor::SheetBrowserPanel::inventory_rom_ = nullptr
private

Definition at line 170 of file sheet_browser_panel.h.

Referenced by RefreshInventory(), and Update().

◆ show_free_blocks_

bool yaze::editor::SheetBrowserPanel::show_free_blocks_ = true
private

Definition at line 171 of file sheet_browser_panel.h.

Referenced by DrawSelectedSheetInfo(), and DrawSheetThumbnail().

◆ label_setter_

LabelSetter yaze::editor::SheetBrowserPanel::label_setter_
private

Definition at line 176 of file sheet_browser_panel.h.

Referenced by DrawSheetLabelEditor(), and SetLabelCallbacks().

◆ label_importer_

LabelImporter yaze::editor::SheetBrowserPanel::label_importer_
private

Definition at line 177 of file sheet_browser_panel.h.

Referenced by DrawSheetLabelEditor(), and SetLabelCallbacks().

◆ label_edit_sheet_

int yaze::editor::SheetBrowserPanel::label_edit_sheet_ = -1
private

Definition at line 178 of file sheet_browser_panel.h.

Referenced by DrawSheetLabelEditor().

◆ label_buffer_

std::string yaze::editor::SheetBrowserPanel::label_buffer_
private

Definition at line 179 of file sheet_browser_panel.h.

Referenced by DrawSheetLabelEditor().

◆ label_status_

std::string yaze::editor::SheetBrowserPanel::label_status_
private

Definition at line 180 of file sheet_browser_panel.h.

Referenced by DrawSheetLabelEditor().

◆ undo_manager_

UndoManager* yaze::editor::SheetBrowserPanel::undo_manager_ = nullptr
private

Definition at line 188 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer(), and SetUndoManager().

◆ png_palette_mode_

int yaze::editor::SheetBrowserPanel::png_palette_mode_
private
Initial value:
=
0

Definition at line 189 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer(), and PngPalette().

◆ png_room_

int yaze::editor::SheetBrowserPanel::png_room_ = 0
private

Definition at line 191 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer(), and PngPalette().

◆ png_room_slot_

int yaze::editor::SheetBrowserPanel::png_room_slot_ = -1
private

Definition at line 192 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer(), and PngPalette().

◆ png_palette_row_

int yaze::editor::SheetBrowserPanel::png_palette_row_ = 2
private

Definition at line 193 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer(), and PngPalette().

◆ png_first_block_

int yaze::editor::SheetBrowserPanel::png_first_block_ = 0
private

Definition at line 194 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer().

◆ png_path_

std::string yaze::editor::SheetBrowserPanel::png_path_
private

Definition at line 195 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer().

◆ png_pending_

std::vector<SheetPngImportPreview> yaze::editor::SheetBrowserPanel::png_pending_
private

Definition at line 196 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer().

◆ png_status_

std::string yaze::editor::SheetBrowserPanel::png_status_
private

Definition at line 197 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer(), and SetPngStatus().

◆ png_status_is_error_

bool yaze::editor::SheetBrowserPanel::png_status_is_error_ = false
private

Definition at line 198 of file sheet_browser_panel.h.

Referenced by DrawPngTransfer(), and SetPngStatus().

◆ save_planner_

SavePlanner yaze::editor::SheetBrowserPanel::save_planner_
private

Definition at line 204 of file sheet_browser_panel.h.

Referenced by DrawPendingSave(), and SetSavePlanner().

◆ save_plan_

std::vector<GraphicsSavePlanEntry> yaze::editor::SheetBrowserPanel::save_plan_
private

Definition at line 205 of file sheet_browser_panel.h.

Referenced by DrawPendingSave().

◆ save_plan_error_

std::string yaze::editor::SheetBrowserPanel::save_plan_error_
private

Definition at line 206 of file sheet_browser_panel.h.

Referenced by DrawPendingSave().

◆ save_plan_sheets_

std::set<uint16_t> yaze::editor::SheetBrowserPanel::save_plan_sheets_
private

Definition at line 207 of file sheet_browser_panel.h.

Referenced by DrawPendingSave().


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