OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce::ValueWithDefault Class Reference

#include <juce_ValueWithDefault.h>

Public Member Functions

 ValueWithDefault ()=default
 
 ValueWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um)
 
 ValueWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um, const var &defaultToUse)
 
 ValueWithDefault (ValueTree &tree, const Identifier &propertyID, UndoManager *um, const var &defaultToUse, StringRef arrayDelimiter)
 
 ValueWithDefault (const ValueWithDefault &other)
 
var get () const noexcept
 
Value getPropertyAsValue ()
 
var getDefault () const
 
void setDefault (const var &newDefault)
 
bool isUsingDefault () const
 
void resetToDefault () noexcept
 
ValueWithDefaultoperator= (const var &newValue)
 
void setValue (const var &newValue, UndoManager *undoManagerToUse)
 
void referTo (ValueTree &tree, const Identifier &property, UndoManager *um)
 
void referTo (ValueTree &tree, const Identifier &property, UndoManager *um, const var &defaultVal)
 
void referTo (ValueTree &tree, const Identifier &property, UndoManager *um, const var &defaultVal, StringRef arrayDelimiter)
 
ValueTreegetValueTree () noexcept
 
IdentifiergetPropertyID () noexcept
 
UndoManagergetUndoManager () noexcept
 
ValueWithDefaultoperator= (const ValueWithDefault &other)
 

Public Attributes

std::function< void()> onDefaultChange
 

Detailed Description

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.

Definition at line 39 of file juce_ValueWithDefault.h.

Constructor & Destructor Documentation

◆ ValueWithDefault() [1/5]

juce::ValueWithDefault::ValueWithDefault ( )
default

Creates an unitialised ValueWithDefault. Initialise it using one of the referTo() methods.

◆ ValueWithDefault() [2/5]

juce::ValueWithDefault::ValueWithDefault ( ValueTree tree,
const Identifier propertyID,
UndoManager um 
)
inline

Creates an ValueWithDefault object. The default value will be an empty var.

Definition at line 47 of file juce_ValueWithDefault.h.

◆ ValueWithDefault() [3/5]

juce::ValueWithDefault::ValueWithDefault ( ValueTree tree,
const Identifier propertyID,
UndoManager um,
const var defaultToUse 
)
inline

Creates an ValueWithDefault object. The default value will be defaultToUse.

Definition at line 56 of file juce_ValueWithDefault.h.

◆ ValueWithDefault() [4/5]

juce::ValueWithDefault::ValueWithDefault ( ValueTree tree,
const Identifier propertyID,
UndoManager um,
const var defaultToUse,
StringRef  arrayDelimiter 
)
inline

Creates an ValueWithDefault object. 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.

Definition at line 71 of file juce_ValueWithDefault.h.

◆ ValueWithDefault() [5/5]

juce::ValueWithDefault::ValueWithDefault ( const ValueWithDefault other)
inline

Creates a ValueWithDefault object from another ValueWithDefault object.

Definition at line 82 of file juce_ValueWithDefault.h.

Member Function Documentation

◆ get()

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

Returns the current value of the property. If the property does not exist or is empty, returns the default value.

Definition at line 95 of file juce_ValueWithDefault.h.

◆ getDefault()

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

Returns the current default value.

Definition at line 110 of file juce_ValueWithDefault.h.

◆ getPropertyAsValue()

Value juce::ValueWithDefault::getPropertyAsValue ( )
inline

Returns the current property as a Value object.

Definition at line 107 of file juce_ValueWithDefault.h.

◆ getPropertyID()

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

Returns the property ID of the referenced property.

Definition at line 182 of file juce_ValueWithDefault.h.

◆ getUndoManager()

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

Returns the UndoManager that is being used.

Definition at line 185 of file juce_ValueWithDefault.h.

◆ getValueTree()

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

Returns a reference to the ValueTree containing the referenced property.

Definition at line 179 of file juce_ValueWithDefault.h.

◆ isUsingDefault()

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

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

Definition at line 125 of file juce_ValueWithDefault.h.

Referenced by get().

◆ operator=() [1/2]

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

Definition at line 188 of file juce_ValueWithDefault.h.

◆ operator=() [2/2]

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

Sets the property and returns the new ValueWithDefault. This will modify the property in the referenced ValueTree.

Definition at line 141 of file juce_ValueWithDefault.h.

◆ referTo() [1/3]

void juce::ValueWithDefault::referTo ( ValueTree tree,
const Identifier property,
UndoManager um 
)
inline

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

Definition at line 158 of file juce_ValueWithDefault.h.

◆ referTo() [2/3]

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

Makes the ValueWithDefault refer to the specified property inside the given ValueTree, and specifies a default value to use.

Definition at line 166 of file juce_ValueWithDefault.h.

◆ referTo() [3/3]

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

Definition at line 171 of file juce_ValueWithDefault.h.

◆ resetToDefault()

void juce::ValueWithDefault::resetToDefault ( )
inlinenoexcept

Removes the property from the referenced ValueTree.

Definition at line 131 of file juce_ValueWithDefault.h.

◆ setDefault()

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

Sets the default value to a new var.

Definition at line 113 of file juce_ValueWithDefault.h.

◆ setValue()

void juce::ValueWithDefault::setValue ( const var newValue,
UndoManager undoManagerToUse 
)
inline

Sets the property. This will actually modify the property in the referenced ValueTree.

Definition at line 148 of file juce_ValueWithDefault.h.

Referenced by operator=().

Member Data Documentation

◆ onDefaultChange

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

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

Definition at line 137 of file juce_ValueWithDefault.h.

Referenced by setDefault().


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