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

Shared state between GraphicsEditor panel components. More...

#include <graphics_editor_state.h>

Collaboration diagram for yaze::editor::GraphicsEditorState:

Public Member Functions

void MarkSheetModified (uint16_t sheet_id)
 Mark a sheet as modified for save tracking.
 
void ClearModifiedSheets ()
 Clear modification tracking (after save)
 
bool HasUnsavedChanges () const
 Check if any sheets have unsaved changes.
 
void PushUndoState (uint16_t sheet_id, const std::vector< uint8_t > &pixel_data, const gfx::SnesPalette &palette)
 Push current state to undo stack before modification.
 
bool PopUndoState (PixelEditorSnapshot &out)
 Pop and return the last undo state.
 
bool PopRedoState (PixelEditorSnapshot &out)
 Pop and return the last redo state.
 
bool CanUndo () const
 
bool CanRedo () const
 
void SelectSheet (uint16_t sheet_id)
 Select a sheet for editing.
 
void CloseSheet (uint16_t sheet_id)
 Close a sheet tab.
 
void SetTool (PixelTool tool)
 Set the current editing tool.
 
void SetZoom (float zoom)
 Set zoom level with clamping.
 
void ZoomIn ()
 
void ZoomOut ()
 
const char * GetToolName () const
 Get tool name for status display.
 

Public Attributes

uint16_t current_sheet_id = 0
 
std::set< uint16_t > open_sheets
 
std::set< uint16_t > selected_sheets
 
PixelTool current_tool = PixelTool::kPencil
 
uint8_t current_color_index = 1
 
ImVec4 current_color
 
uint8_t brush_size = 1
 
bool fill_contiguous = true
 
float zoom_level = 4.0f
 
bool show_grid = true
 
bool show_tile_boundaries = true
 
ImVec2 pan_offset = {0, 0}
 
bool show_cursor_crosshair = true
 
bool show_brush_preview = true
 
bool show_transparency_grid = true
 
bool show_pixel_info_tooltip = true
 
uint64_t palette_group_index = 0
 
uint64_t palette_index = 0
 
uint64_t sub_palette_index = 0
 
bool refresh_graphics = false
 
PixelSelection selection
 
ImVec2 selection_start
 
bool is_selecting = false
 
std::vector< PixelEditorSnapshotundo_stack
 
std::vector< PixelEditorSnapshotredo_stack
 
std::set< uint16_t > modified_sheets
 
std::function< void(uint16_t)> on_sheet_selected
 
std::function< void()> on_palette_changed
 
std::function< void()> on_tool_changed
 
std::function< void(uint16_t)> on_sheet_modified
 

Static Public Attributes

static constexpr size_t kMaxUndoHistory = 50
 

Detailed Description

Shared state between GraphicsEditor panel components.

This class maintains the state that needs to be shared between the Sheet Browser, Pixel Editor, and Palette Controls panels. It provides a single source of truth for selection, current sheet, palette, and editing state.

Definition at line 74 of file graphics_editor_state.h.

Member Function Documentation

◆ MarkSheetModified()

◆ ClearModifiedSheets()

void yaze::editor::GraphicsEditorState::ClearModifiedSheets ( )
inline

Clear modification tracking (after save)

Definition at line 140 of file graphics_editor_state.h.

References modified_sheets.

Referenced by yaze::editor::GraphicsEditor::Save().

◆ HasUnsavedChanges()

bool yaze::editor::GraphicsEditorState::HasUnsavedChanges ( ) const
inline

Check if any sheets have unsaved changes.

Definition at line 145 of file graphics_editor_state.h.

References modified_sheets.

Referenced by yaze::editor::GraphicsEditor::Save().

◆ PushUndoState()

void yaze::editor::GraphicsEditorState::PushUndoState ( uint16_t sheet_id,
const std::vector< uint8_t > & pixel_data,
const gfx::SnesPalette & palette )
inline

Push current state to undo stack before modification.

Definition at line 150 of file graphics_editor_state.h.

References kMaxUndoHistory, redo_stack, and undo_stack.

Referenced by yaze::editor::PixelEditorPanel::SaveUndoState().

◆ PopUndoState()

bool yaze::editor::GraphicsEditorState::PopUndoState ( PixelEditorSnapshot & out)
inline

Pop and return the last undo state.

Definition at line 167 of file graphics_editor_state.h.

References redo_stack, and undo_stack.

Referenced by yaze::editor::PixelEditorPanel::DrawToolbar().

◆ PopRedoState()

bool yaze::editor::GraphicsEditorState::PopRedoState ( PixelEditorSnapshot & out)
inline

Pop and return the last redo state.

Definition at line 178 of file graphics_editor_state.h.

References redo_stack, and undo_stack.

Referenced by yaze::editor::PixelEditorPanel::DrawToolbar().

◆ CanUndo()

bool yaze::editor::GraphicsEditorState::CanUndo ( ) const
inline

Definition at line 186 of file graphics_editor_state.h.

References undo_stack.

Referenced by yaze::editor::PixelEditorPanel::DrawToolbar().

◆ CanRedo()

bool yaze::editor::GraphicsEditorState::CanRedo ( ) const
inline

Definition at line 187 of file graphics_editor_state.h.

References redo_stack.

Referenced by yaze::editor::PixelEditorPanel::DrawToolbar().

◆ SelectSheet()

