13#include "keyboard_virtual_key.hpp"
14#include "keyboard_state.hpp"
15#include "keyboard_modifiers.hpp"
16#include "mouse_buttons.hpp"
17#include "../unicode/grapheme.hpp"
18#include "../geometry/vector.hpp"
19#include "../geometry/point.hpp"
20#include "../geometry/transform.hpp"
21#include "../chrono.hpp"
24namespace hi {
inline namespace v1 {
111 gui_event(
type, std::chrono::utc_clock::now(), keyboard_modifiers::none, keyboard_state::idle)
121 gui_event(
type, std::chrono::utc_clock::now(), keyboard_modifiers::none, keyboard_state::idle)
136 keyboard_virtual_key
key,
138 hi::keyboard_state
keyboard_state = keyboard_state::idle) noexcept :
156 auto r =
gui_event{gui_event_type::mouse_enter};
175 hilet previous_variant = variant();
178 if (previous_variant != variant()) {
184 _grapheme = hi::grapheme{};
218 [[nodiscard]] keyboard_virtual_key&
key() noexcept
228 [[nodiscard]] keyboard_virtual_key
const&
key() const noexcept
248 [[nodiscard]] hi::grapheme
const&
grapheme() const noexcept
254 [[nodiscard]]
constexpr bool operator==(
gui_event_type event_type)
const noexcept
256 return type() == event_type;
259 [[nodiscard]]
constexpr bool operator==(
gui_event_variant event_variant)
const noexcept
261 return variant() == event_variant;
264 [[nodiscard]]
constexpr bool empty() const noexcept
266 return type() == gui_event_type::none;
269 constexpr operator bool() const noexcept
284 return type() == mouse_up and
mouse().
cause.left_button and active_area.contains(
mouse().position);
307 r.
mouse().
position = point2{transform * rhs.mouse().position};
308 r.mouse().down_position = point2{transform * rhs.mouse().down_position};
309 r.mouse().wheel_delta = vector2{transform * rhs.mouse().wheel_delta};
319 keyboard_virtual_key _key;
320 hi::grapheme _grapheme;
326template<
typename CharT>
327struct std::formatter<
hi::gui_event, CharT> : std::formatter<std::string_view, CharT> {
330 return std::formatter<std::string_view, CharT>::format(hi::gui_event_type_metadata[t.
type()], fc);
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
Definition of a GUI event variant.
Definition of GUI event type.
gui_event_type
GUI event type.
Definition gui_event_type.hpp:22
constexpr gui_event_variant to_gui_event_variant(gui_event_type type) noexcept
Convert a gui event type, to an gui event variant.
Definition gui_event_variant.hpp:39
gui_event_variant
A granular gui event type.
Definition gui_event_variant.hpp:18
@ keyboard
The gui_event has keyboard data.
@ mouse
The gui_event has mouse data.
@ grapheme
The gui_event has grapheme data.
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
Information for a mouse event.
Definition gui_event.hpp:29
point2 position
The current position of the mouse pointer.
Definition gui_event.hpp:34
uint8_t click_count
Number of clicks from the last button clicked.
Definition gui_event.hpp:60
vector2 wheel_delta
Change in wheel rotation, in points (pt).
Definition gui_event.hpp:48
mouse_buttons down
Buttons that are also held down.
Definition gui_event.hpp:56
mouse_buttons cause
Buttons which have caused this event.
Definition gui_event.hpp:52
point2 down_position
The position the last time a button was pressed.
Definition gui_event.hpp:42
A user interface event.
Definition gui_event.hpp:66
utc_nanoseconds time_point
The time when the event was created.
Definition gui_event.hpp:70
gui_event(gui_event_type type, hi::grapheme grapheme) noexcept
Create an grapheme GUI event.
Definition gui_event.hpp:120
constexpr vector2 drag_delta() const noexcept
Get the location of the mouse relative to the start of a drag.
Definition gui_event.hpp:289
mouse_event_data const & mouse() const noexcept
Get the mouse event information.
Definition gui_event.hpp:208
constexpr void set_type(gui_event_type type) noexcept
Change the type of the gui_event.
Definition gui_event.hpp:173
constexpr gui_event() noexcept
Create an empty GUI event.
Definition gui_event.hpp:101
hi::grapheme & grapheme() noexcept
Get the grapheme entered on the keyboard.
Definition gui_event.hpp:238
keyboard_modifiers keyboard_modifiers
Keyboard modifiers: shift, ctrl, alt, etc.
Definition gui_event.hpp:76
static gui_event make_mouse_enter(point2 position) noexcept
Create a mouse enter event.
Definition gui_event.hpp:154
keyboard_state keyboard_state
State of the keyboard; caps-lock, num-lock, scroll-lock.
Definition gui_event.hpp:80
hi::grapheme const & grapheme() const noexcept
Get the grapheme entered on the keyboard.
Definition gui_event.hpp:248
constexpr bool is_left_button_up(aarectangle active_area) const noexcept
Check if this event is for a left-button-up event while the mouse pointer is in the given area.
Definition gui_event.hpp:281
constexpr gui_event_type type() const noexcept
Get the event type.
Definition gui_event.hpp:163
keyboard_virtual_key const & key() const noexcept
Get the key from the keyboard event.
Definition gui_event.hpp:228
mouse_event_data & mouse() noexcept
Get the mouse event information.
Definition gui_event.hpp:198
constexpr friend gui_event operator*(geo::transformer auto const &transform, gui_event const &rhs) noexcept
Transform a gui-event to another coordinate system.
Definition gui_event.hpp:303
gui_event(gui_event_type type, keyboard_virtual_key key, hi::keyboard_modifiers keyboard_modifiers=keyboard_modifiers::none, hi::keyboard_state keyboard_state=keyboard_state::idle) noexcept
Create a GUI event.
Definition gui_event.hpp:134
constexpr gui_event(gui_event_type type, utc_nanoseconds time_point, hi::keyboard_modifiers keyboard_modifiers, hi::keyboard_state keyboard_state) noexcept
Create a GUI event.
Definition gui_event.hpp:89
gui_event(gui_event_type type) noexcept
Create am empty GUI event.
Definition gui_event.hpp:110
keyboard_virtual_key & key() noexcept
Get the key from the keyboard event.
Definition gui_event.hpp:218