gfx/value_tree_state_attachments.h
AudioProcessorValueTreeState's widget attachments: SliderAttachment, ButtonAttachment and ComboBoxAttachment, as the reference nests them.
#include <sonore/gfx/value_tree_state_attachments.h>- 3types
- 2other declarations
- Guides: The native editor
On this page
Design notes
Built on the SDK's own attachments
gfx/plugin_editor.h already binds a Slider, a Button and a ComboBox to a parameter: the right curve, a gesture around every edit, value names on a switch, read-only parameters shown and never set. Those rules were each learnt the hard way and are tested there. These classes do not repeat them. Each one builds the SDK's attachment over an EditorHost whose four calls land in the APVTS, and adds the one thing an APVTS needs that an EditorHost polling on a tick does not: it LISTENS, so a change made in code, by undo, or by the host through syncFromHost() moves the widget at once.
Kept out of value_tree_state.h
So a DSP that includes the APVTS for its parameters compiles no GUI. The classes are declared inside AudioProcessorValueTreeState, as the reference declares them, and defined here.
Lifetime
As in the reference: the APVTS and the widget must outlive the attachment. Destroying an attachment unhooks the widget's callbacks, so a widget that outlives its attachment is inert rather than calling into freed memory.
Types 3
class AudioProcessorValueTreeState::SliderAttachment : private AudioProcessorValueTreeState::Listener
A Slider bound to one parameter of an APVTS.
class AudioProcessorValueTreeState::ButtonAttachment : private AudioProcessorValueTreeState::Listener
A toggle Button bound to a two-position parameter.
class AudioProcessorValueTreeState::ComboBoxAttachment : private AudioProcessorValueTreeState::Listener
A ComboBox bound to a stepped parameter. The items are the parameter's value names -- a choice parameter's choices -- filled in by the attachment, so the list and the parameter cannot disagree about order.
Functions 2
- fn
inline EditorHost editorHostFor(AudioProcessorValueTreeState& state)An EditorHost whose calls land in an APVTS: an edit becomes setParameterValue, a drag a gesture, and a read the raw atomic.gfx::editorHostFor · value_tree_state_attachments.h:49More
Which also means the SDK's GenericEditor can be given an APVTS:
GenericEditor(state.parameterInfos(), state.numParameters(), editorHostFor(state), font) - fn
inline AudioProcessorValueTreeState::HostLink hostLinkFrom(const EditorHost& host)The other direction: connect an APVTS to whatever hosts a native editor, with the EditorHost a wrapper hands the editor.gfx::hostLinkFrom · value_tree_state_attachments.h:64