11#include "../GUI/module.hpp"
18namespace hi {
inline namespace v1 {
26template<fixed_string Name =
"">
30 constexpr static auto prefix = Name /
"system-menu";
38 _icon_widget = std::make_unique<icon_widget<prefix>>(
this, icon);
47 [[nodiscard]] generator<widget const&> children(
bool include_invisible)
const noexcept override
49 co_yield *_icon_widget;
56 _icon_constraints = _icon_widget->update_constraints();
58 hilet size = theme<prefix>.size(
this);
59 return {size, size, size};
62 void set_layout(
widget_layout const& context)
noexcept override
65 hilet size = theme<prefix>.size(
this);
66 hilet margin = theme<prefix>.margin(
this);
68 hilet icon_height = context.height() < round_cast<int>(size.height() * 1.2f) ? context.height() : size.height();
69 hilet icon_rectangle =
aarectanglei{0, context.height() - icon_height, context.width(), icon_height};
70 _icon_shape =
box_shape{_icon_constraints, icon_rectangle, theme<prefix>.cap_height(
this)};
72 _system_menu_rectangle =
73 aarectanglei{margin.left(), 0, context.width() - margin.right(), context.height() - margin.top()};
76 _icon_widget->set_layout(context.
transform(_icon_shape));
82 _icon_widget->draw(context);
86 [[nodiscard]] hitbox hitbox_test(point2i position)
const noexcept override
93 return {
id, layout.
elevation, hitbox_type::application_icon};
Functionality for labels, text and icons.
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
#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
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
@ partial
A widget is partially enabled.
@ invisible
The widget is invisible.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition utility.hpp:212
widget_id id
The numeric identifier of a widget.
Definition widget.hpp:35
widget * parent
Pointer to the parent widget.
Definition widget.hpp:40
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:53
Draw context for drawing using the HikoGUI shaders.
Definition widget_draw_context.hpp:204
The layout of a widget.
Definition widget_layout.hpp:37
constexpr bool contains(point3i mouse_position) const noexcept
Check if the mouse position is inside the widget.
Definition widget_layout.hpp:126
float elevation
The elevation of the widget above the window.
Definition widget_layout.hpp:72
constexpr widget_layout transform(box_shape const &child_shape, float child_elevation, aarectanglei new_clipping_rectangle) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:203
2D constraints.
Definition box_constraints.hpp:22
Definition box_shape.hpp:15
The system menu widget.
Definition system_menu_widget.hpp:27