14#include "../animator.hpp"
15#include "../i18n/translate.hpp"
16#include "../notifier.hpp"
23namespace hi {
inline namespace v1 {
25template<
typename Context>
59 observer<semantic_text_style>
text_style = semantic_text_style::label;
61 notifier<void()> pressed;
79 void set_layout(
widget_layout const &context) noexcept override;
80 [[nodiscard]] generator<
widget const &> children(
bool include_invisible) const noexcept
override
82 co_yield *_on_label_widget;
83 co_yield *_off_label_widget;
84 co_yield *_other_label_widget;
87 [[nodiscard]]
color background_color() const noexcept override;
88 [[nodiscard]] hitbox hitbox_test(point2i position) const noexcept final;
89 [[nodiscard]]
bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept override;
90 void activate() noexcept;
91 bool handle_event(
gui_event const& event) noexcept override;
106 bool _pressed = false;
107 notifier<>::callback_token _delegate_cbt;
110 void set_attributes() noexcept
115 void set_attributes(button_widget_attribute
auto&& first, button_widget_attribute
auto&&...rest)
noexcept
117 if constexpr (forward_of<
decltype(first), observer<hi::label>>) {
118 if constexpr (I == 0) {
122 }
else if constexpr (I == 1) {
126 }
else if constexpr (I == 2) {
133 }
else if constexpr (forward_of<
decltype(first), observer<hi::alignment>>) {
137 }
else if constexpr (forward_of<
decltype(first), observer<hi::semantic_text_style>>) {
146 void draw_button(draw_context
const& context)
noexcept;
Defines button_delegate and some default button delegates.
#define hi_static_no_default(...)
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:308
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:238
#define hi_assert_not_null(x,...)
Assert if an expression is not nullptr.
Definition assert.hpp:223
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
button_state
The state of a button.
Definition button_delegate.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
This is a RGBA floating point color.
Definition color.hpp:42
A user interface event.
Definition gui_event.hpp:74
2D constraints.
Definition box_constraints.hpp:22
Definition box_shape.hpp:15
Base class for implementing button widgets.
Definition abstract_button_widget.hpp:32
observer< semantic_text_style > text_style
The text style to button's label.
Definition abstract_button_widget.hpp:59
observer< label > other_label
The label to show when the button is in the 'other' state.
Definition abstract_button_widget.hpp:51
std::shared_ptr< delegate_type > delegate
The delegate that controls the button widget.
Definition abstract_button_widget.hpp:39
button_state state() const noexcept
Get the current state of the button.
Definition abstract_button_widget.hpp:70
observer< label > on_label
The label to show when the button is in the 'on' state.
Definition abstract_button_widget.hpp:43
observer< label > off_label
The label to show when the button is in the 'off' state.
Definition abstract_button_widget.hpp:47
observer< alignment > alignment
The alignment of the button and on/off/other label.
Definition abstract_button_widget.hpp:55
A button delegate controls the state of a button widget.
Definition button_delegate.hpp:45
The GUI widget displays and lays out text together with an icon.
Definition label_widget.hpp:42
An interactive graphical object as part of the user-interface.
Definition widget.hpp:46
widget(widget *parent) noexcept
widget * parent
Pointer to the parent widget.
Definition widget.hpp:51
The layout of a widget.
Definition widget_layout.hpp:38
Definition abstract_button_widget.hpp:26
Definition label_widget.hpp:26