Jamba C++ API  5.1.1
TextButtonView Class Reference

Extension of the CTextButton view to add more functionality. More...

#include <TextButtonView.h>

Inherits CustomViewAdapter< CTextButton >.

Classes

class  Creator
 

Public Types

using OnClickListener = std::function< void()>
 
- Public Types inherited from CustomViewAdapter< CTextButton >
using creator_super_type = TCustomViewCreator< CustomViewAdapter >
 

Public Member Functions

virtual void click ()
 
void draw (CDrawContext *context) override
 
GradientPtr getDisabledGradient () const
 Gradient used to draw the button when no image is provided and the button is disabled. More...
 
CColor const & getDisabledTextColor () const
 Color used to draw the title when no image is provided and the button is disabled. More...
 
BitmapPtr getImage () const
 The image for the button. More...
 
bool getImageHasDisabledState () const
 Used when drawing the image. More...
 
int32 getPrecisionOverride () const
 Allow to override the precision of the parameter. More...
 
ParamID getTitleTag () const
 Optional id of the parameter whose string representation (IGUIParameter::toUTF8String()) will be used as the title for this button. More...
 
virtual void onClick ()
 
void registerParameters () override
 Subclasses should override this method to register each parameter. More...
 
virtual void setDisabledGradient (GradientPtr iGradient)
 Attribute disabled-gradient. More...
 
virtual void setDisabledTextColor (CColor const &iColor)
 Attribute disabled-text-color. More...
 
void setImage (BitmapPtr iImage)
 
void setImageHasDisabledState (bool iValue)
 
void setMouseEnabled (bool bEnable) override
 
void setOnClickListener (OnClickListener iListener)
 
void setPrecisionOverride (int32 iPrecisionOverride)
 
virtual void setTitleTag (ParamID iValue)
 Attribute title-tag. More...
 
 TextButtonView (const CRect &iSize)
 
virtual void unClick ()
 
void valueChanged () override
 
- Public Member Functions inherited from CustomViewAdapter< CTextButton >
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 void drawButtonImage (CDrawContext *context)
 Called when the button is simply rendered as an image. More...
 
virtual void drawButtonText (CDrawContext *context)
 Called when the button should be drawn entirely (background + text + icon) More...
 

Protected Attributes

GradientSPtr fDisabledGradient
 
CColor fDisabledTextColor
 
BitmapSPtr fImage {nullptr}
 
bool fImageHasDisabledState {false}
 
OnClickListener fOnClickListener {}
 
int32 fPrecisionOverride {-1}
 
ParamID fTitleTag {UNDEFINED_PARAM_ID}
 
- Protected Attributes inherited from CustomViewAdapter< CTextButton >
TagID fTag
 
- Protected Attributes inherited from ParamAware
std::unique_ptr< GUIParamCxMgrfParamCxMgr {}
 

Detailed Description

Extension of the CTextButton view to add more functionality.

In addition to the behavior provided by CTextButton, this class adds the following functionality:

  • have a (potentially) dynamic title tied to a parameter (via title-tag / TextButtonView::fTitleTag)
  • handle click conveniently (either inherit from this class and implement onClick(), or provide an onClick listener)
  • optionally handle image (3 states : disabled / off / on)

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

Attribute Description
title-tag Optional id of the parameter whose string representation (IGUIParameter::toUTF8String()) will be used as the title for this button.
disabled-text-color Color used to draw the title when no image is provided and the button is disabled.
disabled-gradient Gradient used to draw the button when no image is provided and the button is disabled.
button-image

The image for the button. If button-image-has-disabled-state is true then the image should contain the following 3 frames (each is of size image height / 3):

y frame
0 the button in its disabled state
1 * image height / 3 the button in its "off" state
2 * image height / 3 the button in its "on" state

Example: 3 frames example

If button-image-has-disabled-state is false then the image should contain the following 2 frames (each is of size image height / 2):

y frame
0 the button in its "off" state
image height / 2 the button in its "on" state

Example: 2 frames example

button-image-has-disabled-state

Used when drawing the image. If true, the image contains a disabled state (3 frames) otherwise it doesn't (2 frames).

