Skip to main content

Vector Button Control

IVButtonControl is a momentary button (triggers action when clicked).

Constructor

IVButtonControl(
  const IRECT& bounds,
  IActionFunction aF = SplashClickActionFunc,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  bool labelInButton = true,
  bool valueInButton = true,
  EVShape shape = EVShape::Rectangle
);
bounds
IRECT
required
Position and size of the button
aF
IActionFunction
default:"SplashClickActionFunc"
Function to execute on button click
label
const char*
default:"empty string"
Button label text
style
IVStyle
default:"DEFAULT_STYLE"
Visual styling
labelInButton
bool
default:"true"
If true, label drawn inside button
valueInButton
bool
default:"true"
If true, value drawn inside button
shape
EVShape
default:"EVShape::Rectangle"
Button shape: Rectangle, Ellipse, Triangle, or EndsRounded

Example

// Simple button with lambda
pGraphics->AttachControl(
  new IVButtonControl(
    IRECT(10, 10, 110, 40),
    [](IControl* pControl) {
      DBGMSG("Button clicked!\n");
    },
    "Click Me"
  )
);

// Rounded button that resets a parameter
pGraphics->AttachControl(
  new IVButtonControl(
    bounds,
    [](IControl* pControl) {
      pControl->GetDelegate()->GetParam(kGain)->SetToDefault();
    },
    "Reset",
    DEFAULT_STYLE,
    true, true,
    EVShape::EndsRounded
  )
);

// Circular button
pGraphics->AttachControl(
  new IVButtonControl(
    IRECT(10, 10, 60, 60), // Square bounds for circle
    SplashClickActionFunc,
    "Go",
    DEFAULT_STYLE,
    true, true,
    EVShape::Ellipse
  )
);

Action Functions

// Built-in action functions:
SplashClickActionFunc     // Default click splash animation
EmptyClickActionFunc      // No action
DefaultClickActionFunc    // Same as Splash

// Custom action function
auto myAction = [](IControl* pCaller) {
  // Access the plugin delegate
  auto* plugin = dynamic_cast<MyPlugin*>(pCaller->GetDelegate());
  plugin->DoSomething();
};

Vector Switch Control

IVSwitchControl cycles through multiple states on each click.

Constructor

// With parameter
IVSwitchControl(
  const IRECT& bounds,
  int paramIdx = kNoParameter,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  bool valueInButton = true
);

// With action function
IVSwitchControl(
  const IRECT& bounds,
  IActionFunction aF = SplashClickActionFunc,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  int numStates = 2,
  bool valueInButton = true
);
bounds
IRECT
required
Position and size
paramIdx
int
default:"kNoParameter"
Parameter index (for parameter variant)
aF
IActionFunction
Action function (for non-parameter variant)
label
const char*
default:"empty string"
Label text
style
IVStyle
default:"DEFAULT_STYLE"
Visual styling
numStates
int
default:"2"
Number of switch states (action function variant only)
valueInButton
bool
default:"true"
Draw value inside button

Example

// 2-state switch linked to parameter
pGraphics->AttachControl(
  new IVSwitchControl(
    IRECT(10, 10, 110, 40),
    kBypass,
    "Bypass"
  )
);

// 3-state switch with action function
pGraphics->AttachControl(
  new IVSwitchControl(
    IRECT(10, 10, 110, 40),
    [](IControl* pControl) {
      int state = static_cast<int>(pControl->GetValue() * 2.999); // 0, 1, or 2
      DBGMSG("State: %d\n", state);
    },
    "Mode",
    DEFAULT_STYLE,
    3  // 3 states
  )
);

Vector Toggle Control

IVToggleControl is a 2-state switch with custom ON/OFF text.

Constructor

// With parameter
IVToggleControl(
  const IRECT& bounds,
  int paramIdx = kNoParameter,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  const char* offText = "OFF",
  const char* onText = "ON"
);

// With action function
IVToggleControl(
  const IRECT& bounds,
  IActionFunction aF = SplashClickActionFunc,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  const char* offText = "OFF",
  const char* onText = "ON",
  bool initialState = false
);

Example

// Toggle with custom text
pGraphics->AttachControl(
  new IVToggleControl(
    IRECT(10, 10, 110, 40),
    kMute,
    "Mute",
    DEFAULT_STYLE,
    "Active",
    "Muted"
  )
);

// Toggle without parameter
pGraphics->AttachControl(
  new IVToggleControl(
    bounds,
    [](IControl* pControl) {
      bool isOn = pControl->GetValue() > 0.5;
      DBGMSG("Toggle: %s\n", isOn ? "ON" : "OFF");
    },
    "Enable",
    DEFAULT_STYLE,
    "Disabled",
    "Enabled",
    false  // Initially off
  )
);

Slide Switch Control

IVSlideSwitchControl is a switch with animated sliding handle.

Constructor

