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;
78 [[nodiscard]] generator<widget *> children() const noexcept
override
80 co_yield _on_label_widget.get();
81 co_yield _off_label_widget.get();
82 co_yield _other_label_widget.get();
85 [[nodiscard]] color background_color() const noexcept override;
86 [[nodiscard]] hitbox hitbox_test(point3 position) const noexcept final;
87 [[nodiscard]]
bool accepts_keyboard_focus(keyboard_focus_group group) const noexcept override;
88 void activate() noexcept;
89 bool handle_event(
gui_event const& event) noexcept override;
92 aarectangle _label_rectangle;
97 bool _pressed = false;
98 notifier<>::callback_token _delegate_cbt;
101 void set_attributes() noexcept
106 void set_attributes(button_widget_attribute
auto&& first, button_widget_attribute
auto&&...rest)
noexcept
108 if constexpr (forward_of<
decltype(first), observer<hi::label>>) {
109 if constexpr (I == 0) {
113 }
else if constexpr (I == 1) {
117 }
else if constexpr (I == 2) {
124 }
else if constexpr (forward_of<
decltype(first), observer<hi::alignment>>) {
128 }
else if constexpr (forward_of<
decltype(first), observer<hi::semantic_text_style>>) {
137 widget_constraints set_constraints_button(set_constraints_context
const &context)
const noexcept;
138 void set_layout_button(widget_layout
const& context)
noexcept;
139 void draw_button(draw_context
const& context)
noexcept;
#define hi_axiom(expression)
Specify an axiom; an expression that is true.
Definition assert.hpp:133
#define hi_assert_not_null(x)
Assert if an expression is not nullptr.
Definition assert.hpp:118
#define hi_static_no_default()
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:172
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition utility.hpp:29
Defines button_delegate and some default button delegates.
button_state
The state of a button.
Definition button_delegate.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
The HikoGUI namespace.
Definition ascii.hpp:19
A user interface event.
Definition gui_event.hpp:76
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:41
An interactive graphical object as part of the user-interface.
Definition widget.hpp:45
widget(widget *parent) noexcept
widget * parent
Pointer to the parent widget.
Definition widget.hpp:50
Definition abstract_button_widget.hpp:26
Definition label_widget.hpp:25