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>(
this, icon);
43 template<forward_of<observer<hi::icon>> Icon>
47 this->icon = std::forward<Icon>(icon);
51 [[nodiscard]] generator<widget_intf &> children(
bool include_invisible)
noexcept override
53 co_yield *_icon_widget;
58 hi_assert_not_null(_icon_widget);
61 _icon_constraints = _icon_widget->update_constraints();
63 auto const size =
extent2{theme().large_size(), theme().large_size()};
64 return {size, size, size};
67 void set_layout(
widget_layout const& context)
noexcept override
70 auto const icon_height =
71 context.height() < round_cast<int>(theme().large_size() * 1.2f) ? context.height() : theme().large_size();
72 auto const icon_rectangle =
aarectangle{0, context.height() - icon_height, context.width(), icon_height};
73 _icon_shape =
box_shape{_icon_constraints, icon_rectangle, theme().baseline_adjustment()};
76 theme().margin<
float>(),
78 context.width() - theme().margin<
float>(),
79 context.height() - theme().margin<
float>()};
82 _icon_widget->set_layout(context.
transform(_icon_shape));
88 _icon_widget->draw(context);
92 [[nodiscard]] hitbox hitbox_test(point2 position)
const noexcept override
94 hi_axiom(loop::main().on_thread());
99 return {
id, _layout.elevation, hitbox_type::application_icon};
@ partial
A widget is partially enabled.
@ invisible
The widget is invisible.
The HikoGUI namespace.
Definition array_generic.hpp:20
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:53
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
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
Definition widget_intf.hpp:24
widget_id id
The numeric identifier of a widget.
Definition widget_intf.hpp:30
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget_intf.hpp:206
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:35
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
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
widget() noexcept
Constructor for creating sub views.
Definition widget.hpp:55