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();
59 return {size, size, size};
62 void set_layout(
widget_layout const& context)
noexcept override
68 hilet icon_height = context.height() < round_cast<int>(size.height() * 1.2f) ? context.height() : size.height();
69 hilet icon_rectangle = aarectangle{0, context.height() - icon_height, context.width(), icon_height};
72 _system_menu_rectangle =
73 aarectangle{margin.left(), 0.0f, 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(point2 position)
const noexcept override
93 return {
id, layout.elevation, hitbox_type::application_icon};
104 aarectangle _system_menu_rectangle;
#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 hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
Functionality for labels, text and icons.
@ partial
A widget is partially enabled.
Definition widget_mode.hpp:67
@ invisible
The widget is invisible.
Definition widget_mode.hpp:35
geometry/margins.hpp
Definition cache.hpp:11
The HikoGUI API version 1.
Definition cache.hpp:11
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition utility.hpp:212
auto theme
A tagged global variable to a theme model for a widget's component.
Definition theme_model.hpp:545
virtual void draw(widget_draw_context &context) noexcept
Draw the widget.
Definition widget.hpp:189
widget_id id
The numeric identifier of a widget.
Definition widget.hpp:35
virtual hitbox hitbox_test(point2 position) const noexcept
Find the widget that is under the mouse cursor.
Definition widget.hpp:126
virtual generator< widget const & > children(bool include_invisible) const noexcept
Get a list of child widgets.
Definition widget.hpp:107
widget * parent
Pointer to the parent widget.
Definition widget.hpp:40
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:49
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 widget_layout transform(box_shape const &child_shape, float child_elevation, aarectangle 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