13namespace hi {
inline namespace v1 {
46template<fixed_string Name =
"">
49 using super = abstract_button_widget<Name /
"toolbar-tab-button">;
50 using delegate_type =
typename super::delegate_type;
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) {
103 this->
parent->request_redraw();
112 _label_constraints = super::update_constraints();
117 return _label_constraints + extra_size;
120 void set_layout(widget_layout
const& context)
noexcept override
123 hilet label_rectangle = aarectangle{
128 this->_on_label_shape = this->_off_label_shape = this->_other_label_shape =
131 super::set_layout(context);
134 void draw(widget_draw_context& 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
152 box_constraints _label_constraints;
154 void draw_toolbar_tab_button(widget_draw_context& context)
noexcept
159 hilet outline_rectangle = aarectangle{0.0f, -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),
#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
Defines abstract_button_widget.
geo::extent< float, 2 > extent2
A 2D extent.
Definition extent.hpp:502
std::shared_ptr< radio_button_delegate > make_default_radio_button_delegate(auto &&value, auto &&...args) noexcept
Make a shared pointer to a toggle-button delegate.
Definition radio_button_delegate.hpp:113
@ partial
A widget is partially enabled.
Definition widget_mode.hpp:67
@ invisible
The widget is invisible.
Definition widget_mode.hpp:35
geometry/margins.hpp
Definition cache.hpp:11
The HikoGUI API version 1.
Definition cache.hpp:11
@ inside
The border is drawn inside the edge of a quad.
Definition widget_draw_context.hpp:29
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition utility.hpp:212
auto theme
A tagged global variable to a theme model for a widget's component.
Definition theme_model.hpp:545
virtual void request_redraw() const noexcept
Request the widget to be redrawn on the next frame.
Definition widget.hpp:227
virtual bool is_tab_button() const noexcept
Check if this widget is a tab-button.
Definition widget.hpp:482
widget * parent
Pointer to the parent widget.
Definition widget.hpp:40
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:49
observer< bool > focus
The widget has keyboard focus.
Definition widget.hpp:61
2D constraints.
Definition box_constraints.hpp:22
observer< hi::alignment > alignment
Definition abstract_button_widget.hpp:58
std::shared_ptr< delegate_type > delegate
Definition abstract_button_widget.hpp:42
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