TermOx
event.hpp
1 #ifndef TERMOX_SYSTEM_EVENT_HPP
2 #define TERMOX_SYSTEM_EVENT_HPP
3 #include <functional>
4 #include <memory>
5 #include <optional>
6 #include <utility>
7 #include <variant>
8 #include <vector>
9 
10 #include <esc/event.hpp>
11 
12 #include <termox/painter/color.hpp>
13 #include <termox/system/key.hpp>
14 #include <termox/system/mouse.hpp>
15 #include <termox/widget/area.hpp>
16 #include <termox/widget/point.hpp>
17 #include <termox/widget/widget.hpp>
18 
19 namespace ox {
20 
21 using Widget_ref = std::reference_wrapper<Widget>;
22 
23 struct Paint_event {
24  Widget_ref receiver;
25 };
26 
28  std::optional<Widget_ref> receiver; // nullopt if no current focus Widget.
29  Key key;
30 };
31 
33  std::optional<Widget_ref> receiver; // nullopt if no current focus Widget.
34  Key key;
35 };
36 
38  Widget_ref receiver;
39  Mouse data;
40 };
41 
43  Widget_ref receiver;
44  Mouse data;
45 };
46 
48  Widget_ref receiver;
49  Mouse data;
50 };
51 
53  Widget_ref receiver;
54  Mouse data;
55 };
56 
58  Widget_ref receiver;
59  Widget_ref child;
60 };
61 
63  Widget_ref receiver;
64  Widget_ref child;
65 };
66 
68  Widget_ref receiver;
69  Widget_ref child;
70 };
71 
72 struct Delete_event {
73  std::unique_ptr<Widget> removed;
74 };
75 
76 struct Disable_event {
77  Widget_ref receiver;
78 };
79 
80 struct Enable_event {
81  Widget_ref receiver;
82 };
83 
85  Widget_ref receiver;
86 };
87 
89  Widget_ref receiver;
90 };
91 
92 struct Move_event {
93  Widget_ref receiver;
94  Point new_position;
95 };
96 
97 struct Resize_event {
98  Widget_ref receiver;
99  Area new_area;
100 };
101 
102 struct Timer_event {
103  Widget_ref receiver;
104 };
105 
107  using Processed_colors = std::vector<std::pair<ox::Color, ox::True_color>>;
108  Processed_colors color_data;
109 };
110 
115 struct Custom_event {
116  std::function<void()> send;
117  std::function<bool()> filter_send = [] { return false; };
118 };
119 
120 using Event = std::variant<Paint_event,
130  Delete_event,
132  Enable_event,
135  Move_event,
136  Resize_event,
137  Timer_event,
139  ::esc::Window_resize,
140  Custom_event>;
141 
142 } // namespace ox
143 #endif // TERMOX_SYSTEM_EVENT_HPP
Definition: event.hpp:57
Definition: event.hpp:67
Definition: event.hpp:62
Definition: event.hpp:115
Definition: event.hpp:72
Definition: event.hpp:76
Definition: event.hpp:106
Definition: event.hpp:80
Definition: event.hpp:84
Definition: event.hpp:88
Definition: event.hpp:27
Definition: event.hpp:32
Definition: event.hpp:52
Definition: event.hpp:37
Definition: event.hpp:42
Definition: event.hpp:47
Definition: event.hpp:92
Definition: event.hpp:23
Definition: event.hpp:97
Definition: event.hpp:102