This class acts as a wrapper around a property inside a ValueTree. More...
#include <juce_ValueTreePropertyWithDefault.h>
Classes | |
class | SynchronousValueSource |
Public Member Functions | |
ValueTreePropertyWithDefault ()=default | |
Creates an uninitialised ValueTreePropertyWithDefault object. More... | |
ValueTreePropertyWithDefault (const ValueTreePropertyWithDefault &other) | |
Creates a ValueTreePropertyWithDefault object from another ValueTreePropertyWithDefault object. More... | |
ValueTreePropertyWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um) | |
Creates a ValueTreePropertyWithDefault object for the specified property. More... | |
ValueTreePropertyWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um, var defaultToUse) | |
Creates an ValueTreePropertyWithDefault object for the specified property. More... | |
ValueTreePropertyWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um, var defaultToUse, StringRef arrayDelimiter) | |
Creates a ValueTreePropertyWithDefault object for the specified property. More... | |
~ValueTreePropertyWithDefault () override | |
Destructor. More... | |
var | get () const noexcept |
Returns the current value of the property. More... | |
var | getDefault () const |
Returns the current default value. More... | |
Value | getPropertyAsValue () |
Returns the current property as a Value object. More... | |
Identifier & | getPropertyID () noexcept |
Returns the property ID of the referenced property. More... | |
UndoManager * | getUndoManager () noexcept |
Returns the UndoManager that is being used. More... | |
ValueTree & | getValueTree () noexcept |
Returns a reference to the ValueTree containing the referenced property. More... | |
bool | isUsingDefault () const |
Returns true if the property does not exist in the referenced ValueTree. More... | |
ValueTreePropertyWithDefault & | operator= (const ValueTreePropertyWithDefault &other) |
ValueTreePropertyWithDefault & | operator= (const var &newValue) |
Sets the property and returns the new ValueTreePropertyWithDefault. More... | |
void | referTo (ValueTree tree, const Identifier &property, UndoManager *um) |
Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree. More... | |
void | referTo (ValueTree tree, const Identifier &property, UndoManager *um, var defaultVal) |
Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree. More... | |
void | referTo (ValueTree tree, const Identifier &property, UndoManager *um, var defaultVal, StringRef arrayDelimiter) |
Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree. More... | |
void | resetToDefault () noexcept |
Removes the property from the referenced ValueTree. More... | |
void | setDefault (const var &newDefault) |
Sets the default value to a new var. More... | |
void | setValue (const var &newValue, UndoManager *undoManagerToUse) |
Sets the property. More... | |
Public Attributes | |
std::function< void()> | onDefaultChange |
You can assign a lambda to this callback and it will called when the default value is changed. More... | |
Private Member Functions | |
void | referToWithDefault (ValueTree v, const Identifier &i, UndoManager *um, const Value &defaultVal, StringRef del) |
void | valueChanged (Value &) override |
Called when a Value object is changed. More... | |
Static Private Member Functions | |
static Array< var > | delimitedStringToVarArray (StringRef input, StringRef delim) |
static String | varArrayToDelimitedString (const Array< var > &input, StringRef delim) |
Private Attributes | |
Value | defaultValue |
String | delimiter |
Identifier | targetProperty |
ValueTree | targetTree |
UndoManager * | undoManager = nullptr |
This class acts as a wrapper around a property inside a ValueTree.
If the property inside the ValueTree is missing it will return a default value, which can be specified in the constructor or by calling setDefault().
@tags{DataStructures}
|
default |
Creates an uninitialised ValueTreePropertyWithDefault object.
Initialise it using one of the referTo() methods.
|
inline |
Creates a ValueTreePropertyWithDefault object for the specified property.
The default value will be an empty var.
References juce::tree.
|
inline |
Creates an ValueTreePropertyWithDefault object for the specified property.
The default value will be defaultToUse.
References juce::tree.
|
inline |
Creates a ValueTreePropertyWithDefault object for the specified property.
The default value will be defaultToUse.
Use this constructor if the underlying var object being controlled is an array and it will handle the conversion to/from a delimited String that can be written to XML format.
References juce::tree.
|
inline |
Creates a ValueTreePropertyWithDefault object from another ValueTreePropertyWithDefault object.
References defaultValue, delimiter, targetProperty, targetTree, and undoManager.
|
inlineoverride |
Destructor.
|
inlinenoexcept |
Returns the current value of the property.
If the property does not exist this returns the default value.
|
inline |
Returns the current default value.
|
inline |
Returns the current property as a Value object.
|
inlinenoexcept |
Returns the property ID of the referenced property.
|
inlinenoexcept |
Returns the UndoManager that is being used.
|
inlinenoexcept |
Returns a reference to the ValueTree containing the referenced property.
|
inline |
Returns true if the property does not exist in the referenced ValueTree.
|
inline |
References defaultValue, delimiter, targetProperty, targetTree, and undoManager.
|
inline |
Sets the property and returns the new ValueTreePropertyWithDefault.
This will modify the property in the referenced ValueTree.
|
inline |
Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.
The default value will be an empty var.
References juce::tree.
|
inline |
Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.
The default value will be defaultVal.
References juce::tree.
|
inline |
Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.
The default value will be defaultVal.
References juce::tree.
|
inlineprivate |
References juce::StandardApplicationCommandIDs::del, and juce::gl::v.
|
inlinenoexcept |
Removes the property from the referenced ValueTree.
|
inline |
Sets the default value to a new var.
|
inline |
Sets the property.
This will modify the property in the referenced ValueTree.
References juce::gl::array, and juce::var::getArray().
|
inlineoverrideprivatevirtual |
Called when a Value object is changed.
Note that the Value object passed as a parameter may not be exactly the same object that you registered the listener with - it might be a copy that refers to the same underlying ValueSource. To find out, you can call Value::refersToSameSourceAs().
Implements juce::Value::Listener.
|
private |
Referenced by operator=(), and ValueTreePropertyWithDefault().
|
private |
Referenced by operator=(), and ValueTreePropertyWithDefault().
std::function<void()> juce::ValueTreePropertyWithDefault::onDefaultChange |
You can assign a lambda to this callback and it will called when the default value is changed.
|
private |
Referenced by operator=(), and ValueTreePropertyWithDefault().
|
private |
Referenced by operator=(), and ValueTreePropertyWithDefault().
|
private |
Referenced by operator=(), and ValueTreePropertyWithDefault().