Jamba C++ API  4.3.0
ScrollbarView Class Reference

Generic scrollbar which handles scrolling and (optional) zooming via handles. More...

#include <ScrollbarView.h>

Inherits CustomView.

Classes

class  Creator
 
struct  ZoomBox
 Represents the box (dimension and position point of view) containing the zoom handles and scrollbar. More...
 

Public Member Functions

void draw (CDrawContext *iContext) override
 
bool getEnableZoomDoubleClick () const
 true to allow zooming on double click on the scrollbar More...
 
Margin const & getMargin () const
 Amount of space (in pixels) to draw around the full scrollbar (includes handles) More...
 
double getOffsetPercent () const
 
ParamID getOffsetPercentTag () const
 id for the parameter tied to offset percent More...
 
const CColor & getScrollbarColor () const
 the color of the scrollbar itself (the rectangle) More...
 
CCoord getScrollbarGutterSpacing () const
 Spacing (in pixels) between the scrollbar and zoom handles (only drawn when zoom handles) More...
 
CCoord getScrollbarMinSize () const
 Minimum size for the scrollbar (in pixels). If -1 it will be auto-computed. More...
 
Range const & getShiftDragFactor () const
 Defines how much to slow down (if less than 1) or accelerate (if more than 1) when shift is held when dragging. More...
 
const CColor & getZoomHandlesColor () const
 Zoom handles color. More...
 
CCoord getZoomHandlesSize () const
 Zoom handles size. If -1 it will be auto-computed. Set to 0 to disable handles entirely. More...
 
double getZoomPercent () const
 
ParamID getZoomPercentTag () const
 id for the parameter tied to zoom percent More...
 
 ScrollbarView (const CRect &iSize)
 
void setEnableZoomDoubleClick (bool iEnableZoomDoubleClick)
 
void setMargin (Margin const &iMargin)
 
void setOffsetPercent (double iOffsetPercent)
 
void setOffsetPercentTag (ParamID offsetPercentTag)
 
void setScrollbarColor (const CColor &iColor)
 
void setScrollbarGutterSpacing (CCoord iScrollbarGutterSpacing)
 
void setScrollbarMinSize (CCoord iScrollbarMinSize)
 
void setShiftDragFactor (Range const &iShiftDragFactor)
 Attribute shift-drag-factor. More...
 
void setZoomHandlesColor (const CColor &iColor)
 
void setZoomHandlesSize (CCoord iSize)
 
void setZoomPercent (double iZoomPercent)
 
void setZoomPercentTag (ParamID zoomPercentTag)
 
bool showHandles () const
 
- Public Member Functions inherited from CustomView
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...
 
 CustomView (const CRect &iSize)
 
 CustomView (const CustomView &c)=delete
 
void draw (CDrawContext *iContext) override
 The basic draw method which will erase the background with the back color. More...
 
virtual void drawBackColor (CDrawContext *iContext)
 Draws the back color (if not set to transparent) More...
 
void drawStyleChanged ()
 Called when the draw style is changed (simply marks the view dirty) More...
 
CColor const & getBackColor () const
 The back color (background) for the view. More...
 
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 setBackColor (CColor const &iColor)
 
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 Types

enum  DragType {
  kNone, kScroll, kZoomLeft, kZoomRight,
  kStretchLeft, kStretchRight
}
 

Protected Member Functions

ZoomBox computeZoomBox () const
 
virtual void drawLeftHandle (CDrawContext *iContext)
 
virtual void drawRightHandle (CDrawContext *iContext)
 
virtual void drawScrollbar (CDrawContext *iContext)
 
CCoord getScrollbarWidth () const
 
void needsRecomputing ()
 
CMouseEventResult onMouseCancel () override
 
CMouseEventResult onMouseDown (CPoint &where, const CButtonState &buttons) override
 
CMouseEventResult onMouseMoved (CPoint &where, const CButtonState &buttons) override
 
CMouseEventResult onMouseUp (CPoint &where, const CButtonState &buttons) override
 
void onParameterChange (ParamID iParamID) override
 Callback when a parameter changes. More...
 
void recompute ()
 
void registerParameters () override
 Subclasses should override this method to register each parameter. More...
 
void setViewSize (const CRect &rect, bool invalid) override
 
- Protected Member Functions inherited from CustomView
void sizeToFit (CCoord iWidth, CCoord iHeight)
 Convenient call to size to fit this view according to the and height provided. More...
 
bool sizeToFit (BitmapPtr iBitmap, int iFrameCount=1)
 Convenient call to size to fit this view to match the bitmap. More...
 

Protected Attributes

RelativeCoord fDragGestureX {-1.0}
 
DragType fDragType {DragType::kNone}
 
bool fEnableZoomDoubleClick {true}
 
AbsoluteRect fLeftHandleRect
 
Margin fMargin {}
 
bool fNeedsRecomputing {true}
 
GUIOptionalParamEditor< ParamValue > fOffsetPercentEditor {}
 
GUIOptionalParam< ParamValue > fOffsetPercentParam {}
 
