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.hpp"
12#include "../enum_metadata.hpp"
13#include <string>
14#include <string_view>
15#include <ostream>
16
17namespace hi { inline namespace v1 {
18
22enum class gui_event_type {
23 none,
24
25 // raw-keyboard-events
26 keyboard_down,
27 keyboard_up,
28 keyboard_grapheme,
29 keyboard_partial_grapheme,
30 keyboard_enter,
31 keyboard_exit,
32
33 // raw-mouse-events
34 mouse_move,
35 mouse_drag,
36 mouse_down,
37 mouse_up,
38 mouse_wheel,
39 mouse_enter,
40 mouse_exit,
41 mouse_exit_window,
42
43 // commands
44 text_cursor_left_char,
45 text_cursor_right_char,
46 text_cursor_down_char,
47 text_cursor_up_char,
48 text_cursor_left_word,
49 text_cursor_right_word,
50 text_cursor_begin_line,
51 text_cursor_end_line,
52 text_cursor_begin_sentence,
53 text_cursor_end_sentence,
54 text_cursor_begin_document,
55 text_cursor_end_document,
56 text_select_left_char,
57 text_select_right_char,
58 text_select_down_char,
59 text_select_up_char,
60 text_select_word,
61 text_select_left_word,
62 text_select_right_word,
63 text_select_begin_line,
64 text_select_end_line,
65 text_select_begin_sentence,
66 text_select_end_sentence,
67 text_select_document,
68 text_select_begin_document,
69 text_select_end_document,
70 text_delete_char_prev,
71 text_delete_char_next,
72 text_delete_word_prev,
73 text_delete_word_next,
74 text_swap_chars,
75 text_edit_paste,
76 text_edit_copy,
77 text_edit_cut,
78 text_undo,
79 text_redo,
80 text_insert_line,
81 text_insert_line_up,
82 text_insert_line_down,
83 text_mode_insert,
84 gui_widget_next,
85 gui_widget_prev,
86 gui_menu_next,
87 gui_menu_prev,
88 gui_sysmenu_open,
89 gui_toolbar_open,
90 gui_toolbar_next,
91 gui_toolbar_prev,
92 gui_activate,
93 gui_activate_next,
94 gui_cancel,
95};
96
97// clang-format off
98constexpr auto gui_event_type_metadata = enum_metadata{
99 gui_event_type::none, "none",
100 gui_event_type::keyboard_down, "keyboard_down",
101 gui_event_type::keyboard_grapheme, "keyboard_grapheme",
102 gui_event_type::keyboard_partial_grapheme, "keyboard_partial_grapheme",
103 gui_event_type::keyboard_enter, "keyboard_enter",
104 gui_event_type::keyboard_exit, "keyboard_exit",
105 gui_event_type::mouse_move, "mouse_move",
106 gui_event_type::mouse_drag, "mouse_drag",
107 gui_event_type::mouse_down, "mouse_down",
108 gui_event_type::mouse_up, "mouse_up",
109 gui_event_type::mouse_wheel, "mouse_wheel",
110 gui_event_type::mouse_enter, "mouse_enter",
111 gui_event_type::mouse_exit, "mouse_exit",
112 gui_event_type::mouse_exit_window, "mouse_exit_window",
113 gui_event_type::text_cursor_left_char, "text_cursor_left_char",
114 gui_event_type::text_cursor_right_char, "text_cursor_right_char",
115 gui_event_type::text_cursor_down_char, "text_cursor_down_char",
116 gui_event_type::text_cursor_up_char, "text_cursor_up_char",
117 gui_event_type::text_cursor_left_word, "text_cursor_left_word",
118 gui_event_type::text_cursor_right_word, "text_cursor_right_word",
119 gui_event_type::text_cursor_begin_line, "text_cursor_begin_line",
120 gui_event_type::text_cursor_end_line, "text_cursor_end_line",
121 gui_event_type::text_cursor_begin_sentence, "text_cursor_begin_sentence",
122 gui_event_type::text_cursor_end_sentence, "text_cursor_end_sentence",
123 gui_event_type::text_cursor_begin_document, "text_cursor_begin_document",
124 gui_event_type::text_cursor_end_document, "text_cursor_end_document",
125 gui_event_type::text_select_left_char, "text_select_left_char",
126 gui_event_type::text_select_right_char, "text_select_right_char",
127 gui_event_type::text_select_down_char, "text_select_down_char",
128 gui_event_type::text_select_up_char, "text_select_up_char",
129 gui_event_type::text_select_word, "text_select_word",
130 gui_event_type::text_select_left_word, "text_select_left_word",
131 gui_event_type::text_select_right_word, "text_select_right_word",
132 gui_event_type::text_select_begin_line, "text_select_begin_line",
133 gui_event_type::text_select_end_line, "text_select_end_line",
134 gui_event_type::text_select_begin_sentence, "text_select_begin_sentence",
135 gui_event_type::text_select_end_sentence, "text_select_end_sentence",
136 gui_event_type::text_select_begin_document, "text_select_begin_document",
137 gui_event_type::text_select_end_document, "text_select_end_document",
138 gui_event_type::text_select_document, "text_select_document",
139 gui_event_type::text_delete_char_prev, "text_delete_char_prev",
140 gui_event_type::text_delete_char_next, "text_delete_char_next",
141 gui_event_type::text_delete_word_prev, "text_delete_word_prev",
142 gui_event_type::text_delete_word_next, "text_delete_word_next",
143 gui_event_type::text_insert_line, "text_insert_line",
144 gui_event_type::text_insert_line_up, "text_insert_line_up",
145 gui_event_type::text_insert_line_down, "text_insert_line_down",
146 gui_event_type::text_swap_chars, "text_swap_chars",
147 gui_event_type::text_edit_paste, "text_edit_paste",
148 gui_event_type::text_edit_copy, "text_edit_copy",
149 gui_event_type::text_edit_cut, "text_edit_cut",
150 gui_event_type::text_undo, "text_undo",
151 gui_event_type::text_redo, "text_redo",
152 gui_event_type::text_mode_insert, "text_mode_insert",
153 gui_event_type::gui_widget_next, "gui_widget_next",
154 gui_event_type::gui_widget_prev, "gui_widget_prev",
155 gui_event_type::gui_menu_next, "gui_menu_next",
156 gui_event_type::gui_menu_prev, "gui_menu_prev",
157 gui_event_type::gui_sysmenu_open, "gui_sysmenu_open",
158 gui_event_type::gui_toolbar_open, "gui_toolbar_open",
159 gui_event_type::gui_toolbar_next, "gui_toolbar_next",
160 gui_event_type::gui_toolbar_prev, "gui_toolbar_prev",
161 gui_event_type::gui_activate, "gui_activate",
162 gui_event_type::gui_activate_next, "gui_activate_next",
163 gui_event_type::gui_cancel, "gui_cancel"
164};
165// clang-format on
166
169inline std::string_view to_string(gui_event_type rhs) noexcept
170{
171 return gui_event_type_metadata[rhs];
172}
173
176constexpr gui_event_type to_gui_event_type(std::string_view name) noexcept
177{
178 return gui_event_type_metadata.at(name, gui_event_type::none);
179}
180
181}} // namespace hi::inline v1
182
Utilities used by the HikoGUI library itself.
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:22
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
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:176