45 hi_axiom(loop::main().on_thread());
50 _children.push_back(std::make_unique<spacer_widget>(
this));
71 auto widget = std::make_unique<Widget>(
this, std::forward<Args>(args)...);
78 for (hilet& child : _children) {
79 co_yield *child.value;
87 for (
auto& child : _children) {
88 child.set_constraints(child.value->update_constraints());
91 auto r = _children.constraints(os_settings::left_to_right());
92 _child_height_adjustment = -r.margins.top();
94 r.minimum.height() += r.margins.top();
95 r.preferred.height() += r.margins.top();
96 r.maximum.height() += r.margins.top();
97 r.padding.top() += r.margins.top();
102 void set_layout(widget_layout
const&
context)
noexcept override
107 shape.rectangle = aarectangle{shape.x(), shape.y(), shape.width(), shape.height() + _child_height_adjustment};
108 _children.set_layout(shape, theme().baseline_adjustment());
113 for (hilet& child : _children) {
120 void draw(draw_context
const&
context)
noexcept override
126 if (tab_button_has_focus()) {
129 hilet
focus_rectangle = aarectangle{0.0f, 0.0f,
layout().rectangle().width(), theme().border_width()};
134 for (hilet& child : _children) {
135 hi_assert_not_null(child.value);
140 hitbox hitbox_test(point2 position)
const noexcept override
142 hi_axiom(loop::main().on_thread());
146 auto r =
layout().
contains(position) ? hitbox{
id, _layout.elevation, hitbox_type::move_area} : hitbox{};
148 for (hilet& child : _children) {
149 hi_assert_not_null(child.value);
150 r = child.value->hitbox_test_from_parent(position, r);
161 return theme().color(semantic_color::accent);
169 mutable float _child_height_adjustment = 0.0f;
170 size_t _spacer_index = 0;
172 void update_layout_for_child(
widget& child,
ssize_t index, widget_layout
const&
context)
const noexcept;
182 _children.insert(_children.cbegin() + _spacer_index,
std::move(
widget));
186 _children.insert(_children.cbegin() + _spacer_index + 1,
std::move(
widget));
201 for (hilet&
cell : _children) {
202 if (
auto const *
const c =
dynamic_cast<toolbar_tab_button_widget *
>(
cell.value.get())) {
203 if (*c->focus
and c->state() == hi::button_state::on) {
constexpr bool contains(point3 mouse_position) const noexcept
Check if the mouse position is inside the widget.
Definition widget_layout.hpp:149
widget_layout const & layout() const noexcept override
Get the current layout for this widget.
Definition widget.hpp:169