See also
getImage() for details on how the frames are laid out in the image
precision-override

Allow to override the precision of the parameter. If set to its default (-1), lets the parameter determine what the precision is (when displaying numbers), but if set >= 0 it will use the attribute value instead.

See also
IGUIParameter::toUTF8String()

Member Typedef Documentation

◆ OnClickListener

using OnClickListener = std::function<void()>

Constructor & Destructor Documentation

◆ TextButtonView()

TextButtonView ( const CRect &  iSize)
inlineexplicit

Member Function Documentation

◆ click()

void click ( )
virtual

◆ draw()

void draw ( CDrawContext *  context)
override

◆ drawButtonImage()

void drawButtonImage ( CDrawContext *  context)
protectedvirtual

Called when the button is simply rendered as an image.

See also
getImage()

◆ drawButtonText()

void drawButtonText ( CDrawContext *  context)
protectedvirtual

Called when the button should be drawn entirely (background + text + icon)

◆ getDisabledGradient()

GradientPtr getDisabledGradient ( ) const
inline

Gradient used to draw the button when no image is provided and the button is disabled.

◆ getDisabledTextColor()

CColor const& getDisabledTextColor ( ) const
inline

Color used to draw the title when no image is provided and the button is disabled.

◆ getImage()

BitmapPtr getImage ( ) const
inline

The image for the button.

If button-image-has-disabled-state is true then the image should contain the following 3 frames (each is of size image height / 3):

y frame
0 the button in its disabled state
1 * image height / 3 the button in its "off" state
2 * image height / 3 the button in its "on" state

Example: 3 frames example

If button-image-has-disabled-state is false then the image should contain the following 2 frames (each is of size image height / 2):

y frame
0 the button in its "off" state
image height / 2 the button in its "on" state

Example: 2 frames example

◆ getImageHasDisabledState()

bool getImageHasDisabledState ( ) const
inline

Used when drawing the image.

If true, the image contains a disabled state (3 frames) otherwise it doesn't (2 frames).

See also
getImage() for details on how the frames are laid out in the image

◆ getPrecisionOverride()

int32 getPrecisionOverride ( ) const
inline

Allow to override the precision of the parameter.

If set to its default (-1), lets the parameter determine what the precision is (when displaying numbers), but if set >= 0 it will use the attribute value instead.

See also
IGUIParameter::toUTF8String()

◆ getTitleTag()

ParamID getTitleTag ( ) const
inline

Optional id of the parameter whose string representation (IGUIParameter::toUTF8String()) will be used as the title for this button.

◆ onClick()

void onClick ( )
virtual

◆ 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.

◆ setDisabledGradient()

virtual void setDisabledGradient ( GradientPtr  iGradient)
inlinevirtual

Attribute disabled-gradient.

◆ setDisabledTextColor()

virtual void setDisabledTextColor ( CColor const &  iColor)
inlinevirtual

Attribute disabled-text-color.

◆ setImage()

void setImage ( BitmapPtr  iImage)
inline

◆ setImageHasDisabledState()

void setImageHasDisabledState ( bool  iValue)
inline

◆ setMouseEnabled()

void setMouseEnabled ( bool  bEnable)
override

◆ setOnClickListener()

void setOnClickListener ( OnClickListener  iListener)
inline

◆ setPrecisionOverride()

void setPrecisionOverride ( int32  iPrecisionOverride)
inline

◆ setTitleTag()

void setTitleTag ( ParamID  iValue)
virtual

Attribute title-tag.

◆ unClick()

void unClick ( )
virtual

◆ valueChanged()

void valueChanged ( )
override

Member Data Documentation

◆ fDisabledGradient

GradientSPtr fDisabledGradient
protected

◆ fDisabledTextColor

CColor fDisabledTextColor
protected

◆ fImage

BitmapSPtr fImage {nullptr}
protected

◆ fImageHasDisabledState

bool fImageHasDisabledState {false}
protected

◆ fOnClickListener

OnClickListener fOnClickListener {}
protected

◆ fPrecisionOverride

int32 fPrecisionOverride {-1}
protected

◆ fTitleTag

ParamID fTitleTag {UNDEFINED_PARAM_ID}
protected

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