uvi-script
Musical event scripting with Lua
OnOffButton Class Reference

2 states boolean button. More...

Inheritance diagram for OnOffButton:
ParamWidget Widget

Public Member Functions

 OnOffButton (string name, bool def)
 creates a stateful on/off button widget on the user interface.
 
void setValue (bool value, bool callChangedCallback=true)
 
void setStripImage (string imagePath, int numFrames)
 dress the button from one image holding a frame per state, stacked top to bottom in the order off, on, hovered off, hovered on, held off, held on.
 
void setLottieAnimation (string path, string mode)
 dress the button with a Lottie animation.
 

Public Attributes

bool value
 the button's state
 
bool default
 the button's default state
 
bool showPopupDisplay
 show/hide the value popup display (if any)
 
string normalImage
 image path for the off state
 
string pressedImage
 image path for the on state, and for the button while held down
 
string overImage
 image path for the mouse being over the button while it is off
 
string overPressedImage
 image path for the mouse being over the button while it is on
 
string backgroundColourOff
 background colour Off: colour string that defines the desired colour.
 
string textColourOff
 textColour Off: colour string that defines the desired colour.
 
string backgroundColourOn
 background colour On: colour string that defines the desired colour.
 
string textColourOn
 textColour On: colour string that defines the
 
number fontSize
 font size
 
string font
 path to TrueType font
 
bool triggeredOnMouseDown
 Sets whether the button click should happen when the mouse is pressed or released.
 
string stripImage
 path to the strip image.
 
string lottieAnimation
 path to a Lottie animation or package, see Lottie Animations
 
- Public Attributes inherited from ParamWidget
Mapper::Type mapper
 Mapper type, default is Mapper.Linear.
 
Unit::Type unit
 Unit type, default is Unit.Generic.
 
int paramId
 parameter id, assigned automatically (read-only)
 
bool exported
 default: false, set it to true to export this parameter as an automatable parameter
 
- Public Attributes inherited from Widget
string name
 widget name, given at construction (read-only)
 
string displayName
 widget display name
 
string displayText
 custom text to display in place of the standard value display, on widgets that show one.
 
string tooltip
 widget tooltip, default is name
 
int x
 x position in pixels
 
int y
 y position in pixels
 
int width
 widget width in pixels
 
int height
 widget height in pixels
 
int w
 alias of width
 
int h
 alias of height
 
table size
 widget size {width, height}
 
table position
 widget position {x,y}
 
table pos
 alias of position
 
table bounds
 widget bounding rect {x,y,width,height}
 
number alpha
 transparency value between 0.0 and 1.0
 
bool enabled
 boolean flag to enable / disable the widget
 
bool visible
 boolean flag to toggle widget visibility
 
bool interceptsMouseClicks
 boolean flag to toggle mouse handling on widget.
 
bool showLabel
 show widgets label if any
 
bool persistent
 flag to tell if the widget values should be serialized when saving.
 
function changed
 callback function used by child widgets to be notified of changes.
 

Detailed Description

2 states boolean button.

creates a stateful on/off button widget on the user interface. Image properties support Retina @2x variants.

b = OnOffButton("button", false)
b.backgroundColourOff = "darkgrey"
b.backgroundColourOn = "darkred"
b.textColourOff = "white"
b.textColourOn = "white"
b.changed = function(self, mods)
print("button changed state:", self.value, mods and mods.altDown)
end
string textColourOff
textColour Off: colour string that defines the desired colour.
Definition ui.cpp:1158
string textColourOn
textColour On: colour string that defines the
Definition ui.cpp:1167
OnOffButton(string name, bool def)
creates a stateful on/off button widget on the user interface.
string backgroundColourOff
background colour Off: colour string that defines the desired colour.
Definition ui.cpp:1153
string backgroundColourOn
background colour On: colour string that defines the desired colour.
Definition ui.cpp:1162
bool value
the button's state
Definition ui.cpp:1143
function changed
callback function used by child widgets to be notified of changes.
Definition ui.cpp:1001

Constructor & Destructor Documentation

◆ OnOffButton()

OnOffButton::OnOffButton ( string name,
bool def )

creates a stateful on/off button widget on the user interface.

Parameters
namethe name to give to the widget
defdefault value to give to the widget

Member Function Documentation

◆ setLottieAnimation()

void OnOffButton::setLottieAnimation ( string path,
string mode )

dress the button with a Lottie animation.

See Lottie Animations.

Parameters
pathpath to a .json animation or a .lottie package
mode"toggle" walks the animation on and off, "trigger" replays it from the first frame on every click; any other string reads as "toggle". The argument is required – a call with the path alone raises an error. To keep the toggle mode, assign the lottieAnimation property instead

◆ setStripImage()

void OnOffButton::setStripImage ( string imagePath,
int numFrames )

dress the button from one image holding a frame per state, stacked top to bottom in the order off, on, hovered off, hovered on, held off, held on.

Fewer frames are read as the first few of that order, so a strip may stop wherever the separate images stopped. Supports Retina @2x variants.

Parameters
imagePathpath to the strip image
numFrameshow many frames the image holds

◆ setValue()

void OnOffButton::setValue ( bool value,
bool callChangedCallback = true )
Parameters
valuethe new widget's value
callChangedCallbackcall the changed callback function if true

Member Data Documentation

◆ backgroundColourOff

string OnOffButton::backgroundColourOff

background colour Off: colour string that defines the desired colour.

It can be either a named colour like "blue" or "red" or an hexadecimal string in RGB ("#FF00CC") or ARGB ("#3C00FECD") format

◆ backgroundColourOn

string OnOffButton::backgroundColourOn

background colour On: colour string that defines the desired colour.

It can be either a named colour like "blue" or "red" or an hexadecimal string in RGB ("#FF00CC") or ARGB ("#3C00FECD") format

◆ stripImage

string OnOffButton::stripImage

path to the strip image.

Nothing is drawn from a strip until the frame count is given, so assigning this alone is inert – call setStripImage

◆ textColourOff

string OnOffButton::textColourOff

textColour Off: colour string that defines the desired colour.

It can be either a named colour like "blue" or "red" or an hexadecimal string in RGB ("#FF00CC") or ARGB ("#3C00FECD") format

◆ textColourOn

string OnOffButton::textColourOn

textColour On: colour string that defines the

desired colour. It can be either a named colour like "blue" or "red" or an hexadecimal string in RGB ("#FF00CC") or ARGB ("#3C00FECD") format

◆ triggeredOnMouseDown

bool OnOffButton::triggeredOnMouseDown

Sets whether the button click should happen when the mouse is pressed or released.

By default the button is only considered to have been clicked when the mouse is released