|
Krotos Modules 3
|
#include <PerformanceArea.h>
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< ValueTreeAttachment > | m_customTreeAttachment |
| Array< File > | m_templateFiles |
| KwidgetAudioProcessor & | m_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 |
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.
|
private |
| 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().
| customDataTree | The "CUSTOMDATA" tree in the plugin state. |
| processor | Reference to the kwidget audio processor. |
| id | The id of the performance area. This could be used to filter specific kwidget GUIs into specific performance areas, if there are many. |
| optionKTypes | A list of kwidget types to populate the "add" dropdown with (only in .nikolas mode) |
|
inlineprivate |
Add a component to the custom layout.
This will add the given component as a child to a resizable component within the CustomLayout.
| component | The component to add to the CustomLayout |
| bounds | The starting bounds of the component. |
|
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.
| component | The component to add to the CustomLayout |
| slot | The slot tree for that component. A slot tree is created when a new component is added to the layout. |
|
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.
| kTypes |
| 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.
|
private |
| void krotos::krotos::PerformanceArea::clearLayout | ( | ) |
Clears the current template and deletes any kwidgets in it.
|
inline |
|
inline |
|
inline |
|
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.
|
private |
|
private |
|
inline |
|
inline |
Returns whether edit mode is active or not.
| void krotos::krotos::PerformanceArea::loadTemplateXml | ( | const XmlElement & | templateXml | ) |
Load a template from Xml, as saved from saveTemplateXml();
|
override |
|
private |
|
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.
|
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.
| layoutTree | A layout tree. This should only be a layout tree already created and saved by the CustomLayout. |
|
override |
| std::unique_ptr< XmlElement > krotos::krotos::PerformanceArea::saveTemplateXml | ( | ) |
Saves and returns the current template as an XmlElement
|
inline |
Set whether the gradient background should be drawn.
|
inline |
Sets visbility of resizable borders on layout slots.
|
inlineprivate |
Change the reference of the layoutTree. Use this if you wish to manage the CustomLayout state exernally from this class.
| layoutTree | A layout tree. This should only be a layout tree already created and saved by the CustomLayout. |
|
inline |
Set the visibility of the template selector dropdown.
|
private |
| std::function<void(String kType)> krotos::krotos::PerformanceArea::addKwidget |
|
static |
|
private |
| 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.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
| bool krotos::krotos::PerformanceArea::smallify {false} |
|
static |