11#include "../GFX/draw_context.hpp"
12#include "../GUI/theme.hpp"
13#include "../GUI/hitbox.hpp"
14#include "../GUI/keyboard_focus_direction.hpp"
15#include "../GUI/keyboard_focus_group.hpp"
17#include "../geometry/extent.hpp"
18#include "../geometry/axis_aligned_rectangle.hpp"
19#include "../geometry/transform.hpp"
20#include "../observer.hpp"
21#include "../chrono.hpp"
22#include "../generator.hpp"
31namespace hi {
inline namespace v1 {
107 [[nodiscard]]
bool is_gui_thread() const noexcept;
128 [[nodiscard]] virtual hitbox
hitbox_test(point3 position) const noexcept
161 hi_axiom(is_gui_thread());
217 virtual void draw(draw_context
const& context)
noexcept = 0;
229 template<fixed_string SourceFile,
int SourceLine, fixed_string Fmt, typename... Args>
232 constexpr auto FmtPlus = fixed_string{
"request_reconstrain:"} + Fmt;
234 log_global.
add<global_state_type::log_info, SourceFile, SourceLine, FmtPlus>(std::forward<Args>(args)...);
235 _request_reconstrain();
238#define hi_request_reconstrain(fmt, ...) \
239 hi_format_check(fmt __VA_OPT__(, ) __VA_ARGS__); \
240 this->request_reconstrain<__FILE__, __LINE__, fmt>(__VA_ARGS__)
244 template<fixed_string SourceFile,
int SourceLine, fixed_string Fmt,
typename... Args>
247 constexpr auto FmtPlus = fixed_string{
"request_resize:"} + Fmt;
249 log_global.
add<global_state_type::log_info, SourceFile, SourceLine, FmtPlus>(std::forward<Args>(args)...);
253#define hi_request_resize(fmt, ...) \
254 hi_format_check(fmt __VA_OPT__(, ) __VA_ARGS__); \
255 this->request_resize<__FILE__, __LINE__, fmt>(__VA_ARGS__)
287 widget const *current_keyboard_widget,
288 keyboard_focus_group group,
289 keyboard_focus_direction direction)
const noexcept;
291 [[nodiscard]]
widget const *find_first_widget(keyboard_focus_group group)
const noexcept;
293 [[nodiscard]]
widget const *find_last_widget(keyboard_focus_group group)
const noexcept;
297 [[nodiscard]]
bool is_first(keyboard_focus_group group)
const noexcept;
301 [[nodiscard]]
bool is_last(keyboard_focus_group group)
const noexcept;
323 virtual [[nodiscard]] color background_color() const noexcept;
325 virtual [[nodiscard]] color foreground_color() const noexcept;
327 virtual [[nodiscard]] color focus_color() const noexcept;
329 virtual [[nodiscard]] color accent_color() const noexcept;
331 virtual [[nodiscard]] color label_color() const noexcept;
337 decltype(
mode)::callback_token _mode_cbt;
339 [[nodiscard]] virtual generator<
widget *> children() const noexcept
353 [[nodiscard]] aarectangle make_overlay_rectangle(aarectangle requested_rectangle)
const noexcept;
356 void _request_reconstrain() const noexcept;
357 void _request_resize() const noexcept;
Defines widget_constraints.
Definition of GUI event types.
@ enabled
The widget is fully enabled.
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
A user interface event.
Definition gui_event.hpp:66
hi_force_inline void add(Args &&...args) noexcept
Log a message.
Definition log.hpp:124
An interactive graphical object as part of the user-interface.
Definition widget.hpp:44
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget.hpp:198
bool is_first(keyboard_focus_group group) const noexcept
Is this widget the first widget in the parent container.
virtual void scroll_to_show(hi::aarectangle rectangle) noexcept
Scroll to show the given rectangle on the window.
void request_resize(Args &&...args) const noexcept
Request the window to be resize based on the preferred size of the widgets.
Definition widget.hpp:245
virtual hitbox hitbox_test_from_parent(point3 position) const noexcept
Call hitbox_test from a parent widget.
Definition widget.hpp:139
virtual widget const * find_next_widget(widget const *current_keyboard_widget, keyboard_focus_group group, keyboard_focus_direction direction) const noexcept
Find the next widget that handles keyboard focus.
virtual void set_layout(widget_layout const &layout) noexcept=0
Update the internal layout of the widget.
int logical_layer
The logical layer of the widget.
Definition widget.hpp:95
std::string id
A name of widget, should be unique between siblings.
Definition widget.hpp:57
int semantic_layer
The draw layer of the widget.
Definition widget.hpp:86
hi::font_book & font_book() const noexcept
Get the font book.
observer< bool > hover
Mouse cursor is hovering over the widget.
Definition widget.hpp:66
widget *const parent
Pointer to the parent widget.
Definition widget.hpp:53
virtual void draw(draw_context const &context) noexcept=0
Draw the widget.
widget(gui_window &window, widget *parent) noexcept
virtual bool handle_event_recursive(gui_event const &event, std::vector< widget const * > const &reject_list=std::vector< widget const * >{}) noexcept
Handle command recursive.
void request_reconstrain(Args &&...args) const noexcept
Request the window to be reconstrain on the next frame.
Definition widget.hpp:230
virtual hitbox hitbox_test_from_parent(point3 position, hitbox sibling_hitbox) const noexcept
Call hitbox_test from a parent widget.
Definition widget.hpp:151
virtual void request_redraw() const noexcept
Request the widget to be redrawn on the next frame.
hi::theme const & theme() const noexcept
Get the theme.
virtual hitbox hitbox_test(point3 position) const noexcept
Find the widget that is under the mouse cursor.
Definition widget.hpp:128
virtual widget_constraints const & set_constraints() noexcept=0
Update the constraints of the widget.
std::vector< widget const * > parent_chain() const noexcept
Get a list of parents of a given widget.
virtual bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept
Check if the widget will accept keyboard focus.
Definition widget.hpp:159
virtual bool handle_event(gui_event const &event) noexcept
Handle command.
bool is_last(keyboard_focus_group group) const noexcept
Is this widget the last widget in the parent container.
void request_relayout() const noexcept
Request the window to be relayout on the next frame.
void scroll_to_show() noexcept
Scroll to show the important part of the widget.
Definition widget.hpp:313
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:62
observer< bool > focus
The widget has keyboard focus.
Definition widget.hpp:70
gui_window & window
Convenient reference to the Window.
Definition widget.hpp:48
The constraints of a widget.
Definition widget_constraints.hpp:26
The layout of a widget.
Definition widget_layout.hpp:37
matrix3 from_parent
This matrix transforms parent widget's coordinates to local coordinates.
Definition widget_layout.hpp:51