JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::ValueTreePropertyWithDefault Class Reference

This class acts as a wrapper around a property inside a ValueTree. More...

#include <juce_ValueTreePropertyWithDefault.h>

Inheritance diagram for juce::ValueTreePropertyWithDefault:
Collaboration diagram for juce::ValueTreePropertyWithDefault:

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...
 
IdentifiergetPropertyID () noexcept
 Returns the property ID of the referenced property. More...
 
UndoManagergetUndoManager () noexcept
 Returns the UndoManager that is being used. More...
 
ValueTreegetValueTree () 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...
 
ValueTreePropertyWithDefaultoperator= (const ValueTreePropertyWithDefault &other)
 
ValueTreePropertyWithDefaultoperator= (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< vardelimitedStringToVarArray (StringRef input, StringRef delim)
 
static String varArrayToDelimitedString (const Array< var > &input, StringRef delim)
 

Private Attributes

Value defaultValue
 
String delimiter
 
Identifier targetProperty
 
ValueTree targetTree
 
UndoManagerundoManager = nullptr
 

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

@tags{DataStructures}

Constructor & Destructor Documentation

◆ ValueTreePropertyWithDefault() [1/5]

juce::ValueTreePropertyWithDefault::ValueTreePropertyWithDefault ( )
default

Creates an uninitialised ValueTreePropertyWithDefault object.

Initialise it using one of the referTo() methods.

◆ 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 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 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 juce::tree.

◆ ValueTreePropertyWithDefault() [5/5]

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

◆ ~ValueTreePropertyWithDefault()

juce::ValueTreePropertyWithDefault::~ValueTreePropertyWithDefault ( )
inlineoverride

Destructor.

Member Function Documentation

◆ delimitedStringToVarArray()

static Array<var> juce::ValueTreePropertyWithDefault::delimitedStringToVarArray ( StringRef  input,
StringRef  delim 
)
inlinestaticprivate

◆ 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.

◆ getDefault()

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

Returns the current default value.

◆ getPropertyAsValue()

Value juce::ValueTreePropertyWithDefault::getPropertyAsValue ( )
inline

Returns the current property as a Value object.

◆ getPropertyID()

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

Returns the property ID of the referenced property.

◆ getUndoManager()

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

Returns the UndoManager that is being used.

◆ getValueTree()

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

Returns a reference to the ValueTree containing the referenced property.

◆ isUsingDefault()

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

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

◆ operator=() [1/2]

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

◆ operator=() [2/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.

◆ 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.

◆ 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.

◆ referToWithDefault()

void juce::ValueTreePropertyWithDefault::referToWithDefault ( ValueTree  v,
const Identifier i,
UndoManager um,
const Value defaultVal,
StringRef  del 
)
inlineprivate

◆ resetToDefault()

void juce::ValueTreePropertyWithDefault::resetToDefault ( )
inlinenoexcept

Removes the property from the referenced ValueTree.

◆ setDefault()

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

Sets the default value to a new var.

◆ 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::gl::array, and juce::var::getArray().

◆ valueChanged()

void juce::ValueTreePropertyWithDefault::valueChanged ( Value value)
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.

◆ varArrayToDelimitedString()

static String juce::ValueTreePropertyWithDefault::varArrayToDelimitedString ( const Array< var > &  input,
StringRef  delim 
)
inlinestaticprivate

Member Data Documentation

◆ defaultValue

Value juce::ValueTreePropertyWithDefault::defaultValue
private

◆ delimiter

String juce::ValueTreePropertyWithDefault::delimiter
private

◆ 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

◆ targetProperty

Identifier juce::ValueTreePropertyWithDefault::targetProperty
private

◆ targetTree

ValueTree juce::ValueTreePropertyWithDefault::targetTree
private

◆ undoManager

UndoManager* juce::ValueTreePropertyWithDefault::undoManager = nullptr
private

The documentation for this class was generated from the following file: