OpenShot Library | libopenshot-audio
0.2.0
|
53 targetProperty (propertyID),
61 const var& defaultToUse)
63 targetProperty (propertyID),
65 defaultValue (defaultToUse)
78 targetProperty (propertyID),
80 defaultValue (defaultToUse),
81 delimiter (arrayDelimiter)
87 : targetTree (other.targetTree),
88 targetProperty (other.targetProperty),
89 undoManager (other.undoManager),
90 defaultValue (other.defaultValue),
91 delimiter (other.delimiter)
105 return delimitedStringToVarArray (targetTree[targetProperty].toString());
107 return targetTree[targetProperty];
119 if (defaultValue != newDefault)
121 defaultValue = newDefault;
154 if (
auto* array = newValue.
getArray())
155 targetTree.
setProperty (targetProperty, varArrayToDelimitedString (*array), undoManagerToUse);
157 targetTree.
setProperty (targetProperty, newValue, undoManagerToUse);
164 referToWithDefault (tree, property, um,
var(), {});
172 referToWithDefault (tree, property, um, defaultVal, {});
178 referToWithDefault (tree, property, um, defaultVal, arrayDelimiter);
194 referToWithDefault (other.targetTree, other.targetProperty, other.undoManager,
195 other.defaultValue, other.delimiter);
202 ValueTree targetTree;
203 Identifier targetProperty;
204 UndoManager* undoManager =
nullptr;
210 void referToWithDefault (
const ValueTree& v,
const Identifier& i, UndoManager* um,
211 const var& defaultVal, StringRef del)
216 defaultValue = defaultVal;
221 String varArrayToDelimitedString (
const Array<var>& input)
const noexcept
225 jassert (delimiter.isNotEmpty());
227 StringArray elements;
229 for (
auto& v : input)
230 elements.add (v.toString());
232 return elements.joinIntoString (delimiter);
235 Array<var> delimitedStringToVarArray (StringRef input)
const noexcept
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.
ValueWithDefault(ValueTree &tree, const Identifier &propertyID, UndoManager *um, const var &defaultToUse)
Creates an ValueWithDefault object.
ValueWithDefault()=default
Creates an unitialised ValueWithDefault.
A simple class for holding temporary references to a string literal or String.
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
Makes the ValueWithDefault refer to the specified property inside the given ValueTree.
Represents a shared variant value.
void setDefault(const var &newDefault)
Sets the default value to a new var.
Identifier & getPropertyID() noexcept
Returns the property ID of the referenced property.
bool hasProperty(const Identifier &name) const noexcept
Returns true if the tree contains a named property.
void removeProperty(const Identifier &name, UndoManager *undoManager)
Removes a property from the tree.
bool isUsingDefault() const
Returns true if the property does not exist in the referenced ValueTree.
Manages a list of undo/redo commands.
ValueTree & getValueTree() noexcept
Returns a reference to the ValueTree containing the referenced property.
static StringArray fromTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Returns an array containing the tokens in a given string.
ValueWithDefault(const ValueWithDefault &other)
Creates a ValueWithDefault object from another ValueWithDefault object.
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um, const var &defaultVal)
Makes the ValueWithDefault refer to the specified property inside the given ValueTree,...
var getDefault() const
Returns the current default value.
ValueTree & setProperty(const Identifier &name, const var &newValue, UndoManager *undoManager)
Changes a named property of the tree.
A variant class, that can be used to hold a range of primitive values.
std::function< void()> onDefaultChange
You can assign a lambda to this callback object to have it called when the default value is changed.
void resetToDefault() noexcept
Removes the property from the referenced ValueTree.
void setValue(const var &newValue, UndoManager *undoManagerToUse)
Sets the property.
Array< var > * getArray() const noexcept
If this variant holds an array, this provides access to it.
Represents a string identifier, designed for accessing properties by name.
ValueWithDefault & operator=(const var &newValue)
Sets the property and returns the new ValueWithDefault.
This class acts as a wrapper around a property inside a ValueTree.
ValueWithDefault(ValueTree &tree, const Identifier &propertyID, UndoManager *um, const var &defaultToUse, StringRef arrayDelimiter)
Creates an ValueWithDefault object.
bool isNotEmpty() const noexcept
Returns true if the string contains at least one character.
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.
var get() const noexcept
Returns the current value of the property.
UndoManager * getUndoManager() noexcept
Returns the UndoManager that is being used.
ValueWithDefault(ValueTree &tree, const Identifier &propertyID, UndoManager *um)
Creates an ValueWithDefault object.