HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
gui_event_type.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
9#pragma once
10
11#include "../utility/module.hpp"
12#include <string>
13#include <string_view>
14#include <ostream>
15
16namespace hi { inline namespace v1 {
17
21enum class gui_event_type {
22 none,
23
24 // raw-keyboard-events
25 keyboard_down,
26 keyboard_up,
27 keyboard_grapheme,
28 keyboard_partial_grapheme,
29 keyboard_enter,
30 keyboard_exit,
31
32 // raw-mouse-events
33 mouse_move,
34 mouse_drag,
35 mouse_down,
36 mouse_up,
37 mouse_wheel,
38 mouse_enter,
39 mouse_exit,
40 mouse_exit_window,
41
42 // window-events
54
55 // commands
56 text_cursor_left_char,
57 text_cursor_right_char,
58 text_cursor_down_char,
59 text_cursor_up_char,
60 text_cursor_left_word,
61 text_cursor_right_word,
62 text_cursor_begin_line,
63 text_cursor_end_line,
64 text_cursor_begin_sentence,
65 text_cursor_end_sentence,
66 text_cursor_begin_document,
67 text_cursor_end_document,
68 text_select_left_char,
69 text_select_right_char,
70 text_select_down_char,
71 text_select_up_char,
72 text_select_word,
73 text_select_left_word,
74 text_select_right_word,
75 text_select_begin_line,
76 text_select_end_line,
77 text_select_begin_sentence,
78 text_select_end_sentence,
79 text_select_document,
80 text_select_begin_document,
81 text_select_end_document,
82 text_delete_char_prev,
83 text_delete_char_next,
84 text_delete_word_prev,
85 text_delete_word_next,
86 text_swap_chars,
87 text_edit_paste,
88 text_edit_copy,
89 text_edit_cut,
90 text_undo,
91 text_redo,
92 text_insert_line,
93 text_insert_line_up,
94 text_insert_line_down,
95 text_mode_insert,
96
97 // GUI navigation.
98 gui_widget_next,
99 gui_widget_prev,
100 gui_menu_next,
101 gui_menu_prev,
102 gui_toolbar_open,
103 gui_toolbar_next,
104 gui_toolbar_prev,
105 gui_activate,
106 gui_activate_next,
107 gui_cancel,
108};
109
110// clang-format off
111constexpr auto gui_event_type_metadata = enum_metadata{
112 gui_event_type::none, "none",
113 gui_event_type::keyboard_down, "keyboard_down",
114 gui_event_type::keyboard_grapheme, "keyboard_grapheme",
115 gui_event_type::keyboard_partial_grapheme, "keyboard_partial_grapheme",
116 gui_event_type::keyboard_enter, "keyboard_enter",
117 gui_event_type::keyboard_exit, "keyboard_exit",
118 gui_event_type::mouse_move, "mouse_move",
119 gui_event_type::mouse_drag, "mouse_drag",
120 gui_event_type::mouse_down, "mouse_down",
121 gui_event_type::mouse_up, "mouse_up",
122 gui_event_type::mouse_wheel, "mouse_wheel",
123 gui_event_type::mouse_enter, "mouse_enter",
124 gui_event_type::mouse_exit, "mouse_exit",
125 gui_event_type::mouse_exit_window, "mouse_exit_window",
126 gui_event_type::window_redraw, "window_redraw",
127 gui_event_type::window_relayout, "window_relayout",
128 gui_event_type::window_reconstrain, "window_reconstrain",
129 gui_event_type::window_resize, "window_resize",
130 gui_event_type::window_minimize, "window_minimize",
131 gui_event_type::window_maximize, "window_maximize",
132 gui_event_type::window_normalize, "window_normalize",
133 gui_event_type::window_open_sysmenu, "window_open_sysmenu",
134 gui_event_type::window_close, "window_close",
135 gui_event_type::window_set_keyboard_target, "window_set_keyboard_target",
136 gui_event_type::window_set_clipboard, "window_set_clipboard",
137 gui_event_type::text_cursor_left_char, "text_cursor_left_char",
138 gui_event_type::text_cursor_right_char, "text_cursor_right_char",
139 gui_event_type::text_cursor_down_char, "text_cursor_down_char",
140 gui_event_type::text_cursor_up_char, "text_cursor_up_char",
141 gui_event_type::text_cursor_left_word, "text_cursor_left_word",
142 gui_event_type::text_cursor_right_word, "text_cursor_right_word",
143 gui_event_type::text_cursor_begin_line, "text_cursor_begin_line",
144 gui_event_type::text_cursor_end_line, "text_cursor_end_line",
145 gui_event_type::text_cursor_begin_sentence, "text_cursor_begin_sentence",
146 gui_event_type::text_cursor_end_sentence, "text_cursor_end_sentence",
147 gui_event_type::text_cursor_begin_document, "text_cursor_begin_document",
148 gui_event_type::text_cursor_end_document, "text_cursor_end_document",
149 gui_event_type::text_select_left_char, "text_select_left_char",
150 gui_event_type::text_select_right_char, "text_select_right_char",
151 gui_event_type::text_select_down_char, "text_select_down_char",
152 gui_event_type::text_select_up_char, "text_select_up_char",
153 gui_event_type::text_select_word, "text_select_word",
154 gui_event_type::text_select_left_word, "text_select_left_word",
155 gui_event_type::text_select_right_word, "text_select_right_word",
156 gui_event_type::text_select_begin_line, "text_select_begin_line",
157 gui_event_type::text_select_end_line, "text_select_end_line",
158 gui_event_type::text_select_begin_sentence, "text_select_begin_sentence",
159 gui_event_type::text_select_end_sentence, "text_select_end_sentence",
160 gui_event_type::text_select_begin_document, "text_select_begin_document",
161 gui_event_type::text_select_end_document, "text_select_end_document",
162 gui_event_type::text_select_document, "text_select_document",
163 gui_event_type::text_delete_char_prev, "text_delete_char_prev",
164 gui_event_type::text_delete_char_next, "text_delete_char_next",
165 gui_event_type::text_delete_word_prev, "text_delete_word_prev",
166 gui_event_type::text_delete_word_next, "text_delete_word_next",
167 gui_event_type::text_insert_line, "text_insert_line",
168 gui_event_type::text_insert_line_up, "text_insert_line_up",
169 gui_event_type::text_insert_line_down, "text_insert_line_down",
170 gui_event_type::text_swap_chars, "text_swap_chars",
171 gui_event_type::text_edit_paste, "text_edit_paste",
172 gui_event_type::text_edit_copy, "text_edit_copy",
173 gui_event_type::text_edit_cut, "text_edit_cut",
174 gui_event_type::text_undo, "text_undo",
175 gui_event_type::text_redo, "text_redo",
176 gui_event_type::text_mode_insert, "text_mode_insert",
177 gui_event_type::gui_widget_next, "gui_widget_next",
178 gui_event_type::gui_widget_prev, "gui_widget_prev",
179 gui_event_type::gui_menu_next, "gui_menu_next",
180 gui_event_type::gui_menu_prev, "gui_menu_prev",
181 gui_event_type::gui_toolbar_open, "gui_toolbar_open",
182 gui_event_type::gui_toolbar_next, "gui_toolbar_next",
183 gui_event_type::gui_toolbar_prev, "gui_toolbar_prev",
184 gui_event_type::gui_activate, "gui_activate",
185 gui_event_type::gui_activate_next, "gui_activate_next",
186 gui_event_type::gui_cancel, "gui_cancel"
187};
188// clang-format on
189
192inline std::string_view to_string(gui_event_type rhs) noexcept
193{
194 return gui_event_type_metadata[rhs];
195}
196
199constexpr gui_event_type to_gui_event_type(std::string_view name) noexcept
200{
201 return gui_event_type_metadata.at(name, gui_event_type::none);
202}
203
204}} // namespace hi::inline v1
205
constexpr std::string to_string(std::u32string_view rhs) noexcept
Conversion from UTF-32 to UTF-8.
Definition to_string.hpp:215
gui_event_type
GUI event type.
Definition gui_event_type.hpp:21
@ window_redraw
Request that part of the window gets redrawn on the next frame.
@ window_normalize
Request the window to be restored to the original size after a minimize and maximize commands.
@ window_open_sysmenu
Open the operating system provided menu for the window.
@ window_minimize
Request the window to minimize.
@ window_close
Request the window to be closed.
@ window_set_keyboard_target
Change the keyboard target widget for this window.
@ window_maximize
Request the window to maximize.
@ window_relayout
Request that widgets get laid out on the next frame.
@ window_reconstrain
Request that widget get constraint on the next frame.
@ window_set_clipboard
Place data on the clipboard.
@ window_resize
Request that the window resizes to desired constraints on the next frame.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
constexpr gui_event_type to_gui_event_type(std::string_view name) noexcept
Convert a name to a GUI event type.
Definition gui_event_type.hpp:199