47 constexpr static auto prefix = super::prefix;
65 this->set_attributes<0>(
hi_forward(attributes)...);
81 different_from<std::shared_ptr<delegate_type>> Value,
82 forward_of<observer<observer_decay_t<Value>>> OnValue,
97 _label_constraints = super::update_constraints();
100 _button_size = theme<prefix>.size(
this);
101 hi_axiom(button_size.width() == button_size.height());
103 hilet extra_size =
extent2i{theme<prefix>.horizontal_spacing(
this) + _button_size.
width(), 0};
105 auto constraints = max(_label_constraints + extra_size, _button_size);
106 constraints.margins = theme<prefix>.margin(
this);
107 constraints.alignment = *this->
alignment;
111 void set_layout(widget_layout
const& context)
noexcept override
116 if (alignment_ == horizontal_alignment::left or alignment_ == horizontal_alignment::right) {
117 _button_rectangle =
align(context.rectangle(), _button_size, alignment_);
122 hilet inner_margin = theme<prefix>.horizontal_spacing(
this);
123 hilet cap_height = theme<prefix>.cap_height(
this);
125 hilet label_width = context.width() - (_button_rectangle.width() + inner_margin);
126 if (alignment_ == horizontal_alignment::left) {
127 hilet label_left = _button_rectangle.right() + inner_margin;
128 hilet label_rectangle = aarectanglei{label_left, 0, label_width, context.height()};
129 this->_on_label_shape = this->_off_label_shape = this->_other_label_shape =
130 box_shape{_label_constraints, label_rectangle, cap_height};
132 }
else if (alignment_ == horizontal_alignment::right) {
133 hilet label_rectangle = aarectanglei{0, 0, label_width, context.height()};
134 this->_on_label_shape = this->_off_label_shape = this->_other_label_shape =
135 box_shape{_label_constraints, label_rectangle, cap_height};
141 _button_circle = circle{narrow_cast<aarectangle>(_button_rectangle)};
143 _pip_size =
theme<prefix /
"pip">.size(
this);
144 hi_axiom(_pip_size.width() == _pip_size.height());
147 align(narrow_cast<aarectangle>(_button_rectangle), circle{_pip_size.width() / 2}, alignment::middle_center());
149 super::set_layout(context);
152 void draw(widget_draw_context
const& context)
noexcept override
155 draw_radio_button(context);
156 draw_radio_pip(context);
157 this->draw_button(context);
164 box_constraints _label_constraints;
167 aarectanglei _button_rectangle;
168 circle _button_circle;
170 animator<float> _animated_value = _animation_duration;
173 void draw_radio_button(widget_draw_context
const& context)
noexcept
177 _button_circle * 1.02f,
178 theme<prefix>.background_color(
this),
179 theme<prefix>.border_color(
this),
180 theme<prefix>.border_width(
this),
184 void draw_radio_pip(widget_draw_context
const& context)
noexcept
187 if (_animated_value.is_animating()) {
192 auto float_value = _animated_value.current_value();
193 if (float_value > 0.0f) {
196 _pip_circle * 1.02f * float_value,
197 theme<prefix / "pip">.background_color(
this),
198 theme<prefix / "pip">.border_color(
this),
199 theme<prefix / "pip">.border_width(
this));