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

#include <PerformanceArea.h>

Inheritance diagram for krotos::krotos::PerformanceArea:

Classes

struct  ComponentIds
 
struct  Layout
 
struct  Tag
 

Public Member Functions

 PerformanceArea (ValueTree &customDataTree, KwidgetAudioProcessor &processor, int id, const StringArray &optionKTypes=StringArray())
 Creates a performance template area, to which kwidget guis may be added via addKwidgetGUI().
 
void resized () override
 
void paint (Graphics &g) override
 
void addKwidgetGUI (KwidgetGUI *kwidget, Rectangle< int > bounds)
 
void removeComponent (int index)
 
ValueTree & getLayoutTree ()
 
std::unique_ptr< XmlElement > saveTemplateXml ()
 
void loadTemplateXml (const XmlElement &templateXml)
 
void setTemplateSelectorVisible (bool isVisible)
 
void setEditModeActive (bool isEditModeActive)
 
bool isEditModeActive ()
 
void enableAutoLayout (bool isEnabled)
 
bool isAutoLayoutActive ()
 
void configureAutoLayout (FlexBox flexSettings, FlexItem::Margin margin)
 
void clearLayout ()
 Clears the current template and deletes any kwidgets in it.
 
int getID ()
 
void addKTypesToDropdown (StringArray kTypes)
 Populate the dropdown in .nikolas mode with ktypes. These must be valid ktypes. If they are not they should be captured by error checking.
 
void setDrawBackground (bool newValue)
 Set whether the gradient background should be drawn.
 

Public Attributes

std::function< void(String kType)> addKwidget
 
std::function< Rectangle< int >(String componentType, Rectangle< int > currentBounds)> getAutoLayoutBoundsFromType
 Used to look up what bounds should be used for a given component type when using auto layout. Returns default bounds if nothing is set for that type.
 
bool smallify {false}
 

Static Public Attributes

static const std::string analyticsEventTemplateSelected
 
static const String TemplateFileExtension
 

Private Types

using KType = KwidgetFactory::KwidgetType
 

Private Member Functions

void setLayoutTree (const ValueTree &layoutTree)
 
void resetLayoutTree (const ValueTree &layoutTree)
 
void addComponent (Component &component, Rectangle< int > bounds=CustomLayout::DefaultSize)
 
void addComponent (Component &component, ValueTree slot)
 
void refreshTemplates ()
 
void initialiseListeners ()
 
void addToLayoutBuilder (const ValueTree &kwidgetTree)
 
void initialiseEditorControls ()
 
void showEditorControls (bool isEnabled)
 

Private Attributes

CustomLayout m_layoutEditor
 
std::unique_ptr< Drawable > m_backgroundImage
 
ComboBox m_layoutSelector
 
ComboBox m_editorSelector
 
StringArray m_optionKTypes
 
std::unique_ptr< FileChooser > m_saveWindow
 
std::unique_ptr< FileChooser > m_loadWindow
 
ValueTree & m_customDataTree
 
std::unique_ptr< ValueTreeAttachmentm_customTreeAttachment
 
Array< File > m_templateFiles
 
KwidgetAudioProcessorm_processor
 
const String edit_mode_file_ext {"nikolas"}
 
bool m_showEditorControls {false}
 
bool m_drawBackground {false}
 
int m_id {0}
 
int m_lastSelectedTemplate {0}
 
std::unique_ptr< Drawable > m_dropdownIcon
 
ValueTree m_layoutBuilderTree
 

Detailed Description

A component for creating performance templates which can be edited, saved and reloaded.

Templates are created as kwidgets are added by saving the kwidget state to an internal tree. When loaded, it uses this state to recreate kwidgets via the processor.

Resizing and saving of bounds is handled by the CustomLayout component, which has a ValueTree whose reference is set to a child of the the CUSTOMDATA node in the main plugin state tree.

Templates may also be laid out automatically using FlexBox. See enableAutoLayout and configureAutoLayout.

Todo: Make this inherit from CustomLayout

Inherits from ActionBroadcaster to facilitate the broadcasting of analytics events and other actions to registered listeners.

See also
CustomLayout

Member Typedef Documentation

◆ KType

Constructor & Destructor Documentation

◆ PerformanceArea()

krotos::krotos::PerformanceArea::PerformanceArea ( ValueTree & customDataTree,
KwidgetAudioProcessor & processor,
int id,
const StringArray & optionKTypes = StringArray() )

