JUCE
|
This class acts as a wrapper around a property inside a ValueTree. More...
Public Member Functions | |
ValueWithDefault () | |
Creates an unitialised ValueWithDefault. More... | |
ValueWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um) | |
Creates an ValueWithDefault object. More... | |
ValueWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um, const var &defaultToUse) | |
Creates an ValueWithDefault object. More... | |
ValueWithDefault (const ValueWithDefault &other) | |
Creates a ValueWithDefault object from another ValueWithDefault object. More... | |
var | get () const noexcept |
Returns the current value of the property. More... | |
Value | getPropertyAsValue () |
Returns the current property as a Value object. More... | |
var | getDefault () const |
Returns the current default value. More... | |
void | setDefault (const var &newDefault) |
Sets the default value to a new var. More... | |
bool | isUsingDefault () const |
Returns true if the property does not exist or is empty. More... | |
void | resetToDefault () noexcept |
Resets the property to an empty var. More... | |
ValueWithDefault & | operator= (const var &newValue) |
Sets the property and returns the new ValueWithDefault. More... | |
void | setValue (const var &newValue, UndoManager *undoManagerToUse) |
Sets the property. More... | |
void | referTo (ValueTree &tree, const Identifier &property, UndoManager *um) |
Makes the ValueWithDefault refer to the specified property inside the given ValueTree. More... | |
void | referTo (ValueTree &tree, const Identifier &property, UndoManager *um, const var &defaultVal) |
Makes the ValueWithDefault refer to the specified property inside the given ValueTree, and specifies a default value to use. More... | |
ValueTree & | getValueTree () noexcept |
Returns a reference to the ValueTree containing the referenced property. More... | |
Identifier & | getPropertyID () noexcept |
Returns the property ID of the referenced property. More... | |
This class acts as a wrapper around a property inside a ValueTree.
If the property inside the ValueTree is missing or empty the ValueWithDefault will automatically return a default value, which can be specified when initialising the ValueWithDefault.
juce::ValueWithDefault::ValueWithDefault | ( | ) |
Creates an unitialised ValueWithDefault.
Initialise it using one of the referTo() methods.
juce::ValueWithDefault::ValueWithDefault | ( | ValueTree & | tree, |
const Identifier & | propertyID, | ||
UndoManager * | um | ||
) |
Creates an ValueWithDefault object.
The default value will be an empty var.
juce::ValueWithDefault::ValueWithDefault | ( | ValueTree & | tree, |
const Identifier & | propertyID, | ||
UndoManager * | um, | ||
const var & | defaultToUse | ||
) |
Creates an ValueWithDefault object.
The default value will be defaultToUse.
juce::ValueWithDefault::ValueWithDefault | ( | const ValueWithDefault & | other | ) |
Creates a ValueWithDefault object from another ValueWithDefault object.
|
noexcept |
Returns the current value of the property.
If the property does not exist or is empty, returns the default value.
References isUsingDefault().
Value juce::ValueWithDefault::getPropertyAsValue | ( | ) |
Returns the current property as a Value object.
References juce::ValueTree::getPropertyAsValue().
var juce::ValueWithDefault::getDefault | ( | ) | const |
Returns the current default value.
void juce::ValueWithDefault::setDefault | ( | const var & | newDefault | ) |
Sets the default value to a new var.
bool juce::ValueWithDefault::isUsingDefault | ( | ) | const |
Returns true if the property does not exist or is empty.
References juce::ValueTree::hasProperty().
Referenced by get().
|
noexcept |
Resets the property to an empty var.
References juce::ValueTree::removeProperty().
ValueWithDefault& juce::ValueWithDefault::operator= | ( | const var & | newValue | ) |
Sets the property and returns the new ValueWithDefault.
This will modify the property in the referenced ValueTree.
References setValue().
void juce::ValueWithDefault::setValue | ( | const var & | newValue, |
UndoManager * | undoManagerToUse | ||
) |
Sets the property.
This will actually modify the property in the referenced ValueTree.
References juce::ValueTree::setProperty().
Referenced by operator=().
void juce::ValueWithDefault::referTo | ( | ValueTree & | tree, |
const Identifier & | property, | ||
UndoManager * | um | ||
) |
Makes the ValueWithDefault refer to the specified property inside the given ValueTree.
void juce::ValueWithDefault::referTo | ( | ValueTree & | tree, |
const Identifier & | property, | ||
UndoManager * | um, | ||
const var & | defaultVal | ||
) |
Makes the ValueWithDefault refer to the specified property inside the given ValueTree, and specifies a default value to use.
|
noexcept |
Returns a reference to the ValueTree containing the referenced property.
|
noexcept |
Returns the property ID of the referenced property.