Reactive binding between a UI widget and an arbitrary external value source, interface-compatible with state::Binding but backed by getter/setter lambdas instead of a StateStore parameter.
More...
#include <external_binding.hpp>
|
| | ExternalBinding ()=default |
| | ExternalBinding (ExternalBindingConfig cfg) |
| float | get () const |
| | Read the current plain value.
|
| void | set (float value) |
| | Write a new plain value.
|
| float | get_normalized () const |
| | Read the value mapped to [0, 1] through the configured range.
|
| void | set_normalized (float normalized) |
| | Write from a normalized [0, 1] value through the configured range.
|
| void | begin_gesture () |
| | Notify the host that a user gesture has begun / ended (optional).
|
| void | end_gesture () |
| void | on_change (ChangeCallback cb) |
| | Register a callback that fires when the value changes via set/poll/notify.
|
| bool | poll () |
| | Poll the source; fire on_change if it moved since the last observation.
|
| void | notify () |
| | UI-thread accelerator: the host knows the external value changed and wants an immediate refresh without waiting for the next poll().
|
| void | reset () |
| | Reset to the range's default value and fire change callbacks.
|
| const std::string & | name () const |
| const std::string & | unit () const |
| const ParamRange & | range () const |
| bool | is_bound () const |
| | True if a getter is configured (an unbound ExternalBinding reads 0).
|
Reactive binding between a UI widget and an arbitrary external value source, interface-compatible with state::Binding but backed by getter/setter lambdas instead of a StateStore parameter.
This is a SEPARATE type, not a base/override of Binding: the StateStore path (state::Binding) stays direct and vtable-free, paying nothing for this flexibility. Widgets bind to either via the param_attachment overloads.
Change notification: poll() reads the getter and fires on_change when the value moved — the fallback for a source with no listener list. A host that KNOWS when the external value changed may call notify() for an immediate refresh, but poll() remains the safety net (a host may forget to notify).
- Note
- Thread safety: get/set/poll/notify and the getter/setter callbacks run on the UI thread only. Any host-owned state they touch is the host's responsibility. These are NOT audio-thread APIs. Modulation is not modeled (a plain external value has no mod offset).
◆ ChangeCallback
◆ ExternalBinding() [1/2]
| pulp::state::ExternalBinding::ExternalBinding |
( |
| ) |
|
|
default |
◆ ExternalBinding() [2/2]
◆ begin_gesture()
| void pulp::state::ExternalBinding::begin_gesture |
( |
| ) |
|
|
inline |
Notify the host that a user gesture has begun / ended (optional).
◆ end_gesture()
| void pulp::state::ExternalBinding::end_gesture |
( |
| ) |
|
|
inline |
◆ get()
| float pulp::state::ExternalBinding::get |
( |
| ) |
const |
|
inline |
Read the current plain value.
◆ get_normalized()
| float pulp::state::ExternalBinding::get_normalized |
( |
| ) |
const |
|
inline |
Read the value mapped to [0, 1] through the configured range.
◆ is_bound()
| bool pulp::state::ExternalBinding::is_bound |
( |
| ) |
const |
|
inline |
◆ name()
| const std::string & pulp::state::ExternalBinding::name |
( |
| ) |
const |
|
inline |
◆ notify()
| void pulp::state::ExternalBinding::notify |
( |
| ) |
|
|
inline |
UI-thread accelerator: the host knows the external value changed and wants an immediate refresh without waiting for the next poll().
◆ on_change()
Register a callback that fires when the value changes via set/poll/notify.
◆ poll()
| bool pulp::state::ExternalBinding::poll |
( |
| ) |
|
|
inline |
Poll the source; fire on_change if it moved since the last observation.
Fallback for external sources without their own change signal.
◆ range()
| const ParamRange & pulp::state::ExternalBinding::range |
( |
| ) |
const |
|
inline |
◆ reset()
| void pulp::state::ExternalBinding::reset |
( |
| ) |
|
|
inline |
Reset to the range's default value and fire change callbacks.
◆ set()
| void pulp::state::ExternalBinding::set |
( |
float | value | ) |
|
|
inline |
Write a new plain value.
Fires change callbacks if the value actually changed (the source may re-clamp/quantize, so we re-read afterwards).
◆ set_normalized()
| void pulp::state::ExternalBinding::set_normalized |
( |
float | normalized | ) |
|
|
inline |
Write from a normalized [0, 1] value through the configured range.
◆ unit()
| const std::string & pulp::state::ExternalBinding::unit |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: