13namespace hi {
inline namespace v1 {
46template<fixed_string Name =
"">
67 this->
alignment = alignment::top_center();
68 this->set_attributes<0>(
hi_forward(attributes)...);
84 different_from<std::shared_ptr<delegate_type>> Value,
85 forward_of<observer<observer_decay_t<Value>>> OnValue,
102 if (this->
parent !=
nullptr) {
112 _label_constraints = super::update_constraints();
116 extent2i{theme<super::prefix>.spacing_horizontal(
this) * 2, theme<super::prefix>.spacing_vertical(
this)};
117 return _label_constraints + extra_size;
120 void set_layout(widget_layout
const& context)
noexcept override
123 hilet label_rectangle = aarectanglei{
124 theme<super::prefix>.spacing_horizontal(
this),
126 context.width() - theme<super::prefix>.spacing_horizontal(
this) * 2,
127 context.height() - theme<super::prefix>.spacing_vertical(
this)};
128 this->_on_label_shape = this->_off_label_shape = this->_other_label_shape =
129 box_shape{_label_constraints, label_rectangle, theme<super::prefix>.cap_height(
this)};
131 super::set_layout(context);
134 void draw(widget_draw_context
const& context)
noexcept override
137 draw_toolbar_tab_button(context);
138 this->draw_button(context);
141 [[nodiscard]]
bool accepts_keyboard_focus(keyboard_focus_group group)
const noexcept override
146 [[nodiscard]]
bool is_tab_button() const noexcept
override
152 box_constraints _label_constraints;
154 void draw_toolbar_tab_button(widget_draw_context
const& context)
noexcept
158 hilet offset = theme<super::prefix>.margin_bottom(
this) + theme<super::prefix>.border_width(
this);
159 hilet outline_rectangle = aarectanglei{0, -offset, this->layout.width(), this->layout.height() + offset};
162 hilet button_z = *this->
focus ? translate_z(0.6f) : translate_z(0.0f);
166 button_z * narrow_cast<aarectangle>(outline_rectangle),
167 theme<super::prefix>.background_color(
this),
168 theme<super::prefix>.border_color(
this),
169 theme<super::prefix>.border_width(
this),
171 theme<super::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
std::shared_ptr< button_delegate > make_default_radio_button_delegate(auto &&value, auto &&on_value) noexcept
Make a shared pointer to a radio-button delegate.
Definition button_delegate.hpp:205
@ partial
A widget is partially enabled.
@ 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
virtual void request_redraw() const noexcept
Request the widget to be redrawn on the next frame.
Definition widget.hpp:270
widget * parent
Pointer to the parent widget.
Definition widget.hpp:40
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:53
observer< bool > focus
The widget has keyboard focus.
Definition widget.hpp:65
2D constraints.
Definition box_constraints.hpp:22
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 graphical control element that allows the user to choose only one of a predefined set of mutually e...
Definition toolbar_tab_button_widget.hpp:47
void request_redraw() const noexcept override
Request the widget to be redrawn on the next frame.
Definition toolbar_tab_button_widget.hpp:97
toolbar_tab_button_widget(widget *parent, std::shared_ptr< delegate_type > delegate, button_widget_attribute auto &&...attributes) noexcept
Construct a toolbar tab button widget.
Definition toolbar_tab_button_widget.hpp:61
toolbar_tab_button_widget(widget *parent, Value &&value, OnValue &&on_value, Attributes &&...attributes) noexcept
Construct a toolbar tab button widget with a default button delegate.
Definition toolbar_tab_button_widget.hpp:87
Definition abstract_button_widget.hpp:26