yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
canvas_types.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_CANVAS_CANVAS_TYPES_H
2#define YAZE_APP_GUI_CANVAS_CANVAS_TYPES_H
3
4// POD and option structs for the canvas subsystem.
5
6#include <cstdint>
7#include <optional>
8
9#include "imgui/imgui.h"
10
11namespace yaze {
12namespace gui {
13
14enum class CanvasType { kTile, kBlock, kMap };
15enum class CanvasMode { kPaint, kSelect };
17
18// Describes the role this canvas plays: what it's for, distinct from
19// CanvasMode which describes the input behavior the user is currently
20// performing. A canvas can have CanvasMode::kSelect while being either a
21// kSelectionSource (picker) or a kEditableScratchpad (rect-select-then-edit).
22//
23// Editors set this once at Init/Begin time. Canvas reads it for cursor and
24// hover-hint defaults; it does not gate operations.
25enum class CanvasRole : uint8_t {
26 kPreviewOnly, // Read-only display (gfx-group sheet thumbnail).
27 kSelectionSource, // Read-only tile/region picker source.
28 kEditableScratchpad, // User-editable target (default).
29 kCompositeOutput, // Post-render composite output.
30};
31
32// True when the canvas's underlying bitmap is owned by the editor and may be
33// mutated through it. False for kPreviewOnly/kSelectionSource canvases whose
34// bitmap is a shared view (gfx-group sheets, sprite atlas thumbnails) where
35// destructive operations like Reformat/SetPalette would corrupt every other
36// view of the same data. The context menu uses this to suppress
37// "Pixel Format" and "Edit Palette" entries on read-only canvases.
39 return role == CanvasRole::kEditableScratchpad ||
41}
42
44 ImDrawList* draw_list = nullptr;
45 ImVec2 canvas_p0 = ImVec2(0, 0);
46 ImVec2 canvas_sz = ImVec2(0, 0);
47 ImVec2 scrolling = ImVec2(0, 0);
48 ImVec2 mouse_pos_local = ImVec2(0, 0);
49 bool hovered = false;
50 float grid_step = 16.0f;
51 float scale = 1.0f;
52 ImVec2 content_size = ImVec2(0, 0);
53};
54
56 ImVec2 canvas_size = ImVec2(0, 0);
57 bool draw_context_menu = true;
58 bool draw_grid = true;
59 std::optional<float> grid_step;
60 bool draw_overlay = true;
61 bool render_popups = true;
62 bool use_child_window = false;
63 bool show_scrollbar = false;
64};
65
67 ImVec2 canvas_size = ImVec2(0, 0);
68 ImVec2 dest_pos = ImVec2(0, 0);
69 ImVec2 dest_size = ImVec2(0, 0);
70 ImVec2 src_pos = ImVec2(0, 0);
71 ImVec2 src_size = ImVec2(0, 0);
72 float scale = 1.0f;
73 int alpha = 255;
74 bool draw_context_menu = false;
75 bool draw_grid = true;
76 std::optional<float> grid_step;
77 bool draw_overlay = true;
78 bool render_popups = true;
79 bool ensure_texture = false;
82};
83
84struct TileHit {
85 int tile_index = -1;
86 ImVec2 tile_origin = ImVec2(0, 0);
87 ImVec2 tile_size = ImVec2(0, 0);
88};
89
91 ImVec2 dest_pos = ImVec2(0, 0);
92 ImVec2 dest_size = ImVec2(0, 0);
93 ImVec2 src_pos = ImVec2(0, 0);
94 ImVec2 src_size = ImVec2(0, 0);
95 float scale = 1.0f;
96 int alpha = 255;
97 bool ensure_texture = true;
98};
99
101 ImVec2 canvas_size = ImVec2(0, 0);
102 float grid_step = 16.0f;
103 bool show_grid = true;
104 bool show_overlay = true;
105 bool render_popups = true;
106 bool ensure_texture = true;
109};
110
112 ImVec2 canvas_size = ImVec2(0, 0);
113 ImVec2 dest_pos = ImVec2(0, 0);
114 ImVec2 dest_size = ImVec2(0, 0);
115 float grid_step = 0.0f;
116 bool render_popups = false;
117 bool ensure_texture = true;
118};
119
121 float scale = 1.0f;
122 ImVec2 scroll = ImVec2(0, 0);
123};
124
125} // namespace gui
126} // namespace yaze
127
128#endif // YAZE_APP_GUI_CANVAS_CANVAS_TYPES_H
constexpr bool RoleAllowsBitmapMutation(CanvasRole role)
std::optional< float > grid_step
std::optional< float > grid_step