13#include "../l10n/l10n.hpp"
14#include "../macros.hpp"
20hi_export_module(hikogui.widgets.system_menu_widget);
22hi_export
namespace hi {
inline namespace v1 {
40 _icon_widget = std::make_unique<icon_widget>(icon);
41 _icon_widget->set_parent(
this);
44 template<forward_of<observer<hi::icon>> Icon>
52 [[nodiscard]] generator<widget_intf &>
children(
bool include_invisible)
noexcept override
54 co_yield *_icon_widget;
59 hi_assert_not_null(_icon_widget);
62 _icon_constraints = _icon_widget->update_constraints();
64 auto const size =
extent2{theme().large_size(), theme().large_size()};
65 return {size, size, size};
71 auto const icon_height =
72 context.height() < round_cast<int>(theme().large_size() * 1.2f) ? context.height() : theme().large_size();
73 auto const icon_rectangle =
aarectangle{0, context.height() - icon_height, context.width(), icon_height};
74 _icon_shape =
box_shape{_icon_constraints, icon_rectangle, theme().baseline_adjustment()};
77 theme().margin<
float>(),
79 context.width() - theme().margin<
float>(),
80 context.height() - theme().margin<
float>()};
83 _icon_widget->set_layout(context.
transform(_icon_shape));
89 _icon_widget->draw(context);
93 [[nodiscard]] hitbox
hitbox_test(point2 position)
const noexcept override
95 hi_axiom(loop::main().on_thread());
100 return {
id, _layout.elevation, hitbox_type::application_icon};
@ partial
A widget is partially enabled.
Definition widget_state.hpp:73
@ invisible
The widget is invisible.
Definition widget_state.hpp:41
The HikoGUI namespace.
Definition array_generic.hpp:21
The HikoGUI API version 1.
Definition array_generic.hpp:22
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:53
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:33
A high-level geometric extent.
Definition extent2.hpp:32
Draw context for drawing using the HikoGUI shaders.
Definition draw_context_intf.hpp:209
widget_id id
The numeric identifier of a widget.
Definition widget_intf.hpp:31
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget_intf.hpp:241
The layout of a widget.
Definition widget_layout.hpp:56
constexpr widget_layout transform(box_shape const &child_shape, transform_command command, aarectangle new_clipping_rectangle) const noexcept
Create a new widget_layout for the child widget.
Definition widget_layout.hpp:236
2D constraints.
Definition box_constraints.hpp:25
Definition box_shape.hpp:18
A observer pointing to the whole or part of a observed_base.
Definition observer_intf.hpp:32
The system menu widget.
Definition system_menu_widget.hpp:30
void set_layout(widget_layout const &context) noexcept override
Update the internal layout of the widget.
Definition widget.hpp:116
generator< widget_intf & > children(bool include_invisible) noexcept override
Get a list of child widgets.
Definition widget.hpp:61
void draw(draw_context const &context) noexcept override
Draw the widget.
Definition widget.hpp:121
widget() noexcept
Constructor for creating sub views.
Definition widget.hpp:50
hitbox hitbox_test(point2 position) const noexcept override
Find the widget that is under the mouse cursor.
Definition widget.hpp:73
box_constraints update_constraints() noexcept override
Update the constraints of the widget.
Definition widget.hpp:110