62 template <
typename Type>
97 UndoManager* undoManager,
const Type& defaultToUse);
105 operator Type() const noexcept {
return cachedValue; }
110 Type
get()
const noexcept {
return cachedValue; }
123 template <
typename OtherType>
124 bool operator== (
const OtherType& other)
const {
return cachedValue == other; }
129 template <
typename OtherType>
130 bool operator!= (
const OtherType& other)
const {
return cachedValue != other; }
162 void setDefault (
const Type& value) { defaultValue = value; }
201 Type getTypedValue()
const;
203 void valueTreePropertyChanged (
ValueTree& changedTree,
const Identifier& changedProperty)
override;
206 void valueTreeChildOrderChanged (
ValueTree&,
int,
int)
override {}
207 void valueTreeParentChanged (
ValueTree&)
override {}
216 template <
typename Type>
219 template <
typename Type>
221 : targetTree (v), targetProperty (i), undoManager (um),
222 defaultValue(), cachedValue (getTypedValue())
227 template <
typename Type>
229 : targetTree (v), targetProperty (i), undoManager (um),
230 defaultValue (defaultToUse), cachedValue (getTypedValue())
235 template <
typename Type>
241 template <
typename Type>
247 template <
typename Type>
254 template <
typename Type>
259 cachedValue = newValue;
264 template <
typename Type>
270 template <
typename Type>
277 template <
typename Type>
280 referToWithDefault (v, i, um, Type());
283 template <
typename Type>
286 referToWithDefault (v, i, um, defaultVal);
289 template <
typename Type>
292 cachedValue = getTypedValue();
295 template <
typename Type>
302 defaultValue = defaultVal;
303 cachedValue = getTypedValue();
307 template <
typename Type>
316 template <
typename Type>
319 if (changedProperty == targetProperty && targetTree == changedTree)
void setDefault(const Type &value)
Resets the fallback default value.
Type * operator->() noexcept
Dereference operator.
void addListener(Listener *listener)
Adds a listener to receive callbacks when this tree is changed in some way.
A powerful tree structure that can be used to hold free-form data, and which can handle its own undo ...
Value getPropertyAsValue()
Returns the current property as a Value object.
Value getPropertyAsValue(const Identifier &name, UndoManager *undoManager, bool shouldUpdateSynchronously=false)
Returns a Value object that can be used to control and respond to one of the tree's properties...
Represents a string identifier, designed for accessing properties by name.
CachedValue & operator=(const Type &newValue)
Sets the property.
A variant class, that can be used to hold a range of primitive values.
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
Makes the CachedValue refer to the specified property inside the given ValueTree. ...
void setValue(const Type &newValue, UndoManager *undoManagerToUse)
Sets the property.
bool isUsingDefault() const
Returns true if the current property does not exist and the CachedValue is using the fallback default...
void removeListener(Listener *listener)
Removes a listener that was previously added with addListener().
CachedValue()
Default constructor.
bool operator!=(const OtherType &other) const
Returns true if the current value of the property (or the fallback value) is not equal to other...
This class acts as a typed wrapper around a property inside a ValueTree.
Type & operator*() noexcept
Dereference operator.
const Identifier & getPropertyID() const noexcept
Returns the property ID of the referenced property.
ValueTree & setProperty(const Identifier &name, const var &newValue, UndoManager *undoManager)
Changes a named property of the tree.
Represents a shared variant value.
Type getDefault() const
Returns the current fallback default value.
ValueTree & getValueTree() noexcept
Returns a reference to the ValueTree containing the referenced property.
Listener class for events that happen to a ValueTree.
Manages a list of undo/redo commands.
const var * getPropertyPointer(const Identifier &name) const noexcept
Returns a pointer to the value of a named property, or nullptr if the property doesn't exist...
void resetToDefault()
Removes the property from the referenced ValueTree and makes the CachedValue return the fallback defa...
void removeProperty(const Identifier &name, UndoManager *undoManager)
Removes a property from the tree.
bool operator==(const OtherType &other) const
Returns true if the current value of the property (or the fallback value) is equal to other...
UndoManager * getUndoManager() noexcept
Returns the UndoManager that is being used.
This template-overloaded class can be used to convert between var and custom types.
bool hasProperty(const Identifier &name) const noexcept
Returns true if the tree contains a named property.
void forceUpdateOfCachedValue()
Force an update in case the referenced property has been changed from elsewhere.