A class to abstract away the issues around storing and retrieving a value from a ValueTree. Designed to make working with VT values more like working with regular class/struct members.
More...
|
| Value (Object &data, const juce::Identifier &id_, T initVal={}) |
| Construct a new Value object.
|
|
Value & | operator= (const T &val) |
| Assign a new value, setting it in the underlying tree and perhaps notifying listeners.
|
|
void | set (const T &val) |
| Set property value in the tree. If the onSet validator function has been configured, the val argument will be passed through that function (and possibly modified) before being stored into the tree.
|
|
| operator T () const |
| Get the current value of this property from the tree.
|
|
T | get () const |
| Get the current value of this property from the tree.
|
|
Cached | getCached () |
|
void | excludeListener (juce::ValueTree::Listener *listener) |
| A listener to exclude from property change updates.
|
|
void | onPropertyChange (PropertyUpdateFn callback) |
| Register (or clear) a callback function to execute when this value changes.
|
|
juce::Identifier | getId () const |
|
void | forceUpdate (bool shouldForceUpdate) |
| If passed true, any call that sets any Value property on this Object will result in a property change update callback being executed. Default (false) behavior only performs this callback when the underlying value is changed.
|
|
bool | shouldForceUpdate () const |
|
template<typename T>
class cello::Value< T >
A class to abstract away the issues around storing and retrieving a value from a ValueTree. Designed to make working with VT values more like working with regular class/struct members.
Data types to be stored as Values must:
- have an
operator !=
(so we can execute change callbacks)
- be supported by the
juce::var
type, or define a juce::VariantConverter
structure to round-trip through a juce::var
NOTE that we have a special case for floating point types – we compare the old and new versions of the value with a small epsilon value to let your code control how 'close' two floating point values must be to be considered equivalent. There's a static epsilon
member of this class that you can set as needed in your application; the default is 0.001.
- Template Parameters
-
T | Data type handled by this Value. |