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

Interface for a UI Component that controls a KwidgetProcessor. More...

#include <KwidgetGUI.h>

Inheritance diagram for krotos::KwidgetGUI:
krotos::KwidgetGUI_Adsr krotos::KwidgetGUI_AudioOut krotos::KwidgetGUI_ConvolutionReverb krotos::KwidgetGUI_CoreEngine krotos::KwidgetGUI_Filter krotos::KwidgetGUI_Lfo krotos::KwidgetGUI_MacroControls krotos::KwidgetGUI_MacroSlider krotos::KwidgetGUI_MoogVcf krotos::KwidgetGUI_OfflineAnalyser krotos::KwidgetGUI_Pan krotos::KwidgetGUI_PhaseVocoder krotos::KwidgetGUI_Recorder krotos::KwidgetGUI_Reformer krotos::KwidgetGUI_SAFilter krotos::KwidgetGUI_Saturation krotos::KwidgetGUI_Sawtooth krotos::KwidgetGUI_Scaledadsr krotos::KwidgetGUI_Sine krotos::KwidgetGUI_Template krotos::KwidgetGUI_TriggerButton krotos::KwidgetGUI_XyPad

Public Types

enum class  RenderStyle {
  normal = 0 , borderless , borderless_with_buttons , minimised ,
  NUM_STYLES
}
 

Public Member Functions

 KwidgetGUI (Kwidget &owner)
 
 ~KwidgetGUI () override=default
 
void moved () override
 
void paint (Graphics &g) override
 
void resized () override
 
void mouseDown (const MouseEvent &event) override
 
const String & getKwidgetType () const
 
const String & getKwidgetID () const
 
void setRenderStyle (RenderStyle newStyle)
 
int divideIntByFloat (int dividend, float divisor)
 
int multiplyIntByFloat (int mult, float factor)
 
virtual void finalSetup ()
 
void ignorePadding (bool ignore)
 
TopBarComponentgetTopBarComponent ()
 
KwidgetgetOwner ()
 

Public Attributes

std::function< void(const String &)> onDelete
 

Protected Member Functions

std::unique_ptr< SliderParameterAttachment > createParameterAttachment (const String &paramID, Slider &slider)
 
std::unique_ptr< ButtonParameterAttachment > createParameterAttachment (const String &paramID, Button &button)
 
std::unique_ptr< ComboBoxParameterAttachment > createParameterAttachment (const String &paramID, ComboBox &comboBox)
 
std::unique_ptr< ParameterAttachment > createParameterAttachment (const String &paramID, std::function< void(float)> callback)
 
std::unique_ptr< LabelCustomParameterAttachmentcreateCustomParameterAttachment (const String &paramID, Label &label)
 
template<typename AttachedComponentType >
void addAttachedComponent (AttachedComponentType &component, const String &paramID, bool isDraggable=true)
 
template<typename AttachedComponentType >
void addAttachedComponent (Component &parent, AttachedComponentType &component, const String &paramID, bool isDraggable=true)
 
void addParameterCallback (const String &paramID, std::function< void(float)> callback)
 

Protected Attributes

bool m_ignorePadding {false}
 
Rectangle< int > m_currentBounds
 
TextButton m_selectButton
 
TextButton m_deleteButton
 
Colour m_borderColour {Colours::fuchsia}
 
TopBarComponent m_topBarComponent
 
RenderStyle m_renderStyle {RenderStyle::normal}
 

Private Attributes

Kwidgetm_owner
 
UndoManager * m_undoManager {nullptr}
 
OwnedArray< KParameter::AsyncListenerObjectm_parameterCallbacks
 
ComponentDragger m_dragger
 
bool m_allowDrag {false}
 

Detailed Description

Interface for a UI Component that controls a KwidgetProcessor.

The KwidgetGUI class provides an interface for creating and managing the graphical user interface (GUI) of a specific type of Kwidget. Inherit from this class to define the UI of a custom Kwidget.

This class offers various functionalities to manage the UI, including rendering, resizing, and handling mouse events. Additionally, KwidgetGUI inherits from ActionBroadcaster to facilitate the broadcasting of analytics events and other actions to registered listeners.

Member Enumeration Documentation

◆ RenderStyle

Enumerator
normal 
borderless 
borderless_with_buttons 
minimised 
NUM_STYLES 

Constructor & Destructor Documentation

◆ KwidgetGUI()

krotos::KwidgetGUI::KwidgetGUI ( Kwidget & owner)

◆ ~KwidgetGUI()

krotos::KwidgetGUI::~KwidgetGUI ( )
overridedefault

Destructor.

Member Function Documentation

◆ addAttachedComponent() [1/2]

template<typename AttachedComponentType >
void krotos::KwidgetGUI::addAttachedComponent ( AttachedComponentType & component,
const String & paramID,
bool isDraggable = true )
inlineprotected

Code duplication saving helper function for an AttachedSlider or AttachedToggleButton, to addAndMakeVisible, enable drag and drop, and create a parameter attachment.

◆ addAttachedComponent() [2/2]

