6#include "widget_layout.hpp"
7#include "widget_id.hpp"
8#include "keyboard_focus_group.hpp"
9#include "../layout/module.hpp"
10#include "../GFX/module.hpp"
11#include "../telemetry/module.hpp"
13namespace hi {
inline namespace v1 {
45 [[nodiscard]]
virtual gui_window *
window() const noexcept = 0;
53 [[nodiscard]] virtual generator<
widget_intf const&>
children(
bool include_invisible) const noexcept final
113 [[nodiscard]] virtual hitbox
hitbox_test(point2 position) const noexcept = 0;
143 std::vector<widget_id> const& reject_list =
std::vector<widget_id>{})
noexcept = 0;
160 widget_id current_keyboard_widget,
161 keyboard_focus_group group,
162 keyboard_focus_direction direction)
const noexcept = 0;
164 [[nodiscard]]
virtual widget_id find_first_widget(keyboard_focus_group group)
const noexcept = 0;
166 [[nodiscard]]
virtual widget_id find_last_widget(keyboard_focus_group group)
const noexcept = 0;
177 while (to_bool(w = w->parent)) {
205 if (start->id ==
id) {
208 for (
auto& child : start->children(include_invisible)) {
209 if (
hilet r = get_if(&child,
id, include_invisible); r !=
nullptr) {
216inline widget_intf& get(widget_intf& start, widget_id
id,
bool include_invisible)
218 if (
auto r = get_if(
std::addressof(start),
id, include_invisible); r !=
nullptr) {
221 throw not_found_error(
"get widget by id");
#define hi_assert_not_null(x,...)
Assert if an expression is not nullptr.
Definition assert.hpp:238
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
@ rectangle
The gui_event has rectangle data.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:26
A rectangle / parallelogram in 3D space.
Definition rectangle.hpp:20
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:209
A user interface event.
Definition gui_event.hpp:74
Definition widget_intf.hpp:16
virtual gui_window * window() const noexcept=0
Get the window that the widget is owned by.
std::vector< widget_id > parent_chain() const noexcept
Get a list of parents of a given widget.
Definition widget_intf.hpp:171
virtual bool handle_event_recursive(gui_event const &event, std::vector< widget_id > const &reject_list=std::vector< widget_id >{}) noexcept=0
Handle command recursive.
widget_id id
The numeric identifier of a widget.
Definition widget_intf.hpp:22
virtual void request_redraw() const noexcept=0
Request the widget to be redrawn on the next frame.
void scroll_to_show() noexcept
Scroll to show the important part of the widget.
Definition widget_intf.hpp:195
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:27
virtual bool process_event(gui_event const &event) const noexcept=0
Send a event to the window.
virtual bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept=0
Check if the widget will accept keyboard focus.
virtual box_constraints update_constraints() noexcept=0
Update the constraints of the widget.
virtual widget_id find_next_widget(widget_id current_keyboard_widget, keyboard_focus_group group, keyboard_focus_direction direction) const noexcept=0
Find the next widget that handles keyboard focus.
virtual void set_layout(widget_layout const &context) noexcept=0
Update the internal layout of the widget.
virtual void scroll_to_show(hi::aarectangle rectangle) noexcept=0
Scroll to show the given rectangle on the window.
virtual bool handle_event(gui_event const &event) noexcept=0
Handle command.
virtual hitbox hitbox_test(point2 position) const noexcept=0
Find the widget that is under the mouse cursor.
virtual widget_layout const & layout() const noexcept=0
Get the current layout for this widget.
virtual generator< widget_intf & > children(bool include_invisible) noexcept=0
Get a list of child widgets.
virtual void draw(draw_context const &context) noexcept=0
Draw the widget.
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:35
2D constraints.
Definition box_constraints.hpp:22