12#include "../macros.hpp"
14namespace hi {
inline namespace v1 {
49 using super = abstract_button_widget;
50 using delegate_type =
typename super::delegate_type;
68 set_attributes<0>(hi_forward(attributes)...);
93 hi_forward(attributes)...)
115 hilet extra_size =
extent2{theme().margin<
float>() * 2.0f, theme().margin<
float>()};
116 return _label_constraints + extra_size;
119 void set_layout(widget_layout
const& context)
noexcept override
122 hilet label_rectangle = aarectangle{
123 theme().margin<
float>(),
125 context.width() - theme().margin<
float>() * 2.0f,
126 context.height() - theme().margin<
float>()};
127 _on_label_shape = _off_label_shape = _other_label_shape =
128 box_shape{_label_constraints, label_rectangle, theme().baseline_adjustment()};
130 super::set_layout(context);
133 void draw(draw_context
const& context)
noexcept override
136 draw_toolbar_tab_button(context);
137 draw_button(context);
141 [[nodiscard]]
bool accepts_keyboard_focus(keyboard_focus_group group)
const noexcept override
147 box_constraints _label_constraints;
149 void draw_toolbar_tab_button(draw_context
const& context)
noexcept
153 hilet offset = theme().margin<
float>() + theme().border_width();
154 hilet outline_rectangle = aarectangle{0, -offset,
layout().width(),
layout().height() + offset};
157 hilet button_z = *
focus ? translate_z(0.6f) : translate_z(0.0f);
165 hilet corner_radii = hi::corner_radii(0.0f, 0.0f, theme().rounding_radius<float>(), theme().rounding_radius<float>());
169 button_z * outline_rectangle,
171 *
focus ? focus_color() : button_color,
172 theme().border_width(),
Defines abstract_button_widget.
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:227
@ on
The 'on' state of a button.
Definition button_delegate.hpp:30
@ partial
A widget is partially enabled.
Definition widget_mode.hpp:68
@ invisible
The widget is invisible.
Definition widget_mode.hpp:36
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
@ inside
The border is drawn inside the edge of a quad.
Definition draw_context.hpp:34
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:56
A high-level geometric extent.
Definition extent2.hpp:29
virtual void request_redraw() const noexcept=0
Request the widget to be redrawn on the next frame.
widget_intf * parent
Pointer to the parent widget.
Definition widget_intf.hpp:28
virtual box_constraints update_constraints() noexcept=0
Update the constraints of the widget.
2D constraints.
Definition box_constraints.hpp:25
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 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
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
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
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
int semantic_layer
The draw layer of the widget.
Definition widget.hpp:66
observer< bool > hover
Mouse cursor is hovering over the widget.
Definition widget.hpp:46
box_constraints update_constraints() noexcept override
Update the constraints of the widget.
Definition widget.hpp:158
observer< widget_mode > mode
The widget mode.
Definition widget.hpp:42
observer< bool > focus
The widget has keyboard focus.
Definition widget.hpp:50
Definition concepts.hpp:54
True if T is a forwarded type of Forward.
Definition concepts.hpp:131
Definition abstract_button_widget.hpp:27