6#include "widget_layout.hpp"
7#include "widget_id.hpp"
8#include "keyboard_focus_group.hpp"
9#include "../layout/module.hpp"
10#include "../GFX/GFX.hpp"
11#include "../telemetry/telemetry.hpp"
12#include "../macros.hpp"
14namespace hi {
inline namespace v1 {
30 virtual ~widget_intf() =
default;
46 [[nodiscard]]
virtual gui_window *
window() const noexcept = 0;
50 [[nodiscard]] virtual generator<widget_intf&>
children(
bool include_invisible) noexcept = 0;
54 [[nodiscard]] virtual generator<widget_intf const&>
children(
bool include_invisible) const noexcept final
56 for (
auto& child :
const_cast<widget_intf *
>(
this)->
children(include_invisible)) {
114 [[nodiscard]] virtual hitbox
hitbox_test(point2 position) const noexcept = 0;
144 std::vector<widget_id> const& reject_list =
std::vector<widget_id>{})
noexcept = 0;
161 widget_id current_keyboard_widget,
162 keyboard_focus_group group,
163 keyboard_focus_direction direction)
const noexcept = 0;
165 [[nodiscard]]
virtual widget_id find_first_widget(keyboard_focus_group group)
const noexcept = 0;
167 [[nodiscard]]
virtual widget_id find_last_widget(keyboard_focus_group group)
const noexcept = 0;
178 while (to_bool(w = w->parent)) {
204 hi_assert_not_null(start);
206 if (start->id ==
id) {
209 for (
auto& child : start->children(include_invisible)) {
210 if (hilet r = get_if(&child,
id, include_invisible); r !=
nullptr) {
219 if (
auto r = get_if(
std::addressof(start),
id, include_invisible); r !=
nullptr) {
@ rectangle
The gui_event has rectangle data.
Definition gui_event_variant.hpp:42
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
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 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.
std::vector< widget_id > parent_chain() const noexcept
Get a list of parents of a given widget.
Definition widget_intf.hpp:172
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:23
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: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 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:38
2D constraints.
Definition box_constraints.hpp:25
Exception thrown when an item was not found.
Definition exception_intf.hpp:148