Loading...
Searching...
No Matches
juce::ValueTreePropertyWithDefault Class Reference

Detailed Description

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().


The documentation for this class was generated from the following file:
Inheritance diagram for juce::ValueTreePropertyWithDefault:

Public Member Functions

 ValueTreePropertyWithDefault ()=default
 Creates an uninitialised ValueTreePropertyWithDefault object.
 ValueTreePropertyWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um)
 Creates a ValueTreePropertyWithDefault object for the specified property.
 ValueTreePropertyWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um, var defaultToUse)
 Creates an ValueTreePropertyWithDefault object for the specified property.
 ValueTreePropertyWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um, var defaultToUse, StringRef arrayDelimiter)
 Creates a ValueTreePropertyWithDefault object for the specified property.
 ValueTreePropertyWithDefault (const ValueTreePropertyWithDefault &other)
 Creates a ValueTreePropertyWithDefault object from another ValueTreePropertyWithDefault object.
 ~ValueTreePropertyWithDefault () override
 Destructor.
var get () const noexcept
 Returns the current value of the property.
Value getPropertyAsValue ()
 Returns the current property as a Value object.
var getDefault () const
 Returns the current default value.
void setDefault (const var &newDefault)
 Sets the default value to a new var.
bool isUsingDefault () const
 Returns true if the property does not exist in the referenced ValueTree.
void resetToDefault () noexcept
 Removes the property from the referenced ValueTree.
ValueTreePropertyWithDefaultoperator= (const var &newValue)
 Sets the property and returns the new ValueTreePropertyWithDefault.
void setValue (const var &newValue, UndoManager *undoManagerToUse)
 Sets the property.
void referTo (ValueTree tree, const Identifier &property, UndoManager *um)
 Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.
void referTo (ValueTree tree, const Identifier &property, UndoManager *um, var defaultVal)
 Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.
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.
ValueTreegetValueTree () noexcept
 Returns a reference to the ValueTree containing the referenced property.
IdentifiergetPropertyID () noexcept
 Returns the property ID of the referenced property.
const IdentifiergetPropertyID () const noexcept
 Returns the property ID of the referenced property.
UndoManagergetUndoManager () noexcept
 Returns the UndoManager that is being used.
ValueTreePropertyWithDefaultoperator= (const ValueTreePropertyWithDefault &other)

Public Attributes

std::function< void()> onDefaultChange
 You can assign a lambda to this callback and it will called when the default value is changed.

Constructors and Destructors

◆ ValueTreePropertyWithDefault() [1/5]

juce::ValueTreePropertyWithDefault::ValueTreePropertyWithDefault ( )
default

Creates an uninitialised ValueTreePropertyWithDefault object.

Initialise it using one of the referTo() methods.

Referenced by operator=(), operator=(), and ValueTreePropertyWithDefault().

◆ ValueTreePropertyWithDefault() [2/5]

juce::ValueTreePropertyWithDefault::ValueTreePropertyWithDefault ( ValueTree & tree,
const Identifier & propertyID,
UndoManager * um )
inline

Creates a ValueTreePropertyWithDefault object for the specified property.

The default value will be an empty var.

References referTo(), and juce::tree.

◆ ValueTreePropertyWithDefault() [3/5]

juce::ValueTreePropertyWithDefault::ValueTreePropertyWithDefault ( ValueTree & tree,
const Identifier & propertyID,
UndoManager * um,
var defaultToUse )
inline

Creates an ValueTreePropertyWithDefault object for the specified property.

The default value will be defaultToUse.

References referTo(), and juce::tree.

◆ ValueTreePropertyWithDefault() [4/5]

juce::ValueTreePropertyWithDefault::ValueTreePropertyWithDefault ( ValueTree & tree,
const Identifier & propertyID,
UndoManager * um,
var defaultToUse,
StringRef arrayDelimiter )
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 referTo(), and juce::tree.

◆ ValueTreePropertyWithDefault() [5/5]

