Main pixel editing panel for graphics sheets. More...
#include <pixel_editor_panel.h>
Public Member Functions | |
| PixelEditorPanel (GraphicsEditorState *state, Rom *rom) | |
| 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 pixel editor UI (EditorPanel interface) | |
| absl::Status | Update () |
| Legacy Update method for backward compatibility. | |
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. | |
Private Member Functions | |
| void | DrawToolbar () |
| Draw the toolbar with tool selection. | |
| void | DrawViewControls () |
| Draw zoom and view controls. | |
| void | DrawCanvas () |
| Draw the main editing canvas. | |
| void | DrawColorPicker () |
| Draw the color palette picker. | |
| void | DrawStatusBar () |
| Draw the status bar with cursor position. | |
| void | DrawMiniMap () |
| Draw the mini navigation map. | |
| void | HandleCanvasInput () |
| Handle canvas mouse input for current tool. | |
| void | ApplyPencil (int x, int y) |
| Apply pencil tool at position. | |
| void | ApplyBrush (int x, int y) |
| Apply brush tool at position. | |
| void | ApplyEraser (int x, int y) |
| Apply eraser tool at position. | |
| void | ApplyFill (int x, int y) |
| Apply flood fill starting at position. | |
| void | ApplyEyedropper (int x, int y) |
| Apply eyedropper tool at position. | |
| void | DrawLine (int x1, int y1, int x2, int y2) |
| Draw line from start to end. | |
| void | DrawRectangle (int x1, int y1, int x2, int y2, bool filled) |
| Draw rectangle from start to end. | |
| void | BeginSelection (int x, int y) |
| Start a new selection. | |
| void | UpdateSelection (int x, int y) |
| Update selection during drag. | |
| void | EndSelection () |
| Finalize the selection. | |
| void | CopySelection () |
| Copy selection to clipboard. | |
| void | PasteSelection (int x, int y) |
| Paste clipboard at position. | |
| void | FlipSelectionHorizontal () |
| Flip selection horizontally. | |
| void | FlipSelectionVertical () |
| Flip selection vertically. | |
| void | SaveUndoState () |
| Save current state for undo. | |
| ImVec2 | ScreenToPixel (ImVec2 screen_pos) |
| Convert screen coordinates to pixel coordinates. | |
| ImVec2 | PixelToScreen (int x, int y) |
| Convert pixel coordinates to screen coordinates. | |
| void | DrawTransparencyGrid (float canvas_width, float canvas_height) |
| Draw checkerboard pattern for transparent pixels. | |
| void | DrawCursorCrosshair () |
| Draw crosshair at cursor position. | |
| void | DrawBrushPreview () |
| Draw brush size preview circle. | |
| void | DrawPixelInfoTooltip (const gfx::Bitmap &sheet) |
| Draw tooltip with pixel information. | |
Private Attributes | |
| GraphicsEditorState * | state_ |
| Rom * | rom_ |
| gui::Canvas | canvas_ |
| bool | is_drawing_ = false |
| ImVec2 | last_mouse_pixel_ = {-1, -1} |
| ImVec2 | tool_start_pixel_ = {-1, -1} |
| bool | show_tool_preview_ = false |
| ImVec2 | preview_end_ = {0, 0} |
| int | cursor_x_ = 0 |
| int | cursor_y_ = 0 |
| bool | cursor_in_canvas_ = false |
Main pixel editing panel for graphics sheets.
Provides a full-featured pixel editor with tools for drawing, selecting, and manipulating graphics data.
Definition at line 21 of file pixel_editor_panel.h.
|
inlineexplicit |
Definition at line 23 of file pixel_editor_panel.h.
|
inlineoverridevirtual |
Unique identifier for this panel.
IDs should be:
Implements yaze::editor::EditorPanel.
Definition at line 30 of file pixel_editor_panel.h.
|
inlineoverridevirtual |
Human-readable name shown in menus and title bars.
Implements yaze::editor::EditorPanel.
Definition at line 31 of file pixel_editor_panel.h.
|
inlineoverridevirtual |
Material Design icon for this panel.
Implements yaze::editor::EditorPanel.
Definition at line 32 of file pixel_editor_panel.h.
References ICON_MD_BRUSH.
|
inlineoverridevirtual |
Editor category this panel belongs to.
Implements yaze::editor::EditorPanel.
Definition at line 33 of file pixel_editor_panel.h.
|
inlineoverridevirtual |
Get display priority for menu ordering.
Reimplemented from yaze::editor::EditorPanel.
Definition at line 34 of file pixel_editor_panel.h.
| void yaze::editor::PixelEditorPanel::Initialize | ( | ) |
Initialize the panel.
Definition at line 15 of file pixel_editor_panel.cc.
|
overridevirtual |
Draw the pixel editor UI (EditorPanel interface)
Implements yaze::editor::EditorPanel.
Definition at line 19 of file pixel_editor_panel.cc.
References DrawCanvas(), DrawColorPicker(), DrawMiniMap(), DrawStatusBar(), DrawToolbar(), and DrawViewControls().
| absl::Status yaze::editor::PixelEditorPanel::Update | ( | ) |
Legacy Update method for backward compatibility.
Definition at line 52 of file pixel_editor_panel.cc.
References DrawCanvas(), DrawColorPicker(), DrawMiniMap(), DrawStatusBar(), DrawToolbar(), and DrawViewControls().
|
private |
Draw the toolbar with tool selection.
Definition at line 86 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::brush_size, yaze::editor::GraphicsEditorState::CanRedo(), yaze::editor::GraphicsEditorState::CanUndo(), yaze::editor::GraphicsEditorState::current_tool, yaze::gfx::Arena::Get(), HOVER_HINT, ICON_MD_AUTO_FIX_HIGH, ICON_MD_BRUSH, ICON_MD_COLORIZE, ICON_MD_CROP_SQUARE, ICON_MD_DRAW, ICON_MD_FORMAT_COLOR_FILL, ICON_MD_HORIZONTAL_RULE, ICON_MD_REDO, ICON_MD_SELECT_ALL, ICON_MD_UNDO, yaze::editor::kBrush, yaze::editor::kEraser, yaze::editor::kEyedropper, yaze::editor::kFill, yaze::editor::kLine, yaze::editor::kPencil, yaze::editor::kRectangle, yaze::editor::kSelect, yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), yaze::editor::PixelEditorSnapshot::pixel_data, yaze::editor::GraphicsEditorState::PopRedoState(), yaze::editor::GraphicsEditorState::PopUndoState(), yaze::editor::GraphicsEditorState::SetTool(), yaze::editor::PixelEditorSnapshot::sheet_id, and state_.
|
private |
Draw zoom and view controls.
Definition at line 167 of file pixel_editor_panel.cc.
References HOVER_HINT, ICON_MD_ADD, ICON_MD_BRUSH, ICON_MD_GRID_ON, ICON_MD_TEXTURE, ICON_MD_ZOOM_IN, ICON_MD_ZOOM_OUT, yaze::editor::GraphicsEditorState::SetZoom(), yaze::editor::GraphicsEditorState::show_brush_preview, yaze::editor::GraphicsEditorState::show_cursor_crosshair, yaze::editor::GraphicsEditorState::show_grid, yaze::editor::GraphicsEditorState::show_transparency_grid, state_, yaze::editor::GraphicsEditorState::zoom_level, yaze::editor::GraphicsEditorState::ZoomIn(), and yaze::editor::GraphicsEditorState::ZoomOut().
Referenced by Draw(), and Update().
|
private |
Draw the main editing canvas.
Definition at line 208 of file pixel_editor_panel.cc.
References canvas_, yaze::editor::GraphicsEditorState::CloseSheet(), yaze::editor::GraphicsEditorState::current_sheet_id, yaze::editor::GraphicsEditorState::current_tool, cursor_in_canvas_, yaze::gui::Canvas::draw_list(), yaze::gui::Canvas::DrawBackground(), DrawBrushPreview(), DrawCursorCrosshair(), yaze::gui::Canvas::DrawGrid(), yaze::gui::Canvas::DrawOverlay(), DrawPixelInfoTooltip(), DrawTransparencyGrid(), yaze::gfx::Arena::Get(), HandleCanvasInput(), yaze::editor::PixelSelection::height, yaze::editor::PixelSelection::is_active, is_drawing_, yaze::editor::kBrush, yaze::editor::kEraser, yaze::editor::kLine, yaze::editor::kRectangle, yaze::editor::GraphicsEditorState::modified_sheets, yaze::gfx::Arena::mutable_gfx_sheets(), yaze::editor::GraphicsEditorState::open_sheets, PixelToScreen(), preview_end_, yaze::editor::GraphicsEditorState::selection, yaze::editor::GraphicsEditorState::show_brush_preview, yaze::editor::GraphicsEditorState::show_cursor_crosshair, yaze::editor::GraphicsEditorState::show_grid, yaze::editor::GraphicsEditorState::show_pixel_info_tooltip, show_tool_preview_, yaze::editor::GraphicsEditorState::show_transparency_grid, state_, tool_start_pixel_, yaze::editor::PixelSelection::width, yaze::editor::PixelSelection::x, yaze::editor::PixelSelection::y, yaze::gui::Canvas::zero_point(), and yaze::editor::GraphicsEditorState::zoom_level.
|
private |
Draw the color palette picker.
Definition at line 440 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_color, yaze::editor::GraphicsEditorState::current_color_index, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::editor::GraphicsEditorState::open_sheets, and state_.
Referenced by Draw(), and Update().
|
private |
Draw the status bar with cursor position.
Definition at line 536 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_sheet_id, cursor_in_canvas_, cursor_x_, cursor_y_, yaze::editor::GraphicsEditorState::GetToolName(), yaze::editor::GraphicsEditorState::modified_sheets, state_, and yaze::editor::GraphicsEditorState::zoom_level.
Referenced by Draw(), and Update().
|
private |
Draw the mini navigation map.
Definition at line 507 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::editor::GraphicsEditorState::open_sheets, and state_.
Referenced by Draw(), and Update().
|
private |
Handle canvas mouse input for current tool.
Definition at line 570 of file pixel_editor_panel.cc.
References ApplyBrush(), ApplyEraser(), ApplyEyedropper(), ApplyFill(), ApplyPencil(), BeginSelection(), yaze::editor::GraphicsEditorState::current_sheet_id, yaze::editor::GraphicsEditorState::current_tool, cursor_in_canvas_, cursor_x_, cursor_y_, DrawLine(), DrawRectangle(), EndSelection(), yaze::gfx::Arena::Get(), is_drawing_, yaze::editor::kBrush, yaze::editor::kEraser, yaze::editor::kEyedropper, yaze::editor::kFill, yaze::editor::kLine, yaze::editor::kPencil, yaze::editor::kRectangle, yaze::editor::kSelect, last_mouse_pixel_, yaze::gfx::Arena::mutable_gfx_sheets(), preview_end_, SaveUndoState(), ScreenToPixel(), show_tool_preview_, state_, tool_start_pixel_, and UpdateSelection().
Referenced by DrawCanvas().
|
private |
Apply pencil tool at position.
Definition at line 678 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_color_index, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::editor::GraphicsEditorState::MarkSheetModified(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), and state_.
Referenced by HandleCanvasInput().
|
private |
Apply brush tool at position.
Definition at line 689 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::brush_size, yaze::editor::GraphicsEditorState::current_color_index, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::editor::GraphicsEditorState::MarkSheetModified(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), and state_.
Referenced by HandleCanvasInput().
|
private |
Apply eraser tool at position.
Definition at line 709 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::brush_size, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::editor::GraphicsEditorState::MarkSheetModified(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), and state_.
Referenced by HandleCanvasInput().
|
private |
Apply flood fill starting at position.
Definition at line 729 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_color_index, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::editor::GraphicsEditorState::MarkSheetModified(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), and state_.
Referenced by HandleCanvasInput().
|
private |
Apply eyedropper tool at position.
Definition at line 775 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_color, yaze::editor::GraphicsEditorState::current_color_index, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::gfx::Arena::gfx_sheets(), and state_.
Referenced by HandleCanvasInput().
|
private |
Draw line from start to end.
Definition at line 792 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_color_index, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::editor::GraphicsEditorState::MarkSheetModified(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), and state_.
Referenced by HandleCanvasInput().
|
private |
Draw rectangle from start to end.
Definition at line 825 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_color_index, yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::editor::GraphicsEditorState::MarkSheetModified(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), and state_.
Referenced by HandleCanvasInput().
|
private |
Start a new selection.
Definition at line 868 of file pixel_editor_panel.cc.
References yaze::editor::PixelSelection::height, yaze::editor::PixelSelection::is_active, yaze::editor::GraphicsEditorState::is_selecting, yaze::editor::GraphicsEditorState::selection, state_, yaze::editor::PixelSelection::width, yaze::editor::PixelSelection::x, and yaze::editor::PixelSelection::y.
Referenced by HandleCanvasInput().
|
private |
Update selection during drag.
Definition at line 877 of file pixel_editor_panel.cc.
References yaze::editor::PixelSelection::height, yaze::editor::GraphicsEditorState::selection, state_, tool_start_pixel_, yaze::editor::PixelSelection::width, yaze::editor::PixelSelection::x, and yaze::editor::PixelSelection::y.
Referenced by HandleCanvasInput().
|
private |
Finalize the selection.
Definition at line 887 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::gfx::Arena::gfx_sheets(), yaze::editor::PixelSelection::height, yaze::editor::GraphicsEditorState::is_selecting, yaze::editor::PixelSelection::palette, yaze::editor::PixelSelection::pixel_data, yaze::editor::GraphicsEditorState::selection, state_, yaze::editor::PixelSelection::width, yaze::editor::PixelSelection::x, and yaze::editor::PixelSelection::y.
Referenced by HandleCanvasInput().
|
private |
Copy selection to clipboard.
Definition at line 912 of file pixel_editor_panel.cc.
|
private |
Paste clipboard at position.
Definition at line 916 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::editor::PixelSelection::height, yaze::editor::GraphicsEditorState::MarkSheetModified(), yaze::gfx::Arena::mutable_gfx_sheets(), yaze::gfx::Arena::NotifySheetModified(), yaze::editor::PixelSelection::pixel_data, SaveUndoState(), yaze::editor::GraphicsEditorState::selection, state_, and yaze::editor::PixelSelection::width.
|
private |
Flip selection horizontally.
Definition at line 941 of file pixel_editor_panel.cc.
References yaze::editor::PixelSelection::height, yaze::editor::PixelSelection::pixel_data, yaze::editor::GraphicsEditorState::selection, state_, and yaze::editor::PixelSelection::width.
|
private |
Flip selection vertically.
Definition at line 955 of file pixel_editor_panel.cc.
References yaze::editor::PixelSelection::height, yaze::editor::PixelSelection::pixel_data, yaze::editor::GraphicsEditorState::selection, state_, and yaze::editor::PixelSelection::width.
|
private |
Save current state for undo.
Definition at line 970 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::current_sheet_id, yaze::gfx::Arena::Get(), yaze::gfx::Arena::gfx_sheets(), yaze::editor::GraphicsEditorState::PushUndoState(), and state_.
Referenced by HandleCanvasInput(), and PasteSelection().
|
private |
Convert screen coordinates to pixel coordinates.
Definition at line 976 of file pixel_editor_panel.cc.
References canvas_, state_, yaze::gui::Canvas::zero_point(), and yaze::editor::GraphicsEditorState::zoom_level.
Referenced by HandleCanvasInput().
|
private |
Convert pixel coordinates to screen coordinates.
Definition at line 982 of file pixel_editor_panel.cc.
References canvas_, state_, yaze::gui::Canvas::zero_point(), and yaze::editor::GraphicsEditorState::zoom_level.
Referenced by DrawBrushPreview(), DrawCanvas(), and DrawCursorCrosshair().
|
private |
Draw checkerboard pattern for transparent pixels.
Definition at line 336 of file pixel_editor_panel.cc.
References canvas_, yaze::gui::Canvas::draw_list(), and yaze::gui::Canvas::zero_point().
Referenced by DrawCanvas().
|
private |
Draw crosshair at cursor position.
Definition at line 358 of file pixel_editor_panel.cc.
References canvas_, yaze::gui::Canvas::canvas_size(), cursor_x_, cursor_y_, yaze::gui::Canvas::draw_list(), PixelToScreen(), state_, yaze::gui::Canvas::zero_point(), and yaze::editor::GraphicsEditorState::zoom_level.
Referenced by DrawCanvas().
|
private |
Draw brush size preview circle.
Definition at line 385 of file pixel_editor_panel.cc.
References yaze::editor::GraphicsEditorState::brush_size, canvas_, yaze::editor::GraphicsEditorState::current_tool, cursor_x_, cursor_y_, yaze::gui::Canvas::draw_list(), yaze::editor::kEraser, PixelToScreen(), state_, and yaze::editor::GraphicsEditorState::zoom_level.
Referenced by DrawCanvas().
|
private |
Draw tooltip with pixel information.
Definition at line 411 of file pixel_editor_panel.cc.
References cursor_x_, cursor_y_, yaze::gfx::Bitmap::GetPixel(), yaze::gfx::Bitmap::height(), yaze::gfx::Bitmap::palette(), and yaze::gfx::Bitmap::width().
Referenced by DrawCanvas().
|
private |
Definition at line 201 of file pixel_editor_panel.h.
Referenced by ApplyBrush(), ApplyEraser(), ApplyEyedropper(), ApplyFill(), ApplyPencil(), BeginSelection(), DrawBrushPreview(), DrawCanvas(), DrawColorPicker(), DrawCursorCrosshair(), DrawLine(), DrawMiniMap(), DrawRectangle(), DrawStatusBar(), DrawToolbar(), DrawViewControls(), EndSelection(), FlipSelectionHorizontal(), FlipSelectionVertical(), HandleCanvasInput(), PasteSelection(), PixelToScreen(), SaveUndoState(), ScreenToPixel(), and UpdateSelection().
|
private |
Definition at line 202 of file pixel_editor_panel.h.
|
private |
Definition at line 203 of file pixel_editor_panel.h.
Referenced by DrawBrushPreview(), DrawCanvas(), DrawCursorCrosshair(), DrawTransparencyGrid(), PixelToScreen(), and ScreenToPixel().
|
private |
Definition at line 207 of file pixel_editor_panel.h.
Referenced by DrawCanvas(), and HandleCanvasInput().
|
private |
Definition at line 208 of file pixel_editor_panel.h.
Referenced by HandleCanvasInput().
|
private |
Definition at line 209 of file pixel_editor_panel.h.
Referenced by DrawCanvas(), HandleCanvasInput(), and UpdateSelection().
|
private |
Definition at line 212 of file pixel_editor_panel.h.
Referenced by DrawCanvas(), and HandleCanvasInput().
|
private |
Definition at line 213 of file pixel_editor_panel.h.
Referenced by DrawCanvas(), and HandleCanvasInput().
|
private |
Definition at line 216 of file pixel_editor_panel.h.
Referenced by DrawBrushPreview(), DrawCursorCrosshair(), DrawPixelInfoTooltip(), DrawStatusBar(), and HandleCanvasInput().
|
private |
Definition at line 217 of file pixel_editor_panel.h.
Referenced by DrawBrushPreview(), DrawCursorCrosshair(), DrawPixelInfoTooltip(), DrawStatusBar(), and HandleCanvasInput().
|
private |
Definition at line 218 of file pixel_editor_panel.h.
Referenced by DrawCanvas(), DrawStatusBar(), and HandleCanvasInput().