Creates a performance template area, to which kwidget guis may be added via addKwidgetGUI().

Parameters
customDataTreeThe "CUSTOMDATA" tree in the plugin state.
See also
ParameterManager::getCustomDataTree()
Parameters
processorReference to the kwidget audio processor.
idThe id of the performance area. This could be used to filter specific kwidget GUIs into specific performance areas, if there are many.
optionKTypesA list of kwidget types to populate the "add" dropdown with (only in .nikolas mode)

Member Function Documentation

◆ addComponent() [1/2]

void krotos::krotos::PerformanceArea::addComponent ( Component & component,
Rectangle< int > bounds = CustomLayout::DefaultSize )
inlineprivate

Add a component to the custom layout.

This will add the given component as a child to a resizable component within the CustomLayout.

Parameters
componentThe component to add to the CustomLayout
boundsThe starting bounds of the component.

◆ addComponent() [2/2]

void krotos::krotos::PerformanceArea::addComponent ( Component & component,
ValueTree slot )
inlineprivate

Add a component from a given slot tree.

This will search for an existing slot that matches the given tree and add the component to that, or create a new one if no slot is found.

A slot tree is created when a new slot is added to the CustomLayout. The most likely circumstance where a singular slot tree may exist outside of the custom layout would be if the layoutTree reference has been re-assigned, for instance, to hand over layout state management to external control.

See also
setLayoutTree
Parameters
componentThe component to add to the CustomLayout
slotThe slot tree for that component. A slot tree is created when a new component is added to the layout.

◆ addKTypesToDropdown()

void krotos::krotos::PerformanceArea::addKTypesToDropdown ( StringArray kTypes)
inline

Populate the dropdown in .nikolas mode with ktypes. These must be valid ktypes. If they are not they should be captured by error checking.

Parameters
kTypes

◆ addKwidgetGUI()

void krotos::krotos::PerformanceArea::addKwidgetGUI ( KwidgetGUI * kwidget,
Rectangle< int > bounds )

Add a kwidget GUI to the performance area. If this kwidget already has a custom layout slot saved in the layout tree, it will be assigned to that slot. Otherwise, a new slot will be created with default bounds.

See also
addComponent

◆ addToLayoutBuilder()

void krotos::krotos::PerformanceArea::addToLayoutBuilder ( const ValueTree & kwidgetTree)
private

◆ clearLayout()

void krotos::krotos::PerformanceArea::clearLayout ( )

Clears the current template and deletes any kwidgets in it.

◆ configureAutoLayout()

void krotos::krotos::PerformanceArea::configureAutoLayout ( FlexBox flexSettings,
FlexItem::Margin margin )
inline

◆ enableAutoLayout()

void krotos::krotos::PerformanceArea::enableAutoLayout ( bool isEnabled)
inline

◆ getID()

int krotos::krotos::PerformanceArea::getID ( )
inline

◆ getLayoutTree()

ValueTree & krotos::krotos::PerformanceArea::getLayoutTree ( )
inline

Returns a reference to the active layoutTree. This reference could be set to the child of a different tree e.g. the plugin state, to allow the layout to be stored outside of this object.

◆ initialiseEditorControls()

void krotos::krotos::PerformanceArea::initialiseEditorControls ( )
private

◆ initialiseListeners()

void krotos::krotos::PerformanceArea::initialiseListeners ( )
private

◆ isAutoLayoutActive()

bool krotos::krotos::PerformanceArea::isAutoLayoutActive ( )
inline

◆ isEditModeActive()

bool krotos::krotos::PerformanceArea::isEditModeActive ( )
inline

Returns whether edit mode is active or not.

See also
setEditModeActive

◆ loadTemplateXml()

void krotos::krotos::PerformanceArea::loadTemplateXml ( const XmlElement & templateXml)

Load a template from Xml, as saved from saveTemplateXml();

See also
saveTemplateXml()

◆ paint()

void krotos::krotos::PerformanceArea::paint ( Graphics & g)
override

◆ refreshTemplates()

void krotos::krotos::PerformanceArea::refreshTemplates ( )
private

◆ removeComponent()

void krotos::krotos::PerformanceArea::removeComponent ( int index)
inline

Remove a component from the CustomLayout. If the index is out-of-range, nothing will be changed Components may also be removed by removing their slot from the valuetree.

◆ resetLayoutTree()

void krotos::krotos::PerformanceArea::resetLayoutTree ( const ValueTree & layoutTree)
inlineprivate

