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
6#include "imgui/imgui.h"
7
8namespace yaze {
9namespace gui {
10
18 ImVec2 position;
20 int tile_id = -1;
21 bool is_drag = false;
22 bool is_complete = false;
23
24 void Reset() {
25 position = ImVec2(-1, -1);
26 grid_position = ImVec2(-1, -1);
27 tile_id = -1;
28 is_drag = false;
29 is_complete = false;
30 }
31};
32
41 std::vector<ImVec2>
43 ImVec2 start_pos;
44 ImVec2 end_pos;
45 int current_map = -1;
46 bool is_complete = false;
47 bool is_active = false;
48
49 void Reset() {
50 selected_tiles.clear();
51 start_pos = ImVec2(-1, -1);
52 end_pos = ImVec2(-1, -1);
53 current_map = -1;
54 is_complete = false;
55 is_active = false;
56 }
57
59 size_t Count() const { return selected_tiles.size(); }
60
62 bool IsEmpty() const { return selected_tiles.empty(); }
63};
64
72 int tile_id = -1;
73 bool is_valid = false;
74
75 void Reset() {
76 tile_position = ImVec2(-1, -1);
77 tile_id = -1;
78 is_valid = false;
79 }
80};
81
89 enum class Type {
90 kNone,
91 kHover,
92 kClick,
95 kDragMove,
97 };
98
100 int entity_id = -1;
101 ImVec2 position;
102 ImVec2 delta;
104 bool is_valid = false;
105
106 void Reset() {
108 entity_id = -1;
109 position = ImVec2(-1, -1);
110 delta = ImVec2(0, 0);
111 grid_position = ImVec2(-1, -1);
112 is_valid = false;
113 }
114
116 bool IsDragEvent() const {
117 return type == Type::kDragStart || type == Type::kDragMove ||
119 }
120
122 bool IsClickEvent() const {
124 }
125};
126
133 ImVec2 position;
135 bool is_valid = false;
136
137 void Reset() {
138 position = ImVec2(-1, -1);
139 grid_position = ImVec2(-1, -1);
140 is_valid = false;
141 }
142};
143
173
174} // namespace gui
175} // namespace yaze
176
177#endif // YAZE_APP_GUI_CANVAS_CANVAS_EVENTS_H
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)