// With parameter
IVSlideSwitchControl(
  const IRECT& bounds,
  int paramIdx = kNoParameter,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  bool valueInButton = false,
  EDirection direction = EDirection::Horizontal
);

// With action function
IVSlideSwitchControl(
  const IRECT& bounds,
  IActionFunction aF = EmptyClickActionFunc,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  bool valueInButton = false,
  EDirection direction = EDirection::Horizontal,
  int numStates = 2,
  int initialState = 0
);
direction
EDirection
default:"EDirection::Horizontal"
Slide direction: Horizontal or Vertical

Example

// Horizontal slide switch
pGraphics->AttachControl(
  new IVSlideSwitchControl(
    IRECT(10, 10, 60, 30),
    kPower,
    "Power",
    DEFAULT_STYLE,
    false,
    EDirection::Horizontal
  )
);

// 3-state vertical slide switch
pGraphics->AttachControl(
  new IVSlideSwitchControl(
    IRECT(10, 10, 30, 90),
    [](IControl* pControl) {
      // Handle state change
    },
    "Mode",
    DEFAULT_STYLE,
    false,
    EDirection::Vertical,
    3,  // 3 states
    0   // Start at state 0
  )
);

Tab Switch Control

IVTabSwitchControl displays multiple tabs for switching between options.

Constructor

// With parameter
IVTabSwitchControl(
  const IRECT& bounds,
  int paramIdx = kNoParameter,
  const std::vector<const char*>& options = {},
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  EVShape shape = EVShape::Rectangle,
  EDirection direction = EDirection::Horizontal
);

// With action function
IVTabSwitchControl(
  const IRECT& bounds,
  IActionFunction aF,
  const std::vector<const char*>& options,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  EVShape shape = EVShape::Rectangle,
  EDirection direction = EDirection::Horizontal
);
options
std::vector<const char*>
Tab labels (overrides parameter display text if provided)
shape
EVShape
default:"EVShape::Rectangle"
Tab button shape
direction
EDirection
default:"EDirection::Horizontal"
Tab layout direction

Example

// Horizontal tabs with parameter
pGraphics->AttachControl(
  new IVTabSwitchControl(
    IRECT(10, 10, 310, 40),
    kOscType,
    {"Sine", "Saw", "Square", "Triangle"},
    "Waveform"
  )
);

// Vertical tabs with action function
pGraphics->AttachControl(
  new IVTabSwitchControl(
    IRECT(10, 10, 100, 200),
    [](IControl* pControl) {
      int tabIdx = static_cast<int>(pControl->GetValue() * 2.999);
      // Switch view based on tab
    },
    {"Filter", "Envelope", "LFO"},
    "Section",
    DEFAULT_STYLE,
    EVShape::EndsRounded,
    EDirection::Vertical
  )
);

Methods

const char* GetSelectedLabelStr() const; // Get label of selected tab

Radio Button Control

IVRadioButtonControl displays multiple radio buttons in a group.

Constructor

// With parameter
IVRadioButtonControl(
  const IRECT& bounds,
  int paramIdx = kNoParameter,
  const std::initializer_list<const char*>& options = {},
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  EVShape shape = EVShape::Ellipse,
  EDirection direction = EDirection::Vertical,
  float buttonSize = 10.f
);

// With action function
IVRadioButtonControl(
  const IRECT& bounds,
  IActionFunction aF,
  const std::initializer_list<const char*>& options,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  EVShape shape = EVShape::Ellipse,
  EDirection direction = EDirection::Vertical,
  float buttonSize = 10.f
);
options
std::initializer_list<const char*>
Labels for each radio button option
shape
EVShape
default:"EVShape::Ellipse"
Radio button shape (typically Ellipse or Rectangle)
direction
EDirection
default:"EDirection::Vertical"
Layout direction
buttonSize
float
default:"10.f"
Size of the radio button circles/shapes in pixels

Example

// Vertical radio buttons
pGraphics->AttachControl(
  new IVRadioButtonControl(
    IRECT(10, 10, 150, 120),
    kFilterType,
    {"Low Pass", "High Pass", "Band Pass", "Notch"},
    "Filter",
    DEFAULT_STYLE,
    EVShape::Ellipse,
    EDirection::Vertical,
    12.f  // 12px buttons
  )
);

// Horizontal radio buttons with squares
pGraphics->AttachControl(
  new IVRadioButtonControl(
    IRECT(10, 10, 300, 40),
    kQuality,
    {"Low", "Medium", "High"},
    "Quality",
    DEFAULT_STYLE,
    EVShape::Rectangle,
    EDirection::Horizontal,
    10.f
  )
);

IVMenuButtonControl opens a popup menu when clicked.

Constructor

IVMenuButtonControl(
  const IRECT& bounds,
  int paramIdx,
  const char* label = "",
  const IVStyle& style = DEFAULT_STYLE,
  EVShape shape = EVShape::Rectangle
);

Example

