yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
canvas_events.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_CANVAS_CANVAS_EVENTS_H
2#define YAZE_APP_GUI_CANVAS_CANVAS_EVENTS_H
3
4#include <vector>
5#include "imgui/imgui.h"
6
7namespace yaze {
8namespace gui {
9
17 ImVec2 position;
19 int tile_id = -1;
20 bool is_drag = false;
21 bool is_complete = false;
22
23 void Reset() {
24 position = ImVec2(-1, -1);
25 grid_position = ImVec2(-1, -1);
26 tile_id = -1;
27 is_drag = false;
28 is_complete = false;
29 }
30};
31
39 std::vector<ImVec2> selected_tiles;
40 ImVec2 start_pos;
41 ImVec2 end_pos;
42 int current_map = -1;
43 bool is_complete = false;
44 bool is_active = false;
45
46 void Reset() {
47 selected_tiles.clear();
48 start_pos = ImVec2(-1, -1);
49 end_pos = ImVec2(-1, -1);
50 current_map = -1;
51 is_complete = false;
52 is_active = false;
53 }
54
56 size_t Count() const { return selected_tiles.size(); }
57
59 bool IsEmpty() const { return selected_tiles.empty(); }
60};
61
69 int tile_id = -1;
70 bool is_valid = false;
71
72 void Reset() {
73 tile_position = ImVec2(-1, -1);
74 tile_id = -1;
75 is_valid = false;
76 }
77};
78
86 enum class Type {
87 kNone,
88 kHover,
89 kClick,
92 kDragMove,
94 };
95
97 int entity_id = -1;
98 ImVec2 position;
99 ImVec2 delta;
101 bool is_valid = false;
102
103 void Reset() {
105 entity_id = -1;
106 position = ImVec2(-1, -1);
107 delta = ImVec2(0, 0);
108 grid_position = ImVec2(-1, -1);
109 is_valid = false;
110 }
111
113 bool IsDragEvent() const {
114 return type == Type::kDragStart || type == Type::kDragMove ||
116 }
117
119 bool IsClickEvent() const {
121 }
122};
123
130 ImVec2 position;
132 bool is_valid = false;
133
134 void Reset() {
135 position = ImVec2(-1, -1);
136 grid_position = ImVec2(-1, -1);
137 is_valid = false;
138 }
139};
140
172
173} // namespace gui
174} // namespace yaze
175
176#endif // YAZE_APP_GUI_CANVAS_CANVAS_EVENTS_H
177
Main namespace for the application.
Definition controller.cc:20
Combined interaction result for a frame.
bool HasAnyEvent() const
Check if any event occurred.
EntityInteractionEvent entity_interaction
void Reset()
Reset all events.
Event payload for entity interactions.
int entity_id
Entity being interacted with.
bool IsDragEvent() const
Check if this is a drag event.
bool is_valid
True if event is valid.
@ kDoubleClick
Double click on entity.
@ kDragEnd
Finished dragging entity.
@ kHover
Mouse hovering over entity.
@ kDragStart
Started dragging entity.
@ kDragMove
Dragging entity (continuous)
ImVec2 position
Current entity position (canvas coords)
bool IsClickEvent() const
Check if this is a click event.
Type type
Type of interaction.
ImVec2 grid_position
Grid-aligned position.
ImVec2 delta
Movement delta (for drag events)
Event payload for hover preview.
bool is_valid
True if hovering over canvas.
ImVec2 position
Canvas-space hover position.
ImVec2 grid_position
Grid-aligned hover position.
Event payload for rectangle selection operations.
bool IsEmpty() const
Check if selection is empty.
bool is_complete
True when selection finishes.
int current_map
Map ID for coordinate calculation.
ImVec2 start_pos
Rectangle start (canvas coords)
std::vector< ImVec2 > selected_tiles
Individual tile positions (grid coords)
ImVec2 end_pos
Rectangle end (canvas coords)
size_t Count() const
Get number of selected tiles.
bool is_active
True while dragging.
Event payload for tile painting operations.
int tile_id
Tile ID being painted (-1 if none)
ImVec2 position
Canvas-space pixel coordinates.
bool is_complete
True when paint action finishes.
ImVec2 grid_position
Grid-aligned tile position.
bool is_drag
True for continuous drag painting.
Event payload for single tile selection.
int tile_id
Selected tile ID.
bool is_valid
True if selection is valid.
ImVec2 tile_position
Selected tile position (grid coords)