62template <
typename Type>
123 template <
typename OtherType>
129 template <
typename OtherType>
162 void setDefault (
const Type& value) { defaultValue = value; }
201 Type getTypedValue()
const;
205 void valueTreeChildRemoved (ValueTree&, ValueTree&,
int)
override {}
206 void valueTreeChildOrderChanged (ValueTree&,
int,
int)
override {}
207 void valueTreeParentChanged (ValueTree&)
override {}
216template <
typename Type>
219template <
typename Type>
221 : targetTree (
v), targetProperty (i), undoManager (
um),
222 defaultValue(), cachedValue (getTypedValue())
227template <
typename Type>
229 : targetTree (
v), targetProperty (i), undoManager (
um),
230 defaultValue (
defaultToUse), cachedValue (getTypedValue())
235template <
typename Type>
238 return targetTree.getPropertyAsValue (targetProperty, undoManager);
241template <
typename Type>
244 return ! targetTree.hasProperty (targetProperty);
247template <
typename Type>
250 setValue (newValue, undoManager);
254template <
typename Type>
257 if (cachedValue != newValue || isUsingDefault())
259 cachedValue = newValue;
264template <
typename Type>
267 resetToDefault (undoManager);
270template <
typename Type>
274 forceUpdateOfCachedValue();
277template <
typename Type>
280 referToWithDefault (
v, i,
um, Type());
283template <
typename Type>
289template <
typename Type>
292 cachedValue = getTypedValue();
295template <
typename Type>
298 targetTree.removeListener (
this);
303 cachedValue = getTypedValue();
304 targetTree.addListener (
this);
307template <
typename Type>
308inline Type CachedValue<Type>::getTypedValue()
const
310 if (
const var* property = targetTree.getPropertyPointer (targetProperty))
311 return VariantConverter<Type>::fromVar (*property);
316template <
typename Type>
317inline void CachedValue<Type>::valueTreePropertyChanged (ValueTree& changedTree,
const Identifier& changedProperty)
320 forceUpdateOfCachedValue();
Holds a resizable array of primitive or copy-by-value objects.
Array()=default
Creates an empty array.
This class acts as a typed wrapper around a property inside a ValueTree.
bool isUsingDefault() const
Returns true if the current property does not exist and the CachedValue is using the fallback default...
Type * operator->() noexcept
Dereference operator.
Type getDefault() const
Returns the current fallback default value.
CachedValue()
Default constructor.
ValueTree & getValueTree() noexcept
Returns a reference to the ValueTree containing the referenced property.
const Identifier & getPropertyID() const noexcept
Returns the property ID of the referenced property.
CachedValue & operator=(const Type &newValue)
Sets the property.
void forceUpdateOfCachedValue()
Force an update in case the referenced property has been changed from elsewhere.
void setValue(const Type &newValue, UndoManager *undoManagerToUse)
Sets the property.
UndoManager * getUndoManager() noexcept
Returns the UndoManager that is being used.
void resetToDefault()
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback defa...
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
Makes the CachedValue refer to the specified property inside the given ValueTree.
Value getPropertyAsValue()
Returns the current property as a Value object.
bool operator==(const OtherType &other) const
Returns true if the current value of the property (or the fallback value) is equal to other.
void setDefault(const Type &value)
Resets the fallback default value.
bool operator!=(const OtherType &other) const
Returns true if the current value of the property (or the fallback value) is not equal to other.
Type get() const noexcept
Returns the current value of the property.
Type & operator*() noexcept
Dereference operator.
Represents a string identifier, designed for accessing properties by name.
Manages a list of undo/redo commands.
Listener class for events that happen to a ValueTree.
A powerful tree structure that can be used to hold free-form data, and which can handle its own undo ...
void addListener(Listener *listener)
Adds a listener to receive callbacks when this tree is changed in some way.
Represents a shared variant value.
This template-overloaded class can be used to convert between var and custom types.