12#include "../macros.hpp"
14hi_export_module(hikogui.widgets.momentary_button_widget);
16hi_export
namespace hi {
inline namespace v1 {
23 using super = abstract_button_widget;
24 using delegate_type =
typename super::delegate_type;
26 template<button_widget_attribute... Attributes>
29 Attributes&&...attributes) noexcept :
36 template<button_widget_attribute... Attributes>
48 auto const extra_size =
extent2{theme().margin<
float>() * 2.0f, theme().margin<
float>() * 2.0f};
50 auto constraints = _label_constraints + extra_size;
51 constraints.margins = theme().margin();
54 void set_layout(
widget_layout const& context)
noexcept override
57 auto const label_rectangle =
58 aarectangle{theme().margin<
float>(), 0.0f, context.width() - theme().margin<
float>() * 2.0f, context.height()};
59 _on_label_shape = _off_label_shape = _other_label_shape =
60 box_shape{_label_constraints, label_rectangle, theme().baseline_adjustment()};
67 draw_label_button(context);
75 void draw_label_button(
draw_context const& context)
noexcept
83 theme().border_width(),
85 theme().rounding_radius());
Defines abstract_button_widget.
@ rectangle
The gui_event has rectangle data.
Definition gui_event_variant.hpp:44
@ invisible
The widget is invisible.
Definition widget_state.hpp:41
The HikoGUI namespace.
Definition array_generic.hpp:21
The HikoGUI API version 1.
Definition array_generic.hpp:22
@ inside
The border is drawn inside the edge of a quad.
Definition draw_context_intf.hpp:35
bool compare_store(T &lhs, U &&rhs) noexcept
Compare then store if there was a change.
Definition misc.hpp:53
Class which represents an axis-aligned rectangle.
Definition aarectangle.hpp:33
A high-level geometric extent.
Definition extent2.hpp:32
Draw context for drawing using the HikoGUI shaders.
Definition draw_context_intf.hpp:209
widget_layout const & layout() const noexcept
Get the current layout for this widget.
Definition widget_intf.hpp:241
virtual box_constraints update_constraints() noexcept=0
Update the constraints of the widget.
The layout of a widget.
Definition widget_layout.hpp:56
2D constraints.
Definition box_constraints.hpp:25
Definition box_shape.hpp:18
std::shared_ptr< delegate_type > delegate
The delegate that controls the button widget.
Definition abstract_button_widget.hpp:43
observer< alignment > alignment
The alignment of the button and on/off/other label.
Definition abstract_button_widget.hpp:59
A momentary button widget.
Definition momentary_button_widget.hpp:21
void set_layout(widget_layout const &context) noexcept override
Update the internal layout of the widget.
Definition widget.hpp:116
void draw(draw_context const &context) noexcept override
Draw the widget.
Definition widget.hpp:121
box_constraints update_constraints() noexcept override
Update the constraints of the widget.
Definition widget.hpp:110