// Menu button for parameter with multiple options
pGraphics->AttachControl(
  new IVMenuButtonControl(
    IRECT(10, 10, 150, 40),
    kPreset,
    "Preset"
  )
);
The menu items are automatically populated from the parameter’s display text.

Bitmap Button

IBButtonControl uses bitmap images for button states.

Constructor

IBButtonControl(
  const IRECT& bounds,
  const IBitmap& bitmap,
  IActionFunction aF = DefaultClickActionFunc
);

Example

// 2-frame bitmap (off/on)
const IBitmap buttonBitmap = pGraphics->LoadBitmap("button.png", 2);

pGraphics->AttachControl(
  new IBButtonControl(
    IRECT(10, 10, 110, 40),
    buttonBitmap,
    [](IControl* pControl) {
      DBGMSG("Button clicked\n");
    }
  )
);

Bitmap Switch

IBSwitchControl uses bitmap filmstrip for multiple switch states.

Constructor

IBSwitchControl(
  const IRECT& bounds,
  const IBitmap& bitmap,
  int paramIdx = kNoParameter
);

Example

// 3-frame bitmap for 3-state switch
const IBitmap switchBitmap = pGraphics->LoadBitmap("switch.png", 3);

pGraphics->AttachControl(
  new IBSwitchControl(
    IRECT(10, 10, 60, 40),
    switchBitmap,
    kFilterMode
  )
);

SVG Button

ISVGButtonControl uses SVG graphics for button states.

Constructor

// Two separate SVGs
ISVGButtonControl(
  const IRECT& bounds,
  IActionFunction aF,
  const ISVG& offImage,
  const ISVG& onImage
);

// Single SVG with color replacement
ISVGButtonControl(
  const IRECT& bounds,
  IActionFunction aF,
  const ISVG& image,
  const std::array<IColor, 4> colors = {
    COLOR_BLACK, COLOR_WHITE,
    COLOR_DARK_GRAY, COLOR_LIGHT_GRAY
  },
  EColorReplacement colorReplacement = EColorReplacement::Fill
);
colors
std::array<IColor, 4>
Colors for: [0] off, [1] on, [2] mouse-over-off, [3] mouse-over-on
colorReplacement
EColorReplacement
Fill or Stroke - which SVG attribute to replace

Example

// Two separate SVGs
ISVG offSVG = pGraphics->LoadSVG("button-off.svg");
ISVG onSVG = pGraphics->LoadSVG("button-on.svg");

pGraphics->AttachControl(
  new ISVGButtonControl(
    IRECT(10, 10, 110, 40),
    [](IControl* pControl) { /* ... */ },
    offSVG,
    onSVG
  )
);

// Single SVG with color replacement
ISVG iconSVG = pGraphics->LoadSVG("icon.svg");

pGraphics->AttachControl(
  new ISVGButtonControl(
    IRECT(10, 10, 60, 60),
    [](IControl* pControl) { /* ... */ },
    iconSVG,
    {COLOR_GRAY, COLOR_BLUE, COLOR_LIGHT_GRAY, COLOR_LIGHT_BLUE},
    EColorReplacement::Fill
  )
);

SVG Toggle

ISVGToggleControl is a toggle switch using SVG graphics.

Constructor

// With parameter
ISVGToggleControl(
  const IRECT& bounds,
  int paramIdx,
  const ISVG& offImage,
  const ISVG& onImage
);

// With action function
ISVGToggleControl(
  const IRECT& bounds,
  IActionFunction aF,
  const ISVG& offImage,
  const ISVG& onImage
);

// Single SVG with color replacement (parameter variant)
ISVGToggleControl(
  const IRECT& bounds,
  int paramIdx,
  const ISVG& image,
  const std::array<IColor, 4> colors,
  EColorReplacement colorReplacement = EColorReplacement::Fill
);

Example

ISVG offSVG = pGraphics->LoadSVG("toggle-off.svg");
ISVG onSVG = pGraphics->LoadSVG("toggle-on.svg");

pGraphics->AttachControl(
  new ISVGToggleControl(
    IRECT(10, 10, 60, 30),
    kBypass,
    offSVG,
    onSVG
  )
);

SVG Switch

ISVGSwitchControl displays different SVGs for each state.

Constructor

ISVGSwitchControl(
  const IRECT& bounds,
  const std::initializer_list<ISVG>& svgs,
  int paramIdx = kNoParameter,
  IActionFunction aF = nullptr
);

Example

ISVG svg1 = pGraphics->LoadSVG("state1.svg");
ISVG svg2 = pGraphics->LoadSVG("state2.svg");
ISVG svg3 = pGraphics->LoadSVG("state3.svg");

pGraphics->AttachControl(
  new ISVGSwitchControl(
    IRECT(10, 10, 80, 80),
    {svg1, svg2, svg3},
    kWaveform
  )
);

Source Reference

File: IGraphics/Controls/IControls.h Vector controls: Lines 51-256
Bitmap controls: Lines 700-735
SVG controls: Lines 585-671