yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
pixel_editor_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_PIXEL_EDITOR_PANEL_H
2#define YAZE_APP_EDITOR_GRAPHICS_PIXEL_EDITOR_PANEL_H
3
4#include "absl/status/status.h"
10#include "rom/rom.h"
11
12namespace yaze {
13namespace editor {
14
22 public:
24 : state_(state), rom_(rom) {}
25
26 // ==========================================================================
27 // EditorPanel Identity
28 // ==========================================================================
29
30 std::string GetId() const override { return "graphics.pixel_editor"; }
31 std::string GetDisplayName() const override { return "Pixel Editor"; }
32 std::string GetIcon() const override { return ICON_MD_BRUSH; }
33 std::string GetEditorCategory() const override { return "Graphics"; }
34 int GetPriority() const override { return 20; }
35
36 // ==========================================================================
37 // EditorPanel Lifecycle
38 // ==========================================================================
39
43 void Initialize();
44
48 void Draw(bool* p_open) override;
49
54 absl::Status Update();
55
56 private:
60 void DrawToolbar();
61
65 void DrawViewControls();
66
70 void DrawCanvas();
71
75 void DrawColorPicker();
76
80 void DrawStatusBar();
81
85 void DrawMiniMap();
86
90 void HandleCanvasInput();
91
95 void ApplyPencil(int x, int y);
96
100 void ApplyBrush(int x, int y);
101
105 void ApplyEraser(int x, int y);
106
110 void ApplyFill(int x, int y);
111
115 void ApplyEyedropper(int x, int y);
116
120 void DrawLine(int x1, int y1, int x2, int y2);
121
125 void DrawRectangle(int x1, int y1, int x2, int y2, bool filled);
126
130 void BeginSelection(int x, int y);
131
135 void UpdateSelection(int x, int y);
136
140 void EndSelection();
141
145 void CopySelection();
146
150 void PasteSelection(int x, int y);
151
156
161
165 void SaveUndoState();
166
170 ImVec2 ScreenToPixel(ImVec2 screen_pos);
171
175 ImVec2 PixelToScreen(int x, int y);
176
177 // ==========================================================================
178 // Overlay Drawing
179 // ==========================================================================
180
184 void DrawTransparencyGrid(float canvas_width, float canvas_height);
185
189 void DrawCursorCrosshair();
190
194 void DrawBrushPreview();
195
199 void DrawPixelInfoTooltip(const gfx::Bitmap& sheet);
200
203 gui::Canvas canvas_{"PixelEditorCanvas", ImVec2(128, 32),
205
206 // Mouse tracking for tools
207 bool is_drawing_ = false;
208 ImVec2 last_mouse_pixel_ = {-1, -1};
209 ImVec2 tool_start_pixel_ = {-1, -1};
210
211 // Line/rectangle preview
212 bool show_tool_preview_ = false;
213 ImVec2 preview_end_ = {0, 0};
214
215 // Current cursor position in pixel coords
216 int cursor_x_ = 0;
217 int cursor_y_ = 0;
218 bool cursor_in_canvas_ = false;
219};
220
221} // namespace editor
222} // namespace yaze
223
224#endif // YAZE_APP_EDITOR_GRAPHICS_PIXEL_EDITOR_PANEL_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
Base interface for all logical panel components.
Shared state between GraphicsEditor panel components.
Main pixel editing panel for graphics sheets.
std::string GetId() const override
Unique identifier for this panel.
void EndSelection()
Finalize the selection.
void DrawLine(int x1, int y1, int x2, int y2)
Draw line from start to end.
void DrawColorPicker()
Draw the color palette picker.
void ApplyEraser(int x, int y)
Apply eraser tool at position.
void DrawPixelInfoTooltip(const gfx::Bitmap &sheet)
Draw tooltip with pixel information.
void DrawCursorCrosshair()
Draw crosshair at cursor position.
PixelEditorPanel(GraphicsEditorState *state, Rom *rom)
void DrawMiniMap()
Draw the mini navigation map.
void Draw(bool *p_open) override
Draw the pixel editor UI (EditorPanel interface)
std::string GetEditorCategory() const override
Editor category this panel belongs to.
void HandleCanvasInput()
Handle canvas mouse input for current tool.
ImVec2 ScreenToPixel(ImVec2 screen_pos)
Convert screen coordinates to pixel coordinates.
void DrawBrushPreview()
Draw brush size preview circle.
void ApplyEyedropper(int x, int y)
Apply eyedropper tool at position.
void CopySelection()
Copy selection to clipboard.
void UpdateSelection(int x, int y)
Update selection during drag.
void FlipSelectionVertical()
Flip selection vertically.
void ApplyBrush(int x, int y)
Apply brush tool at position.
void Initialize()
Initialize the panel.
void FlipSelectionHorizontal()
Flip selection horizontally.
void DrawViewControls()
Draw zoom and view controls.
void ApplyPencil(int x, int y)
Apply pencil tool at position.
std::string GetIcon() const override
Material Design icon for this panel.
void DrawToolbar()
Draw the toolbar with tool selection.
absl::Status Update()
Legacy Update method for backward compatibility.
ImVec2 PixelToScreen(int x, int y)
Convert pixel coordinates to screen coordinates.
void BeginSelection(int x, int y)
Start a new selection.
void DrawStatusBar()
Draw the status bar with cursor position.
void DrawTransparencyGrid(float canvas_width, float canvas_height)
Draw checkerboard pattern for transparent pixels.
void ApplyFill(int x, int y)
Apply flood fill starting at position.
void PasteSelection(int x, int y)
Paste clipboard at position.
int GetPriority() const override
Get display priority for menu ordering.
void DrawRectangle(int x1, int y1, int x2, int y2, bool filled)
Draw rectangle from start to end.
void DrawCanvas()
Draw the main editing canvas.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
void SaveUndoState()
Save current state for undo.
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:67
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
#define ICON_MD_BRUSH
Definition icons.h:325