13#include "../l10n/l10n.hpp"
14#include "../macros.hpp"
19namespace hi {
inline namespace v1 {
37 _icon_widget = std::make_unique<icon_widget>(
this, icon);
43 this->icon = hi_forward(icon);
47 [[nodiscard]] generator<widget_intf &>
children(
bool include_invisible)
noexcept override
49 co_yield *_icon_widget;
54 hi_assert_not_null(_icon_widget);
57 _icon_constraints = _icon_widget->update_constraints();
59 hilet size =
extent2{theme().large_size(), theme().large_size()};
60 return {size, size, size};
67 context.height() < round_cast<int>(theme().large_size() * 1.2f) ? context.height() : theme().large_size();
68 hilet icon_rectangle =
aarectangle{0, context.height() - icon_height, context.width(), icon_height};
69 _icon_shape =
box_shape{_icon_constraints, icon_rectangle, theme().baseline_adjustment()};
72 theme().margin<
float>(),
74 context.width() - theme().margin<
float>(),
75 context.height() - theme().margin<
float>()};
78 _icon_widget->set_layout(context.
transform(_icon_shape));
84 _icon_widget->draw(context);
88 [[nodiscard]] hitbox
hitbox_test(point2 position)
const noexcept override
90 hi_axiom(loop::main().on_thread());
95 return {
id, _layout.elevation, hitbox_type::application_icon};
@ partial
A widget is partially enabled.
Definition widget_mode.hpp:68
@ invisible
The widget is invisible.
Definition widget_mode.hpp:36
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:56
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:29
A high-level geometric extent.
Definition extent2.hpp:29
Draw context for drawing using the HikoGUI shaders.
Definition draw_context.hpp:208
widget_id id
The numeric identifier of a widget.
Definition widget_intf.hpp:23
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
The layout of a widget.
Definition widget_layout.hpp:38
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:206
2D constraints.
Definition box_constraints.hpp:25
Definition box_shape.hpp:18
The system menu widget.
Definition system_menu_widget.hpp:27
widget_layout const & layout() const noexcept override
Get the current layout for this widget.
Definition widget.hpp:169
void set_layout(widget_layout const &context) noexcept override
Update the internal layout of the widget.
Definition widget.hpp:164
widget(widget *parent) noexcept
Definition widget.hpp:87
generator< widget_intf & > children(bool include_invisible) noexcept override
Get a list of child widgets.
Definition widget.hpp:109
void draw(draw_context const &context) noexcept override
Draw the widget.
Definition widget.hpp:174
hitbox hitbox_test(point2 position) const noexcept override
Find the widget that is under the mouse cursor.
Definition widget.hpp:121
box_constraints update_constraints() noexcept override
Update the constraints of the widget.
Definition widget.hpp:158
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:42