12#include "../layout/module.hpp"
13#include "../geometry/module.hpp"
14#include "../observer/module.hpp"
15#include "../time/module.hpp"
16#include "../settings/settings.hpp"
17#include "../numeric/module.hpp"
18#include "../GUI/GUI.hpp"
19#include "../coroutine/module.hpp"
20#include "../macros.hpp"
26namespace hi {
inline namespace v1 {
89 hi_axiom(loop::main().on_thread());
96 _mode_cbt =
mode.subscribe([&](
auto...) {
97 ++global_counter<
"widget:mode:constrain">;
154 hi_axiom(loop::main().on_thread());
200 hi_axiom(loop::main().on_thread());
202 switch (
event.type()) {
207 ++global_counter<
"widget:keyboard_enter:redraw">;
213 ++global_counter<
"widget:keyboard_exit:redraw">;
219 ++global_counter<
"widget:mouse_enter:redraw">;
225 ++global_counter<
"widget:mouse_exit:redraw">;
229 case gui_widget_next:
231 gui_event::window_set_keyboard_target(
id, keyboard_focus_group::normal, keyboard_focus_direction::forward));
234 case gui_widget_prev:
236 gui_event::window_set_keyboard_target(
id, keyboard_focus_group::normal, keyboard_focus_direction::backward));
239 case gui_activate_next:
243 case gui_event_type::gui_toolbar_next:
247 gui_event::window_set_keyboard_target(
id, keyboard_focus_group::toolbar, keyboard_focus_direction::forward));
252 case gui_event_type::gui_toolbar_prev:
256 gui_event::window_set_keyboard_target(
id, keyboard_focus_group::toolbar, keyboard_focus_direction::backward));
271 hi_axiom(loop::main().on_thread());
279 if (!std::ranges::any_of(
reject_list, [&](hilet& x) {
290 keyboard_focus_group group,
291 keyboard_focus_direction direction)
const noexcept override
293 hi_axiom(loop::main().on_thread());
306 for (
auto& child :
children(
false)) {
310 if (direction == keyboard_focus_direction::backward) {
315 hi_axiom_not_null(child);
319 if (
auto tmp = child->find_next_widget({}, group, direction)) {
330 }
else if (
tmp !=
nullptr) {
348 [[
nodiscard]] widget_id find_first_widget(keyboard_focus_group group)
const noexcept override
350 hi_axiom(loop::main().on_thread());
353 if (child.accepts_keyboard_focus(group)) {
360 [[
nodiscard]] widget_id find_last_widget(keyboard_focus_group group)
const noexcept override
362 hi_axiom(loop::main().on_thread());
364 auto found = widget_id{};
366 if (child.accepts_keyboard_focus(group)) {
378 hi_axiom(loop::main().on_thread());
379 return parent->find_first_widget(group) ==
id;
386 hi_axiom(loop::main().on_thread());
387 return parent->find_last_widget(group) ==
id;
393 hi_axiom(loop::main().on_thread());
421 hi_assert_not_null(w);
428 return w->surface.get();
464 return theme().color(semantic_color::accent);
478 return theme().color(semantic_color::accent);
487 return theme().text_style(semantic_text_style::label)->color;
494 widget_layout _layout;
496 decltype(
mode)::callback_token _mode_cbt;
509 hi_axiom(loop::main().on_thread());
@ end
Start from the end of the file.
@ begin
Start from the beginning of the file.
gui_event_type
GUI event type.
Definition gui_event_type.hpp:24
@ window_redraw
Request that part of the window gets redrawn on the next frame.
@ window_reconstrain
Request that widget get constraint on the next frame.
@ partial
A widget is partially enabled.
@ enabled
The widget is fully enabled.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29
A high-level geometric extent.
Definition extent2.hpp:29
A rectangle / parallelogram in 3D space.
Definition rectangle.hpp:21
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:208
A user interface event.
Definition gui_event.hpp:75
Definition widget_intf.hpp:17
virtual gui_window * window() const noexcept=0
Get the window that the widget is owned by.
widget_id id
The numeric identifier of a widget.
Definition widget_intf.hpp:23
void scroll_to_show() noexcept
Scroll to show the important part of the widget.
Definition widget_intf.hpp:196
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
virtual bool process_event(gui_event const &event) const noexcept=0
Send a event to the window.
virtual void scroll_to_show(hi::aarectangle rectangle) noexcept=0
Scroll to show the given rectangle on the window.
virtual generator< widget_intf & > children(bool include_invisible) noexcept=0
Get a list of child widgets.
virtual void set_window(gui_window *window) noexcept=0
Set the window for this tree of widgets.
The layout of a widget.
Definition widget_layout.hpp:38
translate2 to_parent
This matrix transforms local coordinates to the coordinates of the parent widget.
Definition widget_layout.hpp:53
constexpr aarectangle clipping_rectangle_on_window() const noexcept
Get the clipping rectangle in window coordinate system.
Definition widget_layout.hpp:168
translate2 from_parent
This matrix transforms parent widget's coordinates to local coordinates.
Definition widget_layout.hpp:57
translate2 from_window
This matrix transforms window coordinates to local coordinates.
Definition widget_layout.hpp:65
extent2 window_size
Size of the window.
Definition widget_layout.hpp:69
2D constraints.
Definition box_constraints.hpp:25
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
widget_layout const & layout() const noexcept override
Get the current layout for this widget.
Definition widget.hpp:169
bool is_first(keyboard_focus_group group) const noexcept
Is this widget the first widget in the parent container.
Definition widget.hpp:376
int logical_layer
The logical layer of the widget.
Definition widget.hpp:75
bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept override
Check if the widget will accept keyboard focus.
Definition widget.hpp:152
int semantic_layer
The draw layer of the widget.
Definition widget.hpp:66
observer< extent2 > minimum
The minimum size this widget is allowed to be.
Definition widget.hpp:79
observer< bool > hover
Mouse cursor is hovering over the widget.
Definition widget.hpp:46
virtual hitbox hitbox_test_from_parent(point2 position, hitbox sibling_hitbox) const noexcept
Call hitbox_test from a parent widget.
Definition widget.hpp:144
void scroll_to_show() noexcept
Scroll to show the important part of the widget.
Definition widget_intf.hpp:196
bool handle_event_recursive(gui_event const &event, std::vector< widget_id > const &reject_list=std::vector< widget_id >{}) noexcept override
Handle command recursive.
Definition widget.hpp:267
gui_window * window() const noexcept override
Get the window that the widget is owned by.
Definition widget.hpp:409
virtual widget_id find_next_widget(widget_id current_keyboard_widget, keyboard_focus_group group, keyboard_focus_direction direction) const noexcept override
Find the next widget that handles keyboard focus.
Definition widget.hpp:288
void scroll_to_show(hi::aarectangle rectangle) noexcept override
Scroll to show the given rectangle on the window.
Definition widget.hpp:391
void set_layout(widget_layout const &context) noexcept override
Update the internal layout of the widget.
Definition widget.hpp:164
widget(widget *parent) noexcept
Definition widget.hpp:87
generator< widget_intf & > children(bool include_invisible) noexcept override
Get a list of child widgets.
Definition widget.hpp:109
void draw(draw_context const &context) noexcept override
Draw the widget.
Definition widget.hpp:174
void request_redraw() const noexcept override
Request the widget to be redrawn on the next frame.
Definition widget.hpp:189
virtual hitbox hitbox_test_from_parent(point2 position) const noexcept
Call hitbox_test from a parent widget.
Definition widget.hpp:132
hitbox hitbox_test(point2 position) const noexcept override
Find the widget that is under the mouse cursor.
Definition widget.hpp:121
box_constraints update_constraints() noexcept override
Update the constraints of the widget.
Definition widget.hpp:158
void set_window(gui_window *window) noexcept override
Set the window for this tree of widgets.
Definition widget.hpp:400
bool is_last(keyboard_focus_group group) const noexcept
Is this widget the last widget in the parent container.
Definition widget.hpp:384
bool process_event(gui_event const &event) const noexcept override
Send a event to the window.
Definition widget.hpp:178
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:42
observer< bool > focus
The widget has keyboard focus.
Definition widget.hpp:50
bool handle_event(gui_event const &event) noexcept override
Handle command.
Definition widget.hpp:198
observer< extent2 > maximum
The maximum size this widget is allowed to be.
Definition widget.hpp:83