1 module rpui.events;
2 
3 import rpui.math;
4 import rpui.input;
5 import rpui.primitives;
6 
7 struct ProgressEvent {
8     float deltaTime;
9 }
10 
11 struct CreateEvent {
12 }
13 
14 struct KeyPressedEvent {
15     KeyCode key;
16 }
17 
18 struct KeyReleasedEvent {
19     KeyCode key;
20 }
21 
22 struct TextEnteredEvent {
23     utf32string key;
24 }
25 
26 struct ChangeEvent {
27 }
28 
29 struct MouseDownEvent {
30     uint x;
31     uint y;
32     MouseButton button;
33 }
34 
35 struct MouseUpEvent {
36     uint x;
37     uint y;
38     MouseButton button;
39 }
40 
41 struct DblClickEvent {
42     uint x;
43     uint y;
44     MouseButton button;
45 }
46 
47 struct TripleClickEvent {
48     uint x;
49     uint y;
50     MouseButton button;
51 }
52 
53 struct MouseMoveEvent {
54     int x;
55     int y;
56     MouseButton button;
57 }
58 
59 struct MouseWheelEvent {
60     int dx;
61     int dy;
62 }
63 
64 struct WindowResizeEvent {
65     uint width;
66     uint height;
67     uint originalWidth;
68     uint originalHeight;
69 }
70 
71 struct WindowExposedEvent {
72 }
73 
74 struct CopyCommand {
75 }
76 
77 struct PasteCommand {
78 }
79 
80 struct CutCommand {
81 }
82 
83 struct UnselectCommand {
84 }
85 
86 struct SelectAllCommand {
87 }
88 
89 const windowEvents = [
90     typeid(KeyPressedEvent),
91     typeid(KeyReleasedEvent),
92     typeid(TextEnteredEvent),
93     typeid(MouseDownEvent),
94     typeid(MouseUpEvent),
95     typeid(DblClickEvent),
96     typeid(TripleClickEvent),
97     typeid(MouseMoveEvent),
98     typeid(MouseWheelEvent),
99     typeid(WindowResizeEvent),
100     typeid(WindowExposedEvent),
101 ];
102 
103 const commands = [
104     typeid(CopyCommand),
105     typeid(CutCommand),
106     typeid(PasteCommand),
107     typeid(UnselectCommand),
108     typeid(SelectAllCommand),
109 ];
110 
111 interface EventsListener {
112     void onKeyPressed(in KeyPressedEvent event);
113     void onKeyReleased(in KeyReleasedEvent event);
114     void onTextEntered(in TextEnteredEvent event);
115     void onMouseDown(in MouseDownEvent event);
116     void onMouseUp(in MouseUpEvent event);
117     void onDblClick(in DblClickEvent event);
118     void onTripleClick(in TripleClickEvent event);
119     void onMouseMove(in MouseMoveEvent event);
120     void onMouseWheel(in MouseWheelEvent event);
121     void onWindowResize(in WindowResizeEvent event);
122     void onWindowExposed(in WindowExposedEvent event);
123 }
124 
125 abstract class EventsListenerEmpty : EventsListener {
126     void onKeyPressed(in KeyPressedEvent event) {}
127     void onKeyReleased(in KeyReleasedEvent event) {}
128     void onTextEntered(in TextEnteredEvent event) {}
129     void onMouseDown(in MouseDownEvent event) {}
130     void onMouseUp(in MouseUpEvent event) {}
131     void onDblClick(in DblClickEvent event) {}
132     void onTripleClick(in TripleClickEvent event) {}
133     void onMouseMove(in MouseMoveEvent event) {}
134     void onMouseWheel(in MouseWheelEvent event) {}
135     void onWindowResize(in WindowResizeEvent event) {}
136     void onWindowExposed(in WindowExposedEvent event) {}
137 }