4#include "../dispatch/dispatch.hpp"
5#include "../observer/observer.hpp"
6#include "../GUI/GUI.hpp"
7#include "../utility/utility.hpp"
9hi_export_module(hikogui.widgets.radio_delegate);
11hi_export
namespace hi {
inline namespace v1 {
32 return widget_value::off;
37 template<forward_of<
void()> Func>
40 return _notifier.subscribe(std::forward<Func>(
func), flags);
44 notifier<
void()> _notifier;
55template<std::equality_comparable T>
68 template<forward_of<observer<value_type>> Value, forward_of<observer<value_type>> OnValue>
72 value(std::forward<Value>(value)), on_value(std::forward<OnValue>(on_value))
75 _value_cbt = this->value.
subscribe([&](
auto...){ this->_notifier(); });
76 _on_value_cbt = this->on_value.
subscribe([&](
auto...){ this->_notifier(); });
83 if (*value == *on_value) {
84 return widget_value::on;
86 return widget_value::off;
90 void activate(widget_intf
const&
sender)
noexcept override
96 callback<
void(value_type)> _value_cbt;
97 callback<
void(value_type)> _on_value_cbt;
100template<
typename Value,
typename OnValue>
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
The HikoGUI namespace.
Definition recursive_iterator.hpp:15
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:378
Definition callback.hpp:77
Definition widget_intf.hpp:24
A observer pointing to the whole or part of a observed_base.
Definition observer_intf.hpp:32
callback< void(value_type)> subscribe(Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
Subscribe a callback to this observer.
Definition observer_intf.hpp:456
A radio delegate controls the state of a radio button widget.
Definition radio_delegate.hpp:16
virtual widget_value state(widget_intf const &sender) const noexcept
Used by the widget to check the state of the button.
Definition radio_delegate.hpp:30
callback< void()> subscribe(Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
Subscribe a callback for notifying the widget of a data change.
Definition radio_delegate.hpp:38
virtual void activate(widget_intf const &sender) noexcept
Called when the button is pressed by the user.
Definition radio_delegate.hpp:26
A default radio button delegate.
Definition radio_delegate.hpp:56
default_radio_delegate(Value &&value, OnValue &&on_value) noexcept
Construct a delegate.
Definition radio_delegate.hpp:69