juce::ValueTreePropertyWithDefault::ValueTreePropertyWithDefault ( const ValueTreePropertyWithDefault & other)
inline

◆ ~ValueTreePropertyWithDefault()

juce::ValueTreePropertyWithDefault::~ValueTreePropertyWithDefault ( )
inlineoverride

Destructor.

Member Functions

◆ get()

var juce::ValueTreePropertyWithDefault::get ( ) const
inlinenoexcept

Returns the current value of the property.

If the property does not exist this returns the default value.

References isUsingDefault().

◆ getPropertyAsValue()

Value juce::ValueTreePropertyWithDefault::getPropertyAsValue ( )
inline

Returns the current property as a Value object.

◆ getDefault()

var juce::ValueTreePropertyWithDefault::getDefault ( ) const
inline

Returns the current default value.

◆ setDefault()

void juce::ValueTreePropertyWithDefault::setDefault ( const var & newDefault)
inline

Sets the default value to a new var.

◆ isUsingDefault()

bool juce::ValueTreePropertyWithDefault::isUsingDefault ( ) const
inline

Returns true if the property does not exist in the referenced ValueTree.

Referenced by get().

◆ resetToDefault()

void juce::ValueTreePropertyWithDefault::resetToDefault ( )
inlinenoexcept

Removes the property from the referenced ValueTree.

◆ operator=() [1/2]

ValueTreePropertyWithDefault & juce::ValueTreePropertyWithDefault::operator= ( const var & newValue)
inline

Sets the property and returns the new ValueTreePropertyWithDefault.

This will modify the property in the referenced ValueTree.

References setValue(), and ValueTreePropertyWithDefault().

◆ setValue()

void juce::ValueTreePropertyWithDefault::setValue ( const var & newValue,
UndoManager * undoManagerToUse )
inline

Sets the property.

This will modify the property in the referenced ValueTree.

References juce::var::getArray().

Referenced by operator=().

◆ referTo() [1/3]

void juce::ValueTreePropertyWithDefault::referTo ( ValueTree tree,
const Identifier & property,
UndoManager * um )
inline

Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.

The default value will be an empty var.

References juce::tree.

Referenced by ValueTreePropertyWithDefault(), ValueTreePropertyWithDefault(), and ValueTreePropertyWithDefault().

◆ referTo() [2/3]

void juce::ValueTreePropertyWithDefault::referTo ( ValueTree tree,
const Identifier & property,
UndoManager * um,
var defaultVal )
inline

Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.

The default value will be defaultVal.

References juce::tree.

◆ referTo() [3/3]

void juce::ValueTreePropertyWithDefault::referTo ( ValueTree tree,
const Identifier & property,
UndoManager * um,
var defaultVal,
StringRef arrayDelimiter )
inline

Makes the ValueTreePropertyWithDefault refer to the specified property inside the given ValueTree.

The default value will be defaultVal.

References juce::tree.

◆ getValueTree()

ValueTree & juce::ValueTreePropertyWithDefault::getValueTree ( )
inlinenoexcept

Returns a reference to the ValueTree containing the referenced property.

◆ getPropertyID() [1/2]

Identifier & juce::ValueTreePropertyWithDefault::getPropertyID ( )
inlinenoexcept

Returns the property ID of the referenced property.

◆ getPropertyID() [2/2]

const Identifier & juce::ValueTreePropertyWithDefault::getPropertyID ( ) const
inlinenoexcept

Returns the property ID of the referenced property.

◆ getUndoManager()

UndoManager * juce::ValueTreePropertyWithDefault::getUndoManager ( )
inlinenoexcept

Returns the UndoManager that is being used.

◆ operator=() [2/2]

ValueTreePropertyWithDefault & juce::ValueTreePropertyWithDefault::operator= ( const ValueTreePropertyWithDefault & other)
inline

Member Data Documentation

◆ onDefaultChange

std::function<void()> juce::ValueTreePropertyWithDefault::onDefaultChange

You can assign a lambda to this callback and it will called when the default value is changed.

See also
setDefault
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram