Jamba Views / Step Button

Step Button

Step Button

A step button lets you step through the values of a parameter by repeatedly clicking on the button.

This view works for any parameter (both Vst and Jmb) that is (or can be interpreted as) a discrete parameter.

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

Attribute Description
step-increment Value by which this button will increment (positive) or decrement (negative) the parameter.
shift-step-increment Value by which this button will increment (positive) or decrement (negative) the parameter when the shift key modified is being held. This allows to have bigger steps (or smaller steps) when shift is used.
wrap Defines what happens when the value reaches its end of range after being incremented (resp. decremented). When set to true it will wrap around, otherwise it will remain at its max (resp. min)
held-color Color to use when the button is held and no image is provided.
released-color Color to use when the button is not held and no image is provided.
button-image The image for the button (2 frames).
arrow-direction Used only when no bitmap provided in order to draw an arrow pointing in the direction defined by this attribute. A value of auto will trigger the rendering of an arrow up if step-increment is positive, and down if negative.

The image above shows an example of a vst parameter representing the encoding for exporting a sound file. The vst parameter is backed by a discrete value (a VST parameter where step count > 0), in this case it is backed by an enum. The UI shows 2 step buttons to manipulate the parameter (one to go up and one to go down and it wraps around). The UI also shows a label tied to the same parameter for visual feedback.


The XML defining the 2 step buttons (and label) (Source)

<view button-image="arrow_up" class="jamba::StepButton" control-tag="Param_ExportSampleMinorFormat" origin="490, 63" shift-step-increment="1" size="17, 15" step-increment="1" wrap="true" .../>
<view button-image="arrow_down" class="jamba::StepButton" control-tag="Param_ExportSampleMinorFormat" origin="490, 78" shift-step-increment="-1" size="17, 15" step-increment="-1" wrap="true" .../>
<view class="CTextLabel" control-tag="Param_ExportSampleMinorFormat" font="~ NormalFontSmaller" ffont-color="LCD Foreground"origin="430, 69" size="55, 15" text-alignment="center" title="PCM 24" .../>

The vst param is defined this way (discrete parameter => represented by an enum) (Source)

// enum ESampleMinorFormat { kSampleFormatPCM16, kSampleFormatPCM24, kSampleFormatPCM32 };
VstParam<SampleStorage::ESampleMinorFormat> fExportSampleMinorFormat;

The vst param is initialized this way (Source)

using MinorFormat = SampleStorage::ESampleMinorFormat;
fExportSampleMinorFormat =
  vst<EnumParamConverter<MinorFormat, MinorFormat::kSampleFormatPCM32>>(ESampleSplitterParamID::kExportSampleMinorFormat,
                                                                        STR16("Minor Format"),
                                                                        {{STR16("PCM 16"), STR16("PCM 24"), STR16("PCM 32")}})