48 hi_axiom(loop::main().on_thread());
50 auto spacer = std::make_unique<spacer_widget>();
51 spacer->set_parent(
this);
81 [[nodiscard]] generator<widget_intf &> children(
bool include_invisible)
noexcept override
83 for (
auto const& child : _children) {
84 co_yield *child.value;
92 for (
auto& child : _children) {
93 child.set_constraints(child.value->update_constraints());
96 auto r = _children.constraints(os_settings::left_to_right());
97 _child_height_adjustment = -r.margins.top();
99 r.minimum.height() += r.margins.top();
100 r.preferred.height() += r.margins.top();
101 r.maximum.height() += r.margins.top();
106 void set_layout(widget_layout
const& context)
noexcept override
110 auto shape = context.shape;
111 shape.rectangle = aarectangle{shape.x(), shape.y(), shape.width(), shape.height() + _child_height_adjustment};
112 _children.set_layout(shape, theme().baseline_adjustment());
115 auto const overhang = context.redraw_overhang;
117 for (
auto const& child : _children) {
118 auto const child_clipping_rectangle =
119 aarectangle{child.shape.x() - overhang, 0, child.shape.width() + overhang * 2, context.height() + overhang * 2};
124 void draw(draw_context
const& context)
noexcept override
127 if (overlaps(context,
layout())) {
130 if (tab_button_has_focus()) {
133 auto const focus_rectangle = aarectangle{0.0f, 0.0f,
layout().rectangle().width(), theme().border_width()};
134 context.draw_box(
layout(), translate3{0.0f, 0.0f, 1.5f} * focus_rectangle, focus_color());
138 for (
auto const& child : _children) {
139 hi_assert_not_null(child.value);
140 child.value->draw(context);
144 hitbox hitbox_test(point2 position)
const noexcept override
146 hi_axiom(loop::main().on_thread());
150 auto r =
layout().
contains(position) ? hitbox{
id, _layout.elevation, hitbox_type::move_area} : hitbox{};
152 for (
auto const& child : _children) {
153 hi_assert_not_null(child.value);
154 r = child.value->hitbox_test_from_parent(position, r);
162 [[nodiscard]]
color focus_color() const noexcept
override
165 return theme().accent_color();
167 return theme().border_color(_layout.layer - 1);
172 mutable row_layout<std::unique_ptr<widget>> _children;
173 mutable float _child_height_adjustment = 0.0f;
174 size_t _spacer_index = 0;
176 void update_layout_for_child(
widget& child,
ssize_t index, widget_layout
const& context)
const noexcept;
187 _children.insert(_children.cbegin() + _spacer_index,
std::move(
widget));
192 _children.insert(_children.cbegin() + _spacer_index + 1,
std::move(
widget));
205 bool tab_button_has_focus() const noexcept
207 for (
auto const& cell : _children) {
208 if (
auto const *
const c =
dynamic_cast<toolbar_tab_button_widget *
>(cell.value.get())) {
209 if (c->focus() and c->value() == widget_value::on) {