|
HikoGUI
A low latency retained GUI
|
#include <ttauri/detail/observable_base.hpp>
Public Types | |
| using | value_type = T |
| using | notifier_type = notifier<void()> |
| using | callback_type = typename notifier_type::callback_type |
| using | callback_ptr_type = typename notifier_type::callback_ptr_type |
| using | time_point = typename hires_utc_clock::time_point |
| using | duration = typename hires_utc_clock::duration |
Public Member Functions | |
| observable_base (observable_base const &)=delete | |
| observable_base (observable_base &&)=delete | |
| observable_base & | operator= (observable_base const &)=delete |
| observable_base & | operator= (observable_base &&)=delete |
| observable_base () noexcept | |
| Constructor. | |
| value_type | previous_value () const noexcept |
| Get the previous value. | |
| time_point | time_when_last_modified () const noexcept |
| Time when the value was modified last. | |
| duration | duration_since_last_modified () const noexcept |
| Duration since the value was last modified. | |
| float | animation_progress (duration animation_duration) const noexcept |
| The relative time since the start of the animation. | |
| virtual value_type | load () const noexcept=0 |
| Get the current value. | |
| value_type | load (duration animation_duration) const noexcept |
| Get the current value animated over the animation_duration. | |
| virtual bool | store (value_type const &new_value) noexcept=0 |
| Set the value. | |
| template<typename Callback > | |
| callback_ptr_type | subscribe (Callback &&callback) noexcept |
| Add a callback as a listener. | |
| void | unsubscribe (callback_ptr_type callback_ptr) noexcept |
| Remove a callback. | |
Observable abstract base class.
Objects of the observable_base class will notify listeners through callbacks of changes of its value.
This class does not hold the value itself, concrete subclasses will either hold the value or calculate the value on demand. In many cases concrete subclasses may be sub-expressions of other observable objects.
This object will also track the time when the value was last modified so that the value can be animated. Usefull when displaying the value as an animated graphic element. For calculating inbetween values it will keep track of the previous value.
|
inlinenoexcept |
Constructor.
|
inlinenoexcept |
The relative time since the start of the animation.
The relative time since the start of the animation according to the duration of the animation.
| animation_duration | A relative value between 0.0 and 1.0. |
|
inlinenoexcept |
Duration since the value was last modified.
|
pure virtualnoexcept |
Get the current value.
The value is often calculated directly from the cached values retrieved from notifications down the chain.
Implemented in tt::detail::observable_not< OT >, and tt::detail::observable_value< T >.
|
inlinenoexcept |
Get the current value animated over the animation_duration.
|
inlinenoexcept |
Get the previous value.
|
pure virtualnoexcept |
Set the value.
The value is often not directly stored, but instead forwarded up the chain of observables. And then let the notifications flowing backward updated the cached values so that loads() will be quick.
| new_value | The new value |
Implemented in tt::detail::observable_value< T >.
|
inlinenoexcept |
Add a callback as a listener.
| callback | The callback to register, the new value is passed as the first argument. |
|
inlinenoexcept |
Time when the value was modified last.
|
inlinenoexcept |
Remove a callback.
| callback_ptr | The shared callback pointer returned by the add_callback() method. |