12#include "../telemetry/telemetry.hpp"
13#include "../macros.hpp"
15namespace hi {
inline namespace v1 {
148 _label_constraints = super::update_constraints();
150 _button_size = {theme().size(), theme().size()};
151 hilet
extra_size = extent2{theme().margin<
float>() + _button_size.
width(), 0};
153 auto constraints =
max(_label_constraints +
extra_size, _button_size);
154 constraints.margins = theme().margin();
159 void set_layout(widget_layout
const&
context)
noexcept override
167 hi_not_implemented();
170 hilet
label_width =
context.width() - (_button_rectangle.width() + theme().margin<
float>());
172 hilet
label_left = _button_rectangle.right() + theme().margin<
float>();
174 _on_label_shape = _off_label_shape = _other_label_shape =
175 box_shape(_label_constraints,
label_rectangle, theme().baseline_adjustment());
179 _on_label_shape = _off_label_shape = _other_label_shape =
180 box_shape(_label_constraints,
label_rectangle, theme().baseline_adjustment());
182 hi_not_implemented();
186 hilet
check_glyph_bb = _check_glyph.get_metrics().bounding_rectangle * theme().icon_size();
187 _check_glyph_rectangle =
align(_button_rectangle,
check_glyph_bb, alignment::middle_center());
189 _minus_glyph =
find_glyph(elusive_icon::Minus);
190 hilet
minus_glyph_bb = _minus_glyph.get_metrics().bounding_rectangle * theme().icon_size();
191 _minus_glyph_rectangle =
align(_button_rectangle,
minus_glyph_bb, alignment::middle_center());
196 void draw(draw_context
const&
context)
noexcept override
206 box_constraints _label_constraints;
208 extent2 _button_size;
209 aarectangle _button_rectangle;
210 font_book::font_glyph_type _check_glyph;
211 aarectangle _check_glyph_rectangle;
212 font_book::font_glyph_type _minus_glyph;
213 aarectangle _minus_glyph_rectangle;
215 void draw_check_box(draw_context
const&
context)
noexcept
221 void draw_check_mark(draw_context
const&
context)
noexcept
226 if (
state_ == hi::button_state::on) {
227 context.draw_glyph(
layout(), translate_z(0.1f) * _check_glyph_rectangle, _check_glyph, accent_color());
229 }
else if (
state_ == hi::button_state::off) {
233 context.draw_glyph(
layout(), translate_z(0.1f) * _minus_glyph_rectangle, _minus_glyph, accent_color());
Defines abstract_button_widget.
@ right
Align the text to the right side.
@ left
Align the text to the left side.
std::shared_ptr< button_delegate > make_default_toggle_button_delegate(auto &&value, auto &&...args) noexcept
Make a shared pointer to a toggle-button delegate.
Definition button_delegate.hpp:245
@ invisible
The widget is invisible.
DOXYGEN BUG.
Definition algorithm.hpp:16
hi_export auto find_glyph(font const &font, grapheme grapheme) noexcept
Find a glyph using the given code-point.
Definition font_book.hpp:437
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
@ inside
The border is drawn inside the edge of a quad.
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:56
constexpr horizontal_alignment mirror(horizontal_alignment const &rhs) noexcept
Mirror the horizontal alignment.
Definition alignment.hpp:203
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Horizontal/Vertical alignment combination.
Definition alignment.hpp:242
constexpr float & width() noexcept
Access the x-as-width element from the extent.
Definition extent2.hpp:104
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
2D constraints.
Definition box_constraints.hpp:25
Base class for implementing button widgets.
Definition abstract_button_widget.hpp:33
std::shared_ptr< delegate_type > delegate
The delegate that controls the button widget.
Definition abstract_button_widget.hpp:40
button_state state() const noexcept
Get the current state of the button.
Definition abstract_button_widget.hpp:88
observer< alignment > alignment
The alignment of the button and on/off/other label.
Definition abstract_button_widget.hpp:56
A button delegate controls the state of a button widget.
Definition button_delegate.hpp:45
A GUI widget that permits the user to make a binary choice.
Definition checkbox_widget.hpp:43
checkbox_widget(widget *parent, std::shared_ptr< delegate_type > delegate, button_widget_attribute auto &&...attributes) noexcept
Construct a checkbox widget.
Definition checkbox_widget.hpp:57
checkbox_widget(widget *parent, Value &&value, OnValue &&on_value, Attributes &&...attributes) noexcept
Construct a checkbox widget with a default button delegate.
Definition checkbox_widget.hpp:100
checkbox_widget(widget *parent, Value &&value, OnValue &&on_value, OffValue &&off_value, Attributes &&...attributes) noexcept
Construct a checkbox widget with a default button delegate.
Definition checkbox_widget.hpp:129
checkbox_widget(widget *parent, different_from< std::shared_ptr< delegate_type > > auto &&value, button_widget_attribute auto &&...attributes) noexcept
Construct a checkbox widget with a default button delegate.
Definition checkbox_widget.hpp:77
An interactive graphical object as part of the user-interface.
Definition widget.hpp:37
widget_layout const & layout() const noexcept override
Get the current layout for this widget.
Definition widget.hpp:169
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:42
Definition concepts.hpp:54
Definition abstract_button_widget.hpp:27