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

#include <ModulationAssigner.h>

Inheritance diagram for krotos::ModulationAssigner:
krotos::KwidgetAudioProcessor::KListener

Public Member Functions

 ModulationAssigner (KwidgetAudioProcessor &processor, const StringArray &kwidgetWhitelist=StringArray())
 
 ~ModulationAssigner ()
 
void resized () override
 
void paintOverChildren (Graphics &g) override
 
DropComponentaddDropComponent (const String &labelText, const String &targetModSourceKwidgetID, int targetModulatorIdx=-1)
 
MultiDropComponentaddMultiDropComponent (const String &labelText, const String &targetModSourceKwidgetID, int numModulators, Array< Value > labelValues=Array< Value >())
 Add a multi drop component. This will create a parent with drop components for the given number of modulators.
 
void removeDropComponent (const String &kwidgetID)
 
ModulationAssignerTablegetTable (String id)
 
void attachModTreeListener (const ValueTree &tree)
 
void attachKwidgetsTreeListener (const ValueTree &tree)
 
Array< Component * > getDropComponents ()
 
void addToWhitelist (StringRef KType)
 Add a kwidget type to the whitelist.
 
void addToWhitelist (const StringArray &KTypes)
 
void clearWhitelist ()
 
void colourChanged () override
 
void setIndicatorActive (bool isActive)
 Sets whether to draw a border around the component to highlight it as a target destination for a drag and drop.
 

Public Attributes

std::function< void(var desc, String targetModSourceKwidgetID, int targetModulatorIdx, ModulationAssignerTable *table)> assignModulation
 
std::function< void(ValueTree modulationChildTree)> modulationDeleted
 

Private Types

using ModSourceIndexPair = std::pair<String, int>
 

Private Member Functions

void valueTreePropertyChanged (ValueTree &treeWhosePropertyHasChanged, const Identifier &property) override
 
void valueTreeChildAdded (ValueTree &parentTree, ValueTree &childWhichHasBeenAdded) override
 
void valueTreeChildRemoved (ValueTree &parentTree, ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved) override
 
void kwidgetAdded (Kwidget *k) override
 
void kwidgetRemoved (Kwidget *k) override
 
void initialiseData ()
 
ModulationAssignerTableaddTable (String label, ModSourceIndexPair modSourceIdx)
 
void removeTable (ModSourceIndexPair modSourceIdx)
 
void addAssignment (ValueTree assignment)
 
- Private Member Functions inherited from krotos::KwidgetAudioProcessor::KListener
virtual ~KListener ()=default
 

Private Attributes

ValueTree m_modulationParentTree
 
ValueTree m_kwidgetTree
 
Identifier m_property
 
StringArray m_whitelist
 
std::unique_ptr< ModulationAssignerDropAream_dropArea
 
OwnedArray< ModulationAssignerTablem_modulationTables
 
std::map< ModSourceIndexPair, ModulationAssignerTable * > m_tableMap
 
const int m_padding {4}
 
const int m_rowSize {3}
 
const float m_cornerSize {4.0f}
 
Colour m_borderColour {Colours::grey}
 
bool m_indicatorActive {false}
 
KwidgetAudioProcessorm_processor
 

Member Typedef Documentation

◆ ModSourceIndexPair

using krotos::ModulationAssigner::ModSourceIndexPair = std::pair<String, int>
private

Alias for a kwidget modulation source and modulator index

Constructor & Destructor Documentation

◆ ModulationAssigner()

krotos::ModulationAssigner::ModulationAssigner ( KwidgetAudioProcessor & processor,
const StringArray & kwidgetWhitelist = StringArray() )

Create a modulation assigner. This is a GUI component capable of creating assignable "DropComponents" to which draggable labels can be dragged onto. This creates modulation assignments via the KwidgetAudioProcessor.

A whitelist can be used to limit the types of kwidgets will create an assigner.

Parameters
modParentTreeThe Modulations parent ValueTree
kwidgetWhitelistA whitelist of kwidget types which the mod assigner will create drop zones for. If the list is empty, the assigner will create drop zones automatically for any modulator kwidgets added to the processor.
See also
addToWhitelist, clearWhitelist

