Jamba Views / Momentary Button

Momentary Button

Momentary Button

A momentary button is a button that lets you set the value of a parameter to its “on” value when pressed, otherwise its “off” value.

This view is designed to handle parameters which are backed by a bool representation but it works for any parameter (both Vst and Jmb) that is (or can be interpreted as) a discrete parameter.

Info

This view defines the “on” state as being the opposite of the “off” state and so the “off” state is the one being checked against the off value (otherwise we could end up in a situation where both isOn and isOff are true…). The consequence is that the underlying parameter might have a value that is neither the “off” value nor the “on” value, but for the sake of this view it will be treated as “on” (similarly to C/C++ where 0 is false and any non-zero is true).

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

Attribute Description
on-step Maps to the “on” value unless it is set to its default (-1) value in which case it maps to getStepCount() (should be -1 or a value in [0, stepCount]).
off-step Maps to the “off” value unless it is set to its default (-1) value in which case it maps to 0 (should be -1 or a value in [0, stepCount]).
on-color When no image is provided, back-color is used for the “off” state and on-color for the “on” state (draws a rectangle with this color).
disabled-color When no image is provided and the control is disabled, this color is used instead.
button-image The image to use to draw the button (2 or 3 frames).
button-image-has-disabled-state Flag to determine whether the image contains a disabled state (3 frames) or not (2 frames).
inverse Inverses the meaning of “on” and “off” in regards to drawing the view/image.

Example

The XML defining the button (2 frames) (Source)

<view button-image="Button_small_2frames" class="jamba::MomentaryButton" control-tag="Param_MaxLevelReset" origin="358, 45" size="20, 22" ... />

The vst param is defined this way (boolean parameter) (Source)

VstParam<bool> fMaxLevelResetParam;

The vst param is initialized this way (Source)

fMaxLevelResetParam =
  vst<BooleanParamConverter>(EVAC6ParamID::kMaxLevelReset, STR16 ("Max Level Reset"))
    .defaultValue(false)
    .shortTitle(STR16 ("Max Lvl Rst"))
    .transient()
    .add();