void yaze::editor::GraphicsEditorState::SelectSheet ( uint16_t sheet_id)
inline

◆ CloseSheet()

void yaze::editor::GraphicsEditorState::CloseSheet ( uint16_t sheet_id)
inline

Close a sheet tab.

Definition at line 203 of file graphics_editor_state.h.

References open_sheets.

Referenced by yaze::editor::PixelEditorPanel::DrawCanvas().

◆ SetTool()

void yaze::editor::GraphicsEditorState::SetTool ( PixelTool tool)
inline

Set the current editing tool.

Definition at line 208 of file graphics_editor_state.h.

References current_tool, and on_tool_changed.

Referenced by yaze::editor::PixelEditorPanel::DrawToolbar(), and yaze::editor::GraphicsEditor::HandleEditorShortcuts().

◆ SetZoom()

void yaze::editor::GraphicsEditorState::SetZoom ( float zoom)
inline

Set zoom level with clamping.

Definition at line 218 of file graphics_editor_state.h.

References zoom_level.

Referenced by yaze::editor::PixelEditorPanel::DrawViewControls(), ZoomIn(), and ZoomOut().

◆ ZoomIn()

void yaze::editor::GraphicsEditorState::ZoomIn ( )
inline

Definition at line 222 of file graphics_editor_state.h.

References SetZoom(), and zoom_level.

Referenced by yaze::editor::PixelEditorPanel::DrawViewControls(), and yaze::editor::GraphicsEditor::HandleEditorShortcuts().

Here is the call graph for this function:

◆ ZoomOut()

void yaze::editor::GraphicsEditorState::ZoomOut ( )
inline

Definition at line 223 of file graphics_editor_state.h.

References SetZoom(), and zoom_level.

Referenced by yaze::editor::PixelEditorPanel::DrawViewControls(), and yaze::editor::GraphicsEditor::HandleEditorShortcuts().

Here is the call graph for this function:

◆ GetToolName()

const char * yaze::editor::GraphicsEditorState::GetToolName ( ) const
inline

Member Data Documentation

◆ current_sheet_id

◆ open_sheets

◆ selected_sheets

std::set<uint16_t> yaze::editor::GraphicsEditorState::selected_sheets

◆ current_tool

◆ current_color_index

◆ current_color

ImVec4 yaze::editor::GraphicsEditorState::current_color

◆ brush_size

◆ fill_contiguous

bool yaze::editor::GraphicsEditorState::fill_contiguous = true

Definition at line 86 of file graphics_editor_state.h.

◆ zoom_level

◆ show_grid

◆ show_tile_boundaries

bool yaze::editor::GraphicsEditorState::show_tile_boundaries = true

Definition at line 91 of file graphics_editor_state.h.

◆ pan_offset

ImVec2 yaze::editor::GraphicsEditorState::pan_offset = {0, 0}

Definition at line 92 of file graphics_editor_state.h.

◆ show_cursor_crosshair

bool yaze::editor::GraphicsEditorState::show_cursor_crosshair = true

◆ show_brush_preview

bool yaze::editor::GraphicsEditorState::show_brush_preview = true

◆ show_transparency_grid

bool yaze::editor::GraphicsEditorState::show_transparency_grid = true

◆ show_pixel_info_tooltip

bool yaze::editor::GraphicsEditorState::show_pixel_info_tooltip = true

Definition at line 98 of file graphics_editor_state.h.

Referenced by yaze::editor::PixelEditorPanel::DrawCanvas().

◆ palette_group_index

◆ palette_index

◆ sub_palette_index

◆ refresh_graphics

◆ selection

◆ selection_start

ImVec2 yaze::editor::GraphicsEditorState::selection_start

Definition at line 108 of file graphics_editor_state.h.

◆ is_selecting

bool yaze::editor::GraphicsEditorState::is_selecting = false

◆ undo_stack

std::vector<PixelEditorSnapshot> yaze::editor::GraphicsEditorState::undo_stack

Definition at line 112 of file graphics_editor_state.h.

Referenced by CanUndo(), PopRedoState(), PopUndoState(), and PushUndoState().

◆ redo_stack

std::vector<PixelEditorSnapshot> yaze::editor::GraphicsEditorState::redo_stack

Definition at line 113 of file graphics_editor_state.h.

Referenced by CanRedo(), PopRedoState(), PopUndoState(), and PushUndoState().

◆ kMaxUndoHistory

constexpr size_t yaze::editor::GraphicsEditorState::kMaxUndoHistory = 50
staticconstexpr

Definition at line 114 of file graphics_editor_state.h.

Referenced by PushUndoState().

◆ modified_sheets

◆ on_sheet_selected

std::function<void(uint16_t)> yaze::editor::GraphicsEditorState::on_sheet_selected

Definition at line 120 of file graphics_editor_state.h.

Referenced by SelectSheet().

◆ on_palette_changed

std::function<void()> yaze::editor::GraphicsEditorState::on_palette_changed

Definition at line 121 of file graphics_editor_state.h.

◆ on_tool_changed

std::function<void()> yaze::editor::GraphicsEditorState::on_tool_changed

Definition at line 122 of file graphics_editor_state.h.

Referenced by SetTool().

◆ on_sheet_modified

std::function<void(uint16_t)> yaze::editor::GraphicsEditorState::on_sheet_modified

Definition at line 123 of file graphics_editor_state.h.

Referenced by MarkSheetModified().


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