◆ ~ModulationAssigner()

krotos::ModulationAssigner::~ModulationAssigner ( )

Member Function Documentation

◆ addAssignment()

void krotos::ModulationAssigner::addAssignment ( ValueTree assignment)
private

◆ addDropComponent()

DropComponent * krotos::ModulationAssigner::addDropComponent ( const String & labelText,
const String & targetModSourceKwidgetID,
int targetModulatorIdx = -1 )

Add a new DropComponent. You may want to assign assignModulation() using the pointer returned here.

Parameters
labelTextThe label text you want the DropComponent to display.
targetModSourceKwidgetIDThe modulator kwidget ID that this drop component will target.
targetModulatorIdxThe modulation source ID within the targeted kwidgetID.

◆ addMultiDropComponent()

MultiDropComponent * krotos::ModulationAssigner::addMultiDropComponent ( const String & labelText,
const String & targetModSourceKwidgetID,
int numModulators,
Array< Value > labelValues = Array<Value>() )

Add a multi drop component. This will create a parent with drop components for the given number of modulators.

Parameters
labelTextThe title label text for the multi drop component
targetModSourceKwidgetIDThe modulator kwidget ID that this multi drop component will target
numModulatorsThe number of modulators to target
labelValuesAn optional array of Value objects to attach to the drop component labels. This can be used to synchronise the labels with another source such as a property in a ValueTree.
Returns
Returns a pointer to the newly created component.

◆ addTable()

ModulationAssignerTable * krotos::ModulationAssigner::addTable ( String label,
ModSourceIndexPair modSourceIdx )
private

Internal function to create a ModulationAssignerTable. Creates a new ModulationAssignerTable object, adds it to an OwnedArray and the table map, then creates a hidden tab which the table exists on

Parameters
nameTable label
modSourceIdxModulation source and index pair that this table should attach to.

◆ addToWhitelist() [1/2]

void krotos::ModulationAssigner::addToWhitelist ( const StringArray & KTypes)
inline

◆ addToWhitelist() [2/2]

void krotos::ModulationAssigner::addToWhitelist ( StringRef KType)
inline

Add a kwidget type to the whitelist.

Parameters
KType

◆ attachKwidgetsTreeListener()

void krotos::ModulationAssigner::attachKwidgetsTreeListener ( const ValueTree & tree)

Attach a listener to the kwidget tree to automatically update the modulation assigner with drop components, when a modulation source is added.

Parameters
treeThe kwidget tree to listen to. Must be of type XmlType::Tag::kwidgets

◆ attachModTreeListener()

void krotos::ModulationAssigner::attachModTreeListener ( const ValueTree & tree)

Attaches the modulation assigner to listen to the modulation ValueTree, so it may update the tables to display the modulation assignments.

Parameters
treeThe modulations tree to listen to. Must be of type XmlType::Tag::modulations

◆ clearWhitelist()

void krotos::ModulationAssigner::clearWhitelist ( )
inline

◆ colourChanged()

void krotos::ModulationAssigner::colourChanged ( )
override

◆ getDropComponents()

Array< Component * > krotos::ModulationAssigner::getDropComponents ( )
inline

◆ getTable()

ModulationAssignerTable * krotos::ModulationAssigner::getTable ( String id)

Returns a pointer to a modulation table of a given id.

◆ initialiseData()

void krotos::ModulationAssigner::initialiseData ( )
private

Initialise from data in the ValueTree

◆ kwidgetAdded()

void krotos::ModulationAssigner::kwidgetAdded ( Kwidget * k)
overrideprivatevirtual

Called by the main AudioProcessor after a Kwidget is added.

Implements krotos::KwidgetAudioProcessor::KListener.

◆ kwidgetRemoved()

void krotos::ModulationAssigner::kwidgetRemoved ( Kwidget * k)
overrideprivatevirtual

Called by the main AudioProcessor before a Kwidget is removed.

Implements krotos::KwidgetAudioProcessor::KListener.

