Discrete Button |
A discrete button behaves like a toggle button except that it is on
only if the control value (tied to a parameter)
is equal to the step
value (DiscreteButtonView::getStep()
/ step
property in the xml).
Selecting the button will set the underlying parameter to step
. This button can be used to implement a radio group
button behavior (only one selected at a time).
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 |
---|---|
frames |
The number of frames the image contains. Should be either 2 or 4 (4 includes the pressed state). |
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). |
button-image |
The image for the button (2 or 4 frames). |
inverse |
Inverses the meaning of “on” and “off” in regards to drawing the view/image. |
step |
The value used to check whether the button is “on” or “off” as well as the value to set the parameter to when the button is selected. |
Like the toggle button, it can have 2 or 4 frames (handle depressed state).
The image above shows an example of a vst parameter representing a bank (A through D) of pads. The vst parameter is backed by a discrete value (a VST parameter where step count > 0). The UI shows 4 discrete buttons each one tied to a different step. Because a discrete button is on
only when the vst parameter matches its step, selecting one will automatically deselect the others.
The json defining the 4 buttons (Source)
"jamba::DiscreteButton": {
"attributes": {
"back-color": "~ TransparentCColor",
"button-image": "bankA",
"class": "jamba::DiscreteButton",
"control-tag": "Param_PadBank",
"editor-mode": "false",
"frames": "2",
"inverse": "false",
"mouse-enabled": "true",
"on-color": "~ RedCColor",
"opacity": "1",
"origin": "415, 291",
"size": "26, 26",
"step": "0",
"step-count": "-1",
"transparent": "false",
"wants-focus": "false"
}
},
"jamba::DiscreteButton": {
"attributes": {
"back-color": "~ TransparentCColor",
"button-image": "bankB",
"class": "jamba::DiscreteButton",
"control-tag": "Param_PadBank",
"editor-mode": "false",
"frames": "2",
"inverse": "false",
"mouse-enabled": "true",
"on-color": "~ RedCColor",
"opacity": "1",
"origin": "450, 291",
"size": "26, 26",
"step": "1",
"step-count": "-1",
"transparent": "false",
"wants-focus": "false"
}
},
"jamba::DiscreteButton": {
"attributes": {
"back-color": "~ TransparentCColor",
"button-image": "bankC",
"class": "jamba::DiscreteButton",
"control-tag": "Param_PadBank",
"editor-mode": "false",
"frames": "2",
"inverse": "false",
"mouse-enabled": "true",
"on-color": "~ RedCColor",
"opacity": "1",
"origin": "485, 291",
"size": "26, 26",
"step": "2",
"step-count": "-1",
"transparent": "false",
"wants-focus": "false"
}
},
"jamba::DiscreteButton": {
"attributes": {
"back-color": "~ TransparentCColor",
"button-image": "bankD",
"class": "jamba::DiscreteButton",
"control-tag": "Param_PadBank",
"editor-mode": "false",
"frames": "2",
"inverse": "false",
"mouse-enabled": "true",
"on-color": "~ RedCColor",
"opacity": "1",
"origin": "520, 291",
"size": "26, 26",
"step": "3",
"step-count": "-1",
"transparent": "false",
"wants-focus": "false"
}
},
The vst param is defined this way (discrete parameter => represented by int) (Source)
VstParam<int> fPadBank;
The vst param is initialized this way (Source)
fPadBank =
vst<DiscreteValueParamConverter<NUM_PAD_BANKS - 1>>(ESampleSplitterParamID::kPadBank,
STR16("Page"),
STR16("Page %d"), 1)
.defaultValue(0)
.shortTitle(STR16("Page"))
.add();