HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
widget_delegate.hpp
1
2
3
4#pragma once
5
6#include "../dispatch/dispatch.hpp"
7#include "../utility/utility.hpp"
8#include "../GUI/GUI.hpp"
9
10namespace hi { inline namespace v1 {
11
13 using notifier_type = notifier<void()>;
14 using callback_type = notifier_type::callback_type;
15
16 notifier_type _notifier;
17
18 virtual ~widget_delegate() = default;
19
22 virtual void init(widget_intf const& sender) noexcept {}
23
26 virtual void deinit(widget_intf const& sender) noexcept {}
27
28
31 template<forward_of<void()> Func>
32 [[nodiscard]] callback_type subscribe(Func&& func, callback_flags flags = callback_flags::synchronous) noexcept
33 {
34 return _notifier.subscribe(std::forward<Func>(func), flags);
35 }
36};
37
38}}
39
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 widget_intf.hpp:24
Definition widget_delegate.hpp:12
virtual void init(widget_intf const &sender) noexcept
This function is called when a widget takes ownership of a delegate.
Definition widget_delegate.hpp:22
callback_type subscribe(Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
Subscribe a callback for notifying the widget of a data change.
Definition widget_delegate.hpp:32
virtual void deinit(widget_intf const &sender) noexcept
This function is called when a widget drops ownership of a delegate.
Definition widget_delegate.hpp:26