gfx/widgets2.h
A range slider, and a button with a picture on it.
#include <sonore/gfx/widgets2.h>- 4types
- Guides: The native editor
On this page
Design notes
Why a range is not two sliders
A crossover's band edges, a sample's start and end, a compressor's range: all of them are a PAIR that must stay ordered. Two ordinary sliders side by side let a user drag the low end past the high one, and every plugin that does that has a bug report about it. Keeping the pair ordered is the entire reason this is one control.
Why an icon button waited for SVG
Because until there was a way to describe a shape that stays sharp at any size, an icon button meant a bitmap -- and a plugin editor is resized by the host to whatever it likes.
Types 4
class RangeSlider : public Widget
Two values on one track.
Both are normalised 0..1, like Slider, so the same ParamInfo curves apply to each end.
class IconButton : public Widget
A button whose face is a shape rather than a word.
Takes SVG source rather than a Path, because that is how icons arrive -- from a designer, from an icon set, as text a generated plugin can embed in a header. The parse happens once at setIcon, not per frame.
class ImageComponent : public Widget
A picture.
Trivial, and missing until now, which meant every plugin wanting to show its own logo had to subclass Component and write a paint(). That is four lines anybody can write and four lines everybody writes slightly differently -- usually without the placement rule, so the logo stretches when the editor is resized.
The image is NOT owned. A plugin's artwork is decoded once and drawn by however many components want it, and a component that took a copy would decode a megabyte of PNG per instance.
class HyperlinkButton : public Widget
A button that looks like a link.
"Manual", "Report a bug", "Buy the full version". Every plugin has one or two and every one of them was a Button restyled by hand.
It does NOT open the URL itself, and that is deliberate rather than lazy. Launching a browser from inside a plugin means ShellExecute or its equivalents, from a process the user did not start and a thread the host owns -- and a host that is mid-render when a shell call blocks is a host that drops audio. The owner gets the URL and decides; a standalone can open it immediately, and a plugin can put it behind a confirmation.