◆ paintOverChildren()

void krotos::ModulationAssigner::paintOverChildren ( Graphics & g)
override

◆ removeDropComponent()

void krotos::ModulationAssigner::removeDropComponent ( const String & kwidgetID)

Remove a DropComponent. Note, this does not remove it's corresponding table. You'll need to do this with removeTable(). Todo: as part of dual drop component refactor, we should marry these up.

Parameters
labelTextThe kwidgetID of the connected DropComponent to remove.

◆ removeTable()

void krotos::ModulationAssigner::removeTable ( ModSourceIndexPair modSourceIdx)
private

◆ resized()

void krotos::ModulationAssigner::resized ( )
override

◆ setIndicatorActive()

void krotos::ModulationAssigner::setIndicatorActive ( bool isActive)

Sets whether to draw a border around the component to highlight it as a target destination for a drag and drop.

Parameters
isActiveDraw the border or not.

◆ valueTreeChildAdded()

void krotos::ModulationAssigner::valueTreeChildAdded ( ValueTree & parentTree,
ValueTree & childWhichHasBeenAdded )
overrideprivate

◆ valueTreeChildRemoved()

void krotos::ModulationAssigner::valueTreeChildRemoved ( ValueTree & parentTree,
ValueTree & childWhichHasBeenRemoved,
int indexFromWhichChildWasRemoved )
overrideprivate

◆ valueTreePropertyChanged()

void krotos::ModulationAssigner::valueTreePropertyChanged ( ValueTree & treeWhosePropertyHasChanged,
const Identifier & property )
overrideprivate

ValueTree Listener Callback Overrides

Member Data Documentation

◆ assignModulation

std::function<void(var desc, String targetModSourceKwidgetID, int targetModulatorIdx, ModulationAssignerTable* table)> krotos::ModulationAssigner::assignModulation

Assign this function to be called when something is dropped onto one of the drop components.

Parameters
descThe drag and drop description contaning the source kwidget and parameter ID
targetModSourceKwidgetIDThe target modulation souce kwidget e.g. an XY Pad
targetModulatorIdxThe target modulator index of the mod source. e.g. 0 for X, 1 for Y
tableA pointer to the table component created for the modulation assignment.

◆ m_borderColour

Colour krotos::ModulationAssigner::m_borderColour {Colours::grey}
private

◆ m_cornerSize

const float krotos::ModulationAssigner::m_cornerSize {4.0f}
private

◆ m_dropArea

std::unique_ptr<ModulationAssignerDropArea> krotos::ModulationAssigner::m_dropArea
private

This holds the drop components

◆ m_indicatorActive

bool krotos::ModulationAssigner::m_indicatorActive {false}
private

◆ m_kwidgetTree

ValueTree krotos::ModulationAssigner::m_kwidgetTree
private

◆ m_modulationParentTree

ValueTree krotos::ModulationAssigner::m_modulationParentTree
private

◆ m_modulationTables

OwnedArray<ModulationAssignerTable> krotos::ModulationAssigner::m_modulationTables
private

◆ m_padding

const int krotos::ModulationAssigner::m_padding {4}
private

◆ m_processor

KwidgetAudioProcessor& krotos::ModulationAssigner::m_processor
private

◆ m_property

Identifier krotos::ModulationAssigner::m_property
private

◆ m_rowSize

const int krotos::ModulationAssigner::m_rowSize {3}
private

◆ m_tableMap

std::map<ModSourceIndexPair, ModulationAssignerTable*> krotos::ModulationAssigner::m_tableMap
private

A map to lookup tables via the modulation source they are attached to The pointers here are managed via the OwnedArray m_modulationTables so do not delete or manage their lifetimes using the pointers returned here

Todo: Create a remove function to safely remove Table pointers

◆ m_whitelist

StringArray krotos::ModulationAssigner::m_whitelist
private

◆ modulationDeleted

std::function<void(ValueTree modulationChildTree)> krotos::ModulationAssigner::modulationDeleted

Called when a user deletes a row from the tablelist box. Assign this callback to delete modulation via the ParameterManager.


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