Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/widgets.h

Slider, Button, Label, ComboBox.

#include <sonore/gfx/widgets.h>
On this page

Design notes

They work in 0..1 and know nothing about parameters

A slider knows nothing about a processor parameter, and should not. A widget reports a normalised value and calls back; something else binds that to a plugin parameter, formats it and records the gesture.

The layering is not decoration. A widget that reached into the parameter system could not be tested without one, and the interaction rules here -- what a drag means, when a gesture starts -- are the part most worth testing and the part with nothing audio-specific in it.

Gestures

onDragStart and onDragEnd exist because a host needs them. A drag is ONE automation edit and one undo step; without the brackets, a DAW records forty separate changes for one movement of a knob and the user's undo takes forty presses to get back.

Types 5

class Widget : public Component

Shared plumbing: which LookAndFeel to draw with, and which font.

class Slider : public Widget

A slider, rotary or linear.

Value is normalised 0..1 throughout. A caller wanting decibels converts on the way in and out -- the same curve the host's automation lane uses, so the knob and the lane agree about where halfway is.

class Button : public Widget

A push button, or a toggle when setToggleable(true).

class Label : public Widget

Text. Does not take the mouse, so a click passes to whatever is behind.

class ComboBox : public Widget

A choice from a fixed list.

Cycles on click rather than opening a popup. A popup is a MODAL window -- it has to sit above everything, take the mouse until dismissed, and close on a click elsewhere -- and none of that exists yet. Cycling is honest and usable for the three or four choices a plugin parameter has; the popup is named as a gap rather than half-built.

Enums 1

  • enumenum class WheelMode
    What the mouse wheel does over a control.
    More

    The interesting value is the default. A control claiming the wheel outright is right in a fixed editor and wrong in a scrolling one: a user reaching for a parameter further down scrolls, the pointer crosses a knob, and the next notch moves that knob instead of the list. That is an accidental edit -- reported to the host as automation -- made while only navigating.

    Deferring outright is wrong too, and for a reason already written into this file: a wheel WHILE DRAGGING a slider belongs to the slider, or the list scrolls out from under the hand that is adjusting it.

    DeferToScroll is both. The wheel moves the control unless something above it could scroll AND the control is not currently being dragged.

    gfx::WheelMode · widgets.h:50
↑↓ to move↵ to openEvery public name in the headers, and every guide