Krotos Modules 3
Loading...
Searching...
No Matches
krotos::CustomParameterTree Class Reference

#include <CustomParameterTree.h>

Inheritance diagram for krotos::CustomParameterTree:
krotos::SamplesTree

Public Member Functions

 CustomParameterTree (const Identifier &type, UndoManager *undoManager=nullptr)
 
 CustomParameterTree (ValueTree customTree, UndoManager *undoManager=nullptr)
 
 CustomParameterTree (const CustomParameterTree &other)
 
 ~CustomParameterTree () override
 
CustomParameterTreeoperator= (const CustomParameterTree &other)
 
bool operator== (const CustomParameterTree &other) const
 
bool isValid () const
 
void setUndoManager (UndoManager *um)
 
UndoManager * getUndoManager () const
 
const ValueTree & getParameterTree () const
 
const Identifier getType () const
 
void addChild (const ValueTree &child, int index=-1)
 
ValueTree getChild (int index) const
 
ValueTree getChildWithName (const Identifier &type) const
 
void removeChild (const ValueTree &child)
 
void removeAllChildren ()
 Removes all children from the tree.
 
virtual void valueTreePropertyChanged (ValueTree &treeWhosePropertyHasChanged, const Identifier &property) override
 
virtual void valueTreeChildAdded (ValueTree &parentTree, ValueTree &childWhichHasBeenAdded) override
 
virtual void valueTreeChildRemoved (ValueTree &parentTree, ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved) override
 

Public Attributes

std::function< void(ValueTree &treeWhosePropertyHasChanged, const Identifier &property)> propertyChanged
 
std::function< void(ValueTree &parentTree, ValueTree &childWhichHasBeenAdded)> childAdded
 
std::function< void(ValueTree &parentTree, ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved)> childRemoved
 

Protected Attributes

ValueTree m_parameterTree
 

Private Attributes

UndoManager * m_undoManager {nullptr}
 

Detailed Description

Similar to a CustomParameter, this is a wrapper class around
juce::ValueTree designed to store custom plugin state in a tree
format. You can create a subclass to extend the ValueTree as
far and wide as you wish and override the Listeners, or you can just pass
a ValueTree in, use the wrapper methods
and set up Listeners underlying tree using getParameterTree.

Constructor & Destructor Documentation

◆ CustomParameterTree() [1/3]

krotos::CustomParameterTree::CustomParameterTree ( const Identifier & type,
UndoManager * undoManager = nullptr )

Creates an empty CustomParameterTree with a specified type.

◆ CustomParameterTree() [2/3]

krotos::CustomParameterTree::CustomParameterTree ( ValueTree customTree,
UndoManager * undoManager = nullptr )

Creates a CustomParameterTree from an existing ValueTree. This will assign the underlying ValueTree reference to the given input tree, therefore retaining any existing listeners.

◆ CustomParameterTree() [3/3]

krotos::CustomParameterTree::CustomParameterTree ( const CustomParameterTree & other)

Copy constructor.

◆ ~CustomParameterTree()

krotos::CustomParameterTree::~CustomParameterTree ( )
override

Destructor.

Member Function Documentation

◆ addChild()

void krotos::CustomParameterTree::addChild ( const ValueTree & child,
int index = -1 )

Adds a child to this tree. Make sure that the child being added has first been removed from any former parent before calling this, or else you'll hit an assertion. If the index is < 0 or greater than the current number of sub - trees, the new one will be added at the end of the list.

◆ getChild()

ValueTree krotos::CustomParameterTree::getChild ( int index) const

Returns one of this tree's sub-trees. If the index is out of range, it'll return an invalid tree. (You can use isValid() to check whether a tree is valid)

◆ getChildWithName()

ValueTree krotos::CustomParameterTree::getChildWithName ( const Identifier & type) const

Returns the first sub-tree with the specified type name. If no such child tree exists, it'll return an invalid tree. (You can use isValid() to check whether a tree is valid)

See also
getOrCreateChildWithName

◆ getParameterTree()

const ValueTree & krotos::CustomParameterTree::getParameterTree ( ) const
inline

Get a reference to the ValueTree that holds this object's state.

◆ getType()

const Identifier krotos::CustomParameterTree::getType ( ) const
inline

Returns the CustomParameterTree type.

◆ getUndoManager()

UndoManager * krotos::CustomParameterTree::getUndoManager ( ) const
inline

Get a pointer to the UndoManager used by this object.

◆ isValid()

bool krotos::CustomParameterTree::isValid ( ) const

Returns true if this CustomParameter's ValueTree is valid.

◆ operator=()

CustomParameterTree & krotos::CustomParameterTree::operator= ( const CustomParameterTree & other)

Copy assignment operator.

◆ operator==()

bool krotos::CustomParameterTree::operator== ( const CustomParameterTree & other) const

Comparison operator.

Returns
True if the other CustomParameter is controlling the same ValueTree property as this one.

◆ removeAllChildren()

void krotos::CustomParameterTree::removeAllChildren ( )
inline

Removes all children from the tree.

◆ removeChild()

void krotos::CustomParameterTree::removeChild ( const ValueTree & child)

Removes the specified child from this tree's child-list.

◆ setUndoManager()

void krotos::CustomParameterTree::setUndoManager ( UndoManager * um)
inline

Set the UndoManager that this object will use for all of its ValueTree interactions.

◆ valueTreeChildAdded()

void krotos::CustomParameterTree::valueTreeChildAdded ( ValueTree & parentTree,
ValueTree & childWhichHasBeenAdded )
overridevirtual

Reimplemented in krotos::SamplesTree.

◆ valueTreeChildRemoved()

void krotos::CustomParameterTree::valueTreeChildRemoved ( ValueTree & parentTree,
ValueTree & childWhichHasBeenRemoved,
int indexFromWhichChildWasRemoved )
overridevirtual

Reimplemented in krotos::SamplesTree.

◆ valueTreePropertyChanged()

void krotos::CustomParameterTree::valueTreePropertyChanged ( ValueTree & treeWhosePropertyHasChanged,
const Identifier & property )
overridevirtual

Reimplemented in krotos::SamplesTree.

Member Data Documentation

◆ childAdded

std::function<void(ValueTree& parentTree, ValueTree& childWhichHasBeenAdded)> krotos::CustomParameterTree::childAdded

Assign a lambda to this object to be called when a child sub-tree has been added

◆ childRemoved

std::function<void(ValueTree& parentTree, ValueTree& childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved)> krotos::CustomParameterTree::childRemoved

Assign a lambda to this object to be called when a child sub-tree has been removed

◆ m_parameterTree

ValueTree krotos::CustomParameterTree::m_parameterTree
protected

◆ m_undoManager

UndoManager* krotos::CustomParameterTree::m_undoManager {nullptr}
private

◆ propertyChanged

std::function<void(ValueTree& treeWhosePropertyHasChanged, const Identifier& property)> krotos::CustomParameterTree::propertyChanged

Assign a lambda to this object to be called when a property of this tree (or of one of its sub-trees) has been changed.


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