Clears the current layout tree, then changes the refrence of the layout tree to the new incoming tree. Use this if you wish to replace the layout state with one saved externally from this class. i.e. Loading an externally saved layout tree from state.

Parameters
layoutTreeA layout tree. This should only be a layout tree already created and saved by the CustomLayout.

◆ resized()

void krotos::krotos::PerformanceArea::resized ( )
override

◆ saveTemplateXml()

std::unique_ptr< XmlElement > krotos::krotos::PerformanceArea::saveTemplateXml ( )

Saves and returns the current template as an XmlElement

◆ setDrawBackground()

void krotos::krotos::PerformanceArea::setDrawBackground ( bool newValue)
inline

Set whether the gradient background should be drawn.

◆ setEditModeActive()

void krotos::krotos::PerformanceArea::setEditModeActive ( bool isEditModeActive)
inline

Sets visbility of resizable borders on layout slots.

◆ setLayoutTree()

void krotos::krotos::PerformanceArea::setLayoutTree ( const ValueTree & layoutTree)
inlineprivate

Change the reference of the layoutTree. Use this if you wish to manage the CustomLayout state exernally from this class.

Parameters
layoutTreeA layout tree. This should only be a layout tree already created and saved by the CustomLayout.

◆ setTemplateSelectorVisible()

void krotos::krotos::PerformanceArea::setTemplateSelectorVisible ( bool isVisible)
inline

Set the visibility of the template selector dropdown.

◆ showEditorControls()

void krotos::krotos::PerformanceArea::showEditorControls ( bool isEnabled)
private

Member Data Documentation

◆ addKwidget

std::function<void(String kType)> krotos::krotos::PerformanceArea::addKwidget

◆ analyticsEventTemplateSelected

const std::string krotos::krotos::PerformanceArea::analyticsEventTemplateSelected
static

◆ edit_mode_file_ext

const String krotos::krotos::PerformanceArea::edit_mode_file_ext {"nikolas"}
private

◆ getAutoLayoutBoundsFromType

std::function<Rectangle<int>(String componentType, Rectangle<int> currentBounds)> krotos::krotos::PerformanceArea::getAutoLayoutBoundsFromType

Used to look up what bounds should be used for a given component type when using auto layout. Returns default bounds if nothing is set for that type.

◆ m_backgroundImage

std::unique_ptr<Drawable> krotos::krotos::PerformanceArea::m_backgroundImage
private

◆ m_customDataTree

ValueTree& krotos::krotos::PerformanceArea::m_customDataTree
private

◆ m_customTreeAttachment

std::unique_ptr<ValueTreeAttachment> krotos::krotos::PerformanceArea::m_customTreeAttachment
private

◆ m_drawBackground

bool krotos::krotos::PerformanceArea::m_drawBackground {false}
private

◆ m_dropdownIcon

std::unique_ptr<Drawable> krotos::krotos::PerformanceArea::m_dropdownIcon
private

◆ m_editorSelector

ComboBox krotos::krotos::PerformanceArea::m_editorSelector
private

◆ m_id

int krotos::krotos::PerformanceArea::m_id {0}
private

◆ m_lastSelectedTemplate

int krotos::krotos::PerformanceArea::m_lastSelectedTemplate {0}
private

◆ m_layoutBuilderTree

ValueTree krotos::krotos::PerformanceArea::m_layoutBuilderTree
private

◆ m_layoutEditor

CustomLayout krotos::krotos::PerformanceArea::m_layoutEditor
private

◆ m_layoutSelector

ComboBox krotos::krotos::PerformanceArea::m_layoutSelector
private

◆ m_loadWindow

std::unique_ptr<FileChooser> krotos::krotos::PerformanceArea::m_loadWindow
private

◆ m_optionKTypes

StringArray krotos::krotos::PerformanceArea::m_optionKTypes
private

◆ m_processor

KwidgetAudioProcessor& krotos::krotos::PerformanceArea::m_processor
private

◆ m_saveWindow

std::unique_ptr<FileChooser> krotos::krotos::PerformanceArea::m_saveWindow
private

◆ m_showEditorControls

bool krotos::krotos::PerformanceArea::m_showEditorControls {false}
private

◆ m_templateFiles

Array<File> krotos::krotos::PerformanceArea::m_templateFiles
private

◆ smallify

bool krotos::krotos::PerformanceArea::smallify {false}

◆ TemplateFileExtension

const String krotos::krotos::PerformanceArea::TemplateFileExtension
static

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