template<typename AttachedComponentType >
void krotos::KwidgetGUI::addAttachedComponent ( Component & parent,
AttachedComponentType & component,
const String & paramID,
bool isDraggable = true )
inlineprotected

Code duplication saving helper function for an AttachedSlider or AttachedToggleButton, to addAndMakeVisible, enable drag and drop, and create a parameter attachment.

◆ addParameterCallback()

void krotos::KwidgetGUI::addParameterCallback ( const String & paramID,
std::function< void(float)> callback )
protected

Add an action to be performed when a specified parameter changes value.

Parameters
paramIDThe ID of the parameter to listen to.
callbackThe action to be performed when the parameter changes value.

◆ createCustomParameterAttachment()

std::unique_ptr< LabelCustomParameterAttachment > krotos::KwidgetGUI::createCustomParameterAttachment ( const String & paramID,
Label & label )
protected

◆ createParameterAttachment() [1/4]

std::unique_ptr< ButtonParameterAttachment > krotos::KwidgetGUI::createParameterAttachment ( const String & paramID,
Button & button )
protected

◆ createParameterAttachment() [2/4]

std::unique_ptr< ComboBoxParameterAttachment > krotos::KwidgetGUI::createParameterAttachment ( const String & paramID,
ComboBox & comboBox )
protected

◆ createParameterAttachment() [3/4]

std::unique_ptr< SliderParameterAttachment > krotos::KwidgetGUI::createParameterAttachment ( const String & paramID,
Slider & slider )
protected

◆ createParameterAttachment() [4/4]

std::unique_ptr< ParameterAttachment > krotos::KwidgetGUI::createParameterAttachment ( const String & paramID,
std::function< void(float)> callback )
protected

◆ divideIntByFloat()

int krotos::KwidgetGUI::divideIntByFloat ( int dividend,
float divisor )
inline

Helper function for dividing bounds (usually integers) by floats

◆ finalSetup()

virtual void krotos::KwidgetGUI::finalSetup ( )
inlinevirtual

Your GUI can override this to get a callback when everything is created and after the first resize() is called

Reimplemented in krotos::KwidgetGUI_CoreEngine, and krotos::KwidgetGUI_Reformer.

◆ getKwidgetID()

const String & krotos::KwidgetGUI::getKwidgetID ( ) const

Get the ID of the Kwidget represented by this UI object (ex. "Sine0").

◆ getKwidgetType()

const String & krotos::KwidgetGUI::getKwidgetType ( ) const

Get the type of Kwidget represented by this UI object (ex. "Sine").

◆ getOwner()

Kwidget & krotos::KwidgetGUI::getOwner ( )

Get top level Kwidget

◆ getTopBarComponent()

TopBarComponent & krotos::KwidgetGUI::getTopBarComponent ( )
inline

Return the topBarComponent.

◆ ignorePadding()

void krotos::KwidgetGUI::ignorePadding ( bool ignore)
inline

Should this kwidget have padding around it's border

◆ mouseDown()

void krotos::KwidgetGUI::mouseDown ( const MouseEvent & event)
override

Component MouseEvent overrides.

◆ moved()

void krotos::KwidgetGUI::moved ( )
override

◆ multiplyIntByFloat()

int krotos::KwidgetGUI::multiplyIntByFloat ( int mult,
float factor )
inline

Helper function for multiplying bounds (usually integers) by floats

◆ paint()

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

Perform any paint functions common to all Kwidgets here.

◆ resized()

void krotos::KwidgetGUI::resized ( )
override

Resize the elements of this class using this function. Subclasses will use kwidgetResized() to set their bounds.

◆ setRenderStyle()

void krotos::KwidgetGUI::setRenderStyle ( RenderStyle newStyle)

Set the style we wish derived classes to use when they render themselves Derived classes have access to the style choice via protected member enum m_renderStyle

Member Data Documentation

◆ m_allowDrag

bool krotos::KwidgetGUI::m_allowDrag {false}
private

◆ m_borderColour

Colour krotos::KwidgetGUI::m_borderColour {Colours::fuchsia}
protected

◆ m_currentBounds

Rectangle<int> krotos::KwidgetGUI::m_currentBounds
protected

◆ m_deleteButton

TextButton krotos::KwidgetGUI::m_deleteButton
protected

◆ m_dragger

ComponentDragger krotos::KwidgetGUI::m_dragger
private

◆ m_ignorePadding

bool krotos::KwidgetGUI::m_ignorePadding {false}
protected

◆ m_owner

Kwidget& krotos::KwidgetGUI::m_owner
private

◆ m_parameterCallbacks

OwnedArray<KParameter::AsyncListenerObject> krotos::KwidgetGUI::m_parameterCallbacks
private

◆ m_renderStyle

RenderStyle krotos::KwidgetGUI::m_renderStyle {RenderStyle::normal}
protected

◆ m_selectButton

TextButton krotos::KwidgetGUI::m_selectButton
protected

◆ m_topBarComponent

TopBarComponent krotos::KwidgetGUI::m_topBarComponent
protected

◆ m_undoManager

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

◆ onDelete

std::function<void(const String&)> krotos::KwidgetGUI::onDelete

Callback on deletion of the kwidget gui


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