13namespace hi {
inline namespace v1 {
18template<fixed_string Name =
"">
23 constexpr static auto prefix = super::prefix;
28 button_widget_attribute
auto&&...attributes) noexcept :
31 this->
alignment = alignment::middle_center();
32 this->set_attributes<0>(
hi_forward(attributes)...);
43 _label_constraints = super::update_constraints();
45 auto constraints = _label_constraints;
46 constraints.minimum.
width() += _label_constraints.margins.left() + _label_constraints.margins.right();
47 constraints.preferred.width() += _label_constraints.margins.left() + _label_constraints.margins.right();
48 constraints.maximum.width() += _label_constraints.margins.left() + _label_constraints.margins.right();
49 constraints.minimum.height() += _label_constraints.margins.bottom() + _label_constraints.margins.top();
50 constraints.preferred.height() += _label_constraints.margins.bottom() + _label_constraints.margins.top();
51 constraints.maximum.height() += _label_constraints.margins.bottom() + _label_constraints.margins.top();
52 constraints.margins = theme<prefix>.margin(
this);
56 void set_layout(
widget_layout const& context)
noexcept override
59 hilet label_rectangle =
aarectangle{context.size()} - _label_constraints.margins;
61 this->_on_label_shape = this->_off_label_shape = this->_other_label_shape =
62 box_shape{_label_constraints, label_rectangle, theme<prefix>.cap_height(
this)};
64 super::set_layout(context);
70 draw_label_button(context);
71 this->draw_button(context);
83 this->layout.rectangle(),
84 theme<prefix>.background_color(
this),
85 theme<prefix>.border_color(
this),
86 theme<prefix>.border_width(
this),
88 theme<prefix>.border_radius(
this));
Defines abstract_button_widget.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
@ invisible
The widget is invisible.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
@ 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 utility.hpp:212
Class which represents an axis-aligned rectangle.
Definition axis_aligned_rectangle.hpp:27
constexpr value_type & width() noexcept
Access the x-as-width element from the extent.
Definition extent.hpp:166
widget * parent
Pointer to the parent widget.
Definition widget.hpp:40
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:49
Draw context for drawing using the HikoGUI shaders.
Definition widget_draw_context.hpp:204
The layout of a widget.
Definition widget_layout.hpp:37
2D constraints.
Definition box_constraints.hpp:22
Definition box_shape.hpp:15
Base class for implementing button widgets.
Definition abstract_button_widget.hpp:33
observer< hi::alignment > alignment
The alignment of the button and on/off/other label.
Definition abstract_button_widget.hpp:58
std::shared_ptr< delegate_type > delegate
The delegate that controls the button widget.
Definition abstract_button_widget.hpp:42
A button delegate controls the state of a button widget.
Definition button_delegate.hpp:23
A momentary button widget.
Definition momentary_button_widget.hpp:19