ParamID fOffsetPercentTag {UNDEFINED_PARAM_ID}
 
AbsoluteRect fRightHandleRect
 
CColor fScrollbarColor {kWhiteCColor}
 
CCoord fScrollbarGutterSpacing {1}
 
CCoord fScrollbarMinSize {-1}
 
AbsoluteRect fScrollbarRect
 
Range fShiftDragFactor {1.0}
 
ZoomBox fZoomBox {}
 
CColor fZoomHandlesColor {kWhiteCColor}
 
CCoord fZoomHandlesSize {-1}
 
GUIOptionalParamEditor< ParamValue > fZoomPercentEditor {}
 
GUIOptionalParam< ParamValue > fZoomPercentParam {}
 
ParamID fZoomPercentTag {UNDEFINED_PARAM_ID}
 
- Protected Attributes inherited from CustomView
CColor fBackColor
 
ParamID fTag
 
- Protected Attributes inherited from ParamAware
std::unique_ptr< GUIParamCxMgrfParamCxMgr {}
 

Detailed Description

Generic scrollbar which handles scrolling and (optional) zooming via handles.

The scrollbar is driven by 2 parameters which can be tied to Vst or Jmb parameters:

  • offsetPercent which represents the position of the scrollbar as a percent (0 means completely left, 1 means completely right)
  • zoomPercent which represents the size of the scrollbar as a percent (0 means completely zoomed out (hence the scrollbar is full), 1 means completely zoomed in (hence the scrollbar is at its minimum size)). At the moment, it handles only horizontal scrollbar.

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

Attribute Description
offset-percent-tag id for the parameter tied to offset percent
zoom-percent-tag id for the parameter tied to zoom percent
margin Amount of space (in pixels) to draw around the full scrollbar (includes handles)
scrollbar-color the color of the scrollbar itself (the rectangle)
scrollbar-min-size Minimum size for the scrollbar (in pixels). If -1 it will be auto-computed.
scrollbar-gutter-spacing Spacing (in pixels) between the scrollbar and zoom handles (only drawn when zoom handles)
zoom-handles-color Zoom handles color.
zoom-handles-size Zoom handles size. If -1 it will be auto-computed. Set to 0 to disable handles entirely.
shift-drag-factor Defines how much to slow down (if less than 1) or accelerate (if more than 1) when shift is held when dragging.
Note
This attribute defines a range (which can be a degenerate range when both from and to are the same) in the event you want the factor to vary depending on how zoomed the scrollbar is. For example: shift-drag-factor="0.01,0.5"
enable-zoom-double-click true to allow zooming on double click on the scrollbar

Member Enumeration Documentation

◆ DragType

enum DragType
strongprotected
Enumerator
kNone 
kScroll 
kZoomLeft 
kZoomRight 
kStretchLeft 
kStretchRight 

Constructor & Destructor Documentation

◆ ScrollbarView()

ScrollbarView ( const CRect &  iSize)
inlineexplicit

Member Function Documentation

◆ computeZoomBox()

ScrollbarView::ZoomBox computeZoomBox ( ) const
protected

◆ draw()

void draw ( CDrawContext *  iContext)
override

◆ drawLeftHandle()

void drawLeftHandle ( CDrawContext *  iContext)
protectedvirtual

◆ drawRightHandle()

void drawRightHandle ( CDrawContext *  iContext)
protectedvirtual

◆ drawScrollbar()

void drawScrollbar ( CDrawContext *  iContext)
protectedvirtual

◆ getEnableZoomDoubleClick()

bool getEnableZoomDoubleClick ( ) const
inline

true to allow zooming on double click on the scrollbar

◆ getMargin()

Margin const& getMargin ( ) const
inline

Amount of space (in pixels) to draw around the full scrollbar (includes handles)

◆ getOffsetPercent()

double getOffsetPercent ( ) const

◆ getOffsetPercentTag()

ParamID getOffsetPercentTag ( ) const
inline

id for the parameter tied to offset percent

◆ getScrollbarColor()

const CColor& getScrollbarColor ( ) const
inline

the color of the scrollbar itself (the rectangle)

◆ getScrollbarGutterSpacing()

CCoord getScrollbarGutterSpacing ( ) const
inline

Spacing (in pixels) between the scrollbar and zoom handles (only drawn when zoom handles)

◆ getScrollbarMinSize()

CCoord getScrollbarMinSize ( ) const
inline

Minimum size for the scrollbar (in pixels). If -1 it will be auto-computed.

◆ getScrollbarWidth()

CCoord getScrollbarWidth ( ) const
protected

◆ getShiftDragFactor()

Range const& getShiftDragFactor ( ) const
inline

Defines how much to slow down (if less than 1) or accelerate (if more than 1) when shift is held when dragging.

Note
This attribute defines a range (which can be a degenerate range when both from and to are the same) in the event you want the factor to vary depending on how zoomed the scrollbar is. For example: shift-drag-factor="0.01,0.5"

◆ getZoomHandlesColor()

const CColor& getZoomHandlesColor ( ) const
inline

Zoom handles color.

◆ getZoomHandlesSize()

CCoord getZoomHandlesSize ( ) const
inline

Zoom handles size. If -1 it will be auto-computed. Set to 0 to disable handles entirely.

◆ getZoomPercent()

double getZoomPercent ( ) const

◆ getZoomPercentTag()

ParamID getZoomPercentTag ( ) const
inline

id for the parameter tied to zoom percent

◆ needsRecomputing()

void needsRecomputing ( )
inlineprotected

◆ onMouseCancel()

CMouseEventResult onMouseCancel ( )
overrideprotected

◆ onMouseDown()

CMouseEventResult onMouseDown ( CPoint &  where,
const CButtonState &  buttons 
)
overrideprotected

◆ onMouseMoved()

CMouseEventResult onMouseMoved ( CPoint &  where,
const CButtonState &  buttons 
)
overrideprotected

◆ onMouseUp()

CMouseEventResult onMouseUp ( CPoint &  where,
const CButtonState &  buttons 
)
overrideprotected

◆ onParameterChange()

void onParameterChange ( ParamID  iParamID)
overrideprotectedvirtual

Callback when a parameter changes.

By default simply marks the view as dirty. This method is intended to be overriden to implement specific behavior.

Reimplemented from CustomView.

◆ recompute()

void recompute ( )
protected

◆ registerParameters()

void registerParameters ( )
overrideprotectedvirtual

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.

◆ setEnableZoomDoubleClick()

void setEnableZoomDoubleClick ( bool  iEnableZoomDoubleClick)
inline

◆ setMargin()

void setMargin ( Margin const &  iMargin)
inline

◆ setOffsetPercent()

void setOffsetPercent ( double  iOffsetPercent)

◆ setOffsetPercentTag()

void setOffsetPercentTag ( ParamID  offsetPercentTag)

◆ setScrollbarColor()

void setScrollbarColor ( const CColor &  iColor)
inline

◆ setScrollbarGutterSpacing()

void setScrollbarGutterSpacing ( CCoord  iScrollbarGutterSpacing)
inline

◆ setScrollbarMinSize()

void setScrollbarMinSize ( CCoord  iScrollbarMinSize)
inline

◆ setShiftDragFactor()

void setShiftDragFactor ( Range const &  iShiftDragFactor)
inline

Attribute shift-drag-factor.

◆ setViewSize()

void setViewSize ( const CRect &  rect,
bool  invalid 
)
overrideprotected

◆ setZoomHandlesColor()

void setZoomHandlesColor ( const CColor &  iColor)
inline

◆ setZoomHandlesSize()

void setZoomHandlesSize ( CCoord  iSize)
inline

◆ setZoomPercent()

void setZoomPercent ( double  iZoomPercent)

◆ setZoomPercentTag()

void setZoomPercentTag ( ParamID  zoomPercentTag)

◆ showHandles()

bool showHandles ( ) const
inline

Member Data Documentation

◆ fDragGestureX

RelativeCoord fDragGestureX {-1.0}
protected

◆ fDragType

DragType fDragType {DragType::kNone}
protected

◆ fEnableZoomDoubleClick

bool fEnableZoomDoubleClick {true}
protected

◆ fLeftHandleRect

AbsoluteRect fLeftHandleRect
protected

◆ fMargin

Margin fMargin {}
protected

◆ fNeedsRecomputing

bool fNeedsRecomputing {true}
protected

◆ fOffsetPercentEditor

GUIOptionalParamEditor<ParamValue> fOffsetPercentEditor {}
protected

◆ fOffsetPercentParam

GUIOptionalParam<ParamValue> fOffsetPercentParam {}
protected

◆ fOffsetPercentTag

ParamID fOffsetPercentTag {UNDEFINED_PARAM_ID}
protected

◆ fRightHandleRect

AbsoluteRect fRightHandleRect
protected

◆ fScrollbarColor

CColor fScrollbarColor {kWhiteCColor}
protected

◆ fScrollbarGutterSpacing

CCoord fScrollbarGutterSpacing {1}
protected

◆ fScrollbarMinSize

CCoord fScrollbarMinSize {-1}
protected

◆ fScrollbarRect

AbsoluteRect fScrollbarRect
protected

◆ fShiftDragFactor

Range fShiftDragFactor {1.0}
protected

◆ fZoomBox

ZoomBox fZoomBox {}
protected

◆ fZoomHandlesColor

CColor fZoomHandlesColor {kWhiteCColor}
protected

◆ fZoomHandlesSize

CCoord fZoomHandlesSize {-1}
protected

◆ fZoomPercentEditor

GUIOptionalParamEditor<ParamValue> fZoomPercentEditor {}
protected

◆ fZoomPercentParam

GUIOptionalParam<ParamValue> fZoomPercentParam {}
protected

◆ fZoomPercentTag

ParamID fZoomPercentTag {UNDEFINED_PARAM_ID}
protected

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