Jamba C++ API  4.3.0
SwitchViewContainer Class Reference

This view offers dynamic switching between multiple views. More...

#include <SwitchViewContainer.h>

Inherits CustomViewAdapter< CViewContainer >, and IViewContainerListenerAdapter.

Classes

class  Creator
 

Public Member Functions

virtual void afterCreate (IUIDescription const *iDescription, IController *iController)
 
ParamID getSwitchControlTag () const
 id for the parameter tied to switching. More...
 
const std::vector< std::string > & getTemplateNames () const
 A comma separated list of template names. More...
 
void onParameterChange (ParamID iParamID) override
 This is the callback that should be implemented to handle parameter changes. More...
 
void registerParameters () override
 Subclasses should override this method to register each parameter. More...
 
virtual void setSwitchControlTag (ParamID iTag)
 Attribute switch-control-tag More...
 
void setTemplateNames (const std::vector< std::string > &iNames)
 
 SwitchViewContainer (const CRect &iSize)
 
 ~SwitchViewContainer () override
 
- Public Member Functions inherited from CustomViewAdapter< CViewContainer >
void afterApplyAttributes () override
 Handles the lifecycle behavior getting triggered once all the attributes have been set (which usually happens after the XML file (uidesc) has been read/processed, or when you modify attributes in the VSTGUI Editor). More...
 
 CustomViewAdapter (const CRect &iSize, Args &&...args)
 
TagID getCustomViewTag () const
 The tag associated to this custom view. More...
 
bool getEditorMode () const
 A flag whose purpose is to render/log information during development when the flag is set to true. More...
 
void markDirty ()
 Marks this view dirty which will (at the appropriate time in the rendering lifecycle) trigger a call to draw() More...
 
void onParameterChange (ParamID iParamID) override
 Callback when a parameter changes. More...
 
void setCustomViewTag (TagID iTag)
 
void setEditorMode (bool iEditorMode)
 
- Public Member Functions inherited from ParamAware
virtual void initState (GUIState *iGUIState)
 Called during initialization. More...
 
void invokeAll ()
 Invoke all (currently) registered callbacks and onParameterChange() (if registered). More...
 
IGUIParam registerBaseCallback (ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback)
 Registers a callback for the "base" param for the most generic use case. More...
 
IGUIParam registerBaseCallback (ParamID iParamID, Parameters::ChangeCallback1< IGUIParam > iChangeCallback, bool iInvokeCallback)
 Registers a callback for the "base" param for the most generic use case. More...
 
IGUIParam registerBaseParam (ParamID iParamID, bool iSubscribeToChanges=true)
 Registers the "base" param for the most generic use case but as a result is fairly limited and mainly gives access to the string representation of the param. More...
 
GUIRawVstParam registerCallback (RawVstParam const &iParamDef, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Registers a raw parameter (no conversion). More...
 
GUIRawVstParam registerCallback (RawVstParam const &iParamDef, Parameters::ChangeCallback1< GUIRawVstParam > iChangeCallback, bool iInvokeCallback=false)
 Registers a raw parameter (no conversion). More...
 
template<typename T >
GUIVstParam< T > registerCallback (VstParam< T > const &iParamDef, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Convenient call to register a callback for the Vst param simply by using its description (accessible in state-aware views via fParams->fMyParam). More...
 
template<typename T >
GUIVstParam< T > registerCallback (VstParam< T > const &iParamDef, Parameters::ChangeCallback1< GUIVstParam< T >> iChangeCallback, bool iInvokeCallback=false)
 Convenient call to register a callback for the Vst param simply by using its description (accessible in state-aware views via fParams->fMyParam). More...
 
template<typename T >
GUIJmbParam< T > registerCallback (JmbParam< T > const &iParamDef, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Convenient call to register a callback for the Jmb param simply by using its description (accessible in state-aware views via fParams->fMyParam). More...
 
template<typename T >
GUIJmbParam< T > registerCallback (JmbParam< T > const &iParamDef, Parameters::ChangeCallback1< GUIJmbParam< T >> iChangeCallback, bool iInvokeCallback=false)
 Convenient call to register a callback for the Jmb param simply by using its description (accessible in state-aware views via fParams->fMyParam). More...
 
template<typename T >
GUIJmbParam< T > registerCallback (GUIJmbParam< T > &iParam, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Convenient call to register a callback for the Jmb param simply by using the param from the state (accessible in state-aware views via fState->fMyParam). More...
 
template<typename T >
GUIJmbParam< T > registerCallback (GUIJmbParam< T > &iParam, Parameters::ChangeCallback1< GUIJmbParam< T >> iChangeCallback, bool iInvokeCallback=false)
 Convenient call to register a callback for the Jmb param simply by using the param from the state (accessible in state-aware views via fState->fMyParam). More...
 
template<typename T >
GUIJmbParam< T > registerJmbCallback (ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Registers a callback for the Jmb param by its id and return the wrapper to the param. More...
 
template<typename T >
GUIJmbParam< T > registerJmbCallback (ParamID iParamID, Parameters::ChangeCallback1< GUIJmbParam< T >> iChangeCallback, bool iInvokeCallback=false)
 Registers a callback for the Jmb param by its id and return the wrapper to the param. More...
 
template<typename T >
GUIJmbParam< T > registerJmbParam (ParamID iParamID, bool iSubscribeToChanges=true)
 Registers the Jmb param by its id and return the wrapper to the param. More...
 
template<typename T >
GUIOptionalParam< T > registerOptionalCallback (ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Registers an optional parameter which handles Vst, Jmb or no parameter at all. More...
 
template<typename T >
GUIOptionalParam< T > registerOptionalCallback (ParamID iParamID, Parameters::ChangeCallback1< GUIOptionalParam< T >> iChangeCallback, bool iInvokeCallback=false)
 Registers an optional parameter which handles Vst, Jmb or no parameter at all. More...
 
GUIOptionalParam< int32 > registerOptionalDiscreteCallback (ParamID iParamID, int32 iStepCount, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Registers an optional discrete parameter which handles Vst, Jmb or no parameter at all. More...
 
GUIOptionalParam< int32 > registerOptionalDiscreteCallback (ParamID iParamID, int32 iStepCount, Parameters::ChangeCallback1< GUIOptionalParam< int32 >> iChangeCallback, bool iInvokeCallback=false)
 Registers an optional discrete parameter which handles Vst, Jmb or no parameter at all. More...
 
GUIOptionalParam< int32 > registerOptionalDiscreteParam (ParamID iParamID, int32 iStepCount, bool iSubscribeToChanges=true)
 Registers an optional discrete parameter which handles Vst, Jmb or no parameter at all. More...
 
template<typename T >
GUIOptionalParam< T > registerOptionalParam (ParamID iParamID, bool iSubscribeToChanges=true)
 Registers an optional parameter which handles Vst, Jmb or no parameter at all. More...
 
GUIRawVstParam registerParam (RawVstParam const &iParamDef, bool iSubscribeToChanges=true)
 Registers a raw parameter (no conversion). More...
 
template<typename T >
GUIVstParam< T > registerParam (VstParam< T > const &iParamDef, bool iSubscribeToChanges=true)
 Convenient call to register a Vst param simply by using its description (accessible in state-aware views via fParams->fMyParam). More...
 
template<typename T >
GUIJmbParam< T > registerParam (JmbParam< T > const &iParamDef, bool iSubscribeToChanges=true)
 Convenient call to register a Jmb param simply by using its description (accessible in state-aware views via fParams->fMyParam). More...
 
template<typename T >
GUIJmbParam< T > registerParam (GUIJmbParam< T > &iParam, bool iSubscribeToChanges=true)
 Convenient call to register a Jmb param simply by using the param from the state (accessible in state-aware views via fState->fMyParam). More...
 
GUIRawVstParam registerRawVstCallback (ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Registers a raw parameter (no conversion) The callback will be invoked when the parameter changes. More...
 
GUIRawVstParam registerRawVstCallback (ParamID iParamID, Parameters::ChangeCallback1< GUIRawVstParam > iChangeCallback, bool iInvokeCallback=false)
 Registers a raw parameter (no conversion) The callback will be invoked when the parameter changes. More...
 
GUIRawVstParam registerRawVstParam (ParamID iParamID, bool iSubscribeToChanges=true)
 Registers a raw parameter (no conversion) onParameterChange() will be called on changes (if iSubscribeToChanges is set to true). More...
 
GUIVstParam< bool > registerVstBooleanParam (ParamID iParamID, bool iSubscribeToChanges=true)
 
template<typename T >
GUIVstParam< T > registerVstCallback (ParamID iParamID, Parameters::ChangeCallback iChangeCallback, bool iInvokeCallback=false)
 Register a callback for a Vst parameter simply given its id The callback will be invoked when the parameter changes. More...
 
template<typename T >
GUIVstParam< T > registerVstCallback (ParamID iParamID, Parameters::ChangeCallback1< GUIVstParam< T >> iChangeCallback, bool iInvokeCallback=false)
 Register a callback for a Vst parameter simply given its id The callback will be invoked when the parameter changes. More...
 
template<typename T >
GUIVstParam< T > registerVstParam (ParamID iParamID, bool iSubscribeToChanges=true)
 Register a Vst parameter simply given its id onParameterChange() will be called on changes (if iSubscribeToChanges is set to true). More...
 
GUIVstParam< PercentregisterVstPercentParam (ParamID iParamID, bool iSubscribeToChanges=true)
 
void unregisterAll ()
 Unregisters all parameters. More...
 
bool unregisterParam (ParamID iParamID)
 Removes the registration of the provided param (closing the connection/stopping to listen) More...
 
GUIRawVstParam unregisterParam (GUIRawVstParam const &iParam)
 Removes the registration of the provided param (closing the connection/stopping to listen) More...
 
template<typename T >
GUIVstParam< T > unregisterParam (GUIVstParam< T > const &iParam)
 Removes the registration of the provided param (closing the connection/stopping to listen) More...
 
template<typename T >
GUIJmbParam< T > unregisterParam (GUIJmbParam< T > const &iParam)
 Removes the registration of the provided param (closing the connection/stopping to listen) More...
 
virtual ~ParamAware ()
 

Protected Member Functions

virtual std::string computeTemplateName (int iIndex)
 Lookup the name of the template in the vector. More...
 
virtual void setCurrentView (CView *iCurrentView)
 Sets the current view to the one provided (remove previous view from container children and add this one). More...
 
virtual void switchCurrentView ()
 Called whenever something has changed to switch to a new current view. More...
 
void viewContainerViewAdded (CViewContainer *container, CView *view) override
 The only purpose of this callback (from IViewContainerListenerAdapter) is to catch the unavoidable cases when the editor will save the children of this class as there does not seem to be a way to prevent this behavior from happening. More...
 

Protected Attributes

GUIOptionalParam< int32 > fControlSwitch {}
 
std::string fCurrentTemplateName {}
 
CView * fCurrentView {}
 
ParamID fSwitchControlTag {UNDEFINED_PARAM_ID}
 
std::vector< std::string > fTemplateNames
 
IController * fUIController {}
 
IUIDescription const * fUIDescription {}
 
- Protected Attributes inherited from CustomViewAdapter< CViewContainer >
TagID fTag
 
- Protected Attributes inherited from ParamAware
std::unique_ptr< GUIParamCxMgrfParamCxMgr {}
 

Additional Inherited Members

- Public Types inherited from CustomViewAdapter< CViewContainer >
using creator_super_type = TCustomViewCreator< CustomViewAdapter >
 

Detailed Description

This view offers dynamic switching between multiple views.

Switching is based on the value of any parameter (both Vst and Jmb) that is (or can be interpreted as) a discrete parameter.

The VST SDK comes with a similar implementation which a) is buggy, b) requires an actual control tied to a vst parameter (so for example does not work with StepButtonView or cannot be changed by the RT). This implementation uses a parameter directly so has none of these restrictions.

Note
When editing the layout using the editor, and saving the xml file, unfortunately the editor will save the children of this class (in this case, the one that was added dynamically). Although the code handles this case, it is recommended (for production) to manually edit the xml file to remove any child of this entry (otherwise objects will be created to be destroyed right away).

In addition to the attributes exposed by CViewContainer, this class exposes the following attributes:

Attribute Description
switch-control-tag id for the parameter tied to switching. It can be any parameter (both Vst and Jmb) that is (or can be interpreted as) a discrete parameter.
template-names

A comma separated list of template names. Should refer to valid templates (in the xml file)

Note
You can use _ for a template name which means displays nothing (make sure you set the container to transparent in this case). Can be used for overlay for example.

Constructor & Destructor Documentation

◆ SwitchViewContainer()

SwitchViewContainer ( const CRect &  iSize)
explicit

◆ ~SwitchViewContainer()

~SwitchViewContainer ( )
override

Member Function Documentation

◆ afterCreate()

void afterCreate ( IUIDescription const *  iDescription,
IController *  iController 
)
virtual

◆ computeTemplateName()

std::string computeTemplateName ( int  iIndex)
protectedvirtual

Lookup the name of the template in the vector.

Can be overridden to implement different behavior

◆ getSwitchControlTag()

ParamID getSwitchControlTag ( ) const
inline

id for the parameter tied to switching.

It can be any parameter (both Vst and Jmb) that is (or can be interpreted as) a discrete parameter.

◆ getTemplateNames()

const std::vector<std::string>& getTemplateNames ( ) const
inline

A comma separated list of template names.

Should refer to valid templates (in the xml file)

Note
You can use _ for a template name which means displays nothing (make sure you set the container to transparent in this case). Can be used for overlay for example.

◆ onParameterChange()

void onParameterChange ( ParamID  iParamID)
overridevirtual

This is the callback that should be implemented to handle parameter changes.

This callback is only invoked if any registerXXParam method is called.

Reimplemented from ParamAware.

◆ registerParameters()

void registerParameters ( )
overridevirtual

Subclasses should override this method to register each parameter.

Jamba automatically calls this method and you should not have to invoke it yourself.

Note
Jamba automatically calls unregisterAll() prior to calling this method so it is ok to assume that there is no parameter registered prior to this call.
This method may be called multiple times during the life of the class inheriting from ParamAware, which is generally the case while using the VSTGUI editor

Reimplemented from ParamAware.

◆ setCurrentView()

void setCurrentView ( CView *  iCurrentView)
protectedvirtual

Sets the current view to the one provided (remove previous view from container children and add this one).

Handles no view properly.

◆ setSwitchControlTag()

virtual void setSwitchControlTag ( ParamID  iTag)
inlinevirtual

Attribute switch-control-tag

◆ setTemplateNames()

void setTemplateNames ( const std::vector< std::string > &  iNames)
inline

◆ switchCurrentView()

void switchCurrentView ( )
protectedvirtual

Called whenever something has changed to switch to a new current view.

◆ viewContainerViewAdded()

void viewContainerViewAdded ( CViewContainer *  container,
CView *  view 
)
overrideprotected

The only purpose of this callback (from IViewContainerListenerAdapter) is to catch the unavoidable cases when the editor will save the children of this class as there does not seem to be a way to prevent this behavior from happening.

Member Data Documentation

◆ fControlSwitch

GUIOptionalParam<int32> fControlSwitch {}
protected

◆ fCurrentTemplateName

std::string fCurrentTemplateName {}
protected

◆ fCurrentView

CView* fCurrentView {}
protected

◆ fSwitchControlTag

ParamID fSwitchControlTag {UNDEFINED_PARAM_ID}
protected

◆ fTemplateNames

std::vector<std::string> fTemplateNames
protected

◆ fUIController

IController* fUIController {}
protected

◆ fUIDescription

IUIDescription const* fUIDescription {}
protected

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