Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
parameter_binding.hpp File Reference

Two-way binding between a standard widget and a store parameter, with host automation gestures. More...

#include <optional>
#include <pulp/state/parameter.hpp>
#include <pulp/state/store.hpp>
#include <pulp/view/design_frame_view.hpp>
#include <pulp/view/ui_components.hpp>
#include <pulp/view/widgets.hpp>
#include <utility>

Go to the source code of this file.

Classes

class  pulp::view::ParameterBinding
 RAII owner of a widget↔parameter binding's store listener. More...

Namespaces

namespace  pulp
namespace  pulp::view
 Hover-cursor tracking for platform window hosts.
namespace  pulp::view::detail

Functions

template<typename Control>
state::StateStore::ModulationWatch pulp::view::detail::watch_modulated_display (Control &control, state::StateStore &store, state::ParamID id)
 The modulated-value half of a binding: whatever modulates the parameter – a host's CLAP modulation, or the plugin's own published modulation (StateStore::set_display_modulation) – is drawn on the control as its played value; nothing is drawn when nothing modulates it.
ParameterBinding pulp::view::bind_parameter (Knob &knob, state::StateStore &store, state::ParamID id)
 Knob ↔ parameter (normalized).
ParameterBinding pulp::view::bind_parameter (Fader &fader, state::StateStore &store, state::ParamID id)
 Fader ↔ parameter (normalized).
ParameterBinding pulp::view::bind_parameter (XYPad &pad, state::StateStore &store, state::ParamID x_id, state::ParamID y_id)
 XY pad ↔ two parameters (normalized). A single drag drives both.
ParameterBinding pulp::view::bind_parameter (RangeSlider &slider, state::StateStore &store, state::ParamID id)
 Range slider ↔ parameter (normalized).
ParameterBinding pulp::view::bind_parameter (ComboBox &combo, state::StateStore &store, state::ParamID id)
 ComboBox ↔ stepped/index parameter.
ParameterBinding pulp::view::bind_parameter (DesignStepper &stepper, state::StateStore &store, state::ParamID id)
 DesignStepper ↔ stepped/index parameter (same contract as ComboBox): user steps are one-shot gestures; automation playback drives the selection via set_selected_silent (which does not re-fire on_select).
ParameterBinding pulp::view::bind_parameter (Toggle &toggle, state::StateStore &store, state::ParamID id)
 Toggle (switch) ↔ parameter, as a one-shot gesture per flip.
ParameterBinding pulp::view::bind_parameter (Checkbox &box, state::StateStore &store, state::ParamID id)
 Checkbox ↔ parameter, as a one-shot gesture per flip.
ParameterBinding pulp::view::bind_parameter (ToggleButton &button, state::StateStore &store, state::ParamID id)
 Toggle button ↔ parameter.

Detailed Description

Two-way binding between a standard widget and a store parameter, with host automation gestures.

One call replaces the hand-written widget-callback ↔ parameter-listener pair an editor would otherwise maintain per control.

bind_parameter(widget, store, id) wires, with no further code:

  • widget interaction → host gesture (begin on press, end on release; a discrete control – toggle, button, combo, stepper – is one complete gesture per change) so DAWs record the control's automation;
  • widget value changes → store.set_normalized(id, …);
  • store changes (automation playback, preset load) → the widget's displayed value, so the control moves while the host plays it back;
  • for a continuous control (Knob, Fader, RangeSlider, XYPad), the parameter's modulated value as the control's one indicator: a host's CLAP modulation by default, and the plugin's own modulation when it publishes one (StateStore::set_display_modulation). Nothing changes when nothing modulates the parameter. Modulation never writes a host lane. A discrete control (toggle, button, checkbox, combo, stepper) shows its base: a stepped parameter has no position between states for a modulator to move it to.

Bind once, get automation and playback animation for free. Showing a plugin's INTERNAL modulation is opt-in (the plugin publishes it); any modulation menus or routing UI are the plugin's own.

It returns a ParameterBinding that owns the store listener. The binding is lifetime-scoped: keep it alive for as long as the widget is bound (typically as a member of the editor, so it dies with the widget), and dropping it unbinds — there is no separate detach call.

Without this, a widget changes the parameter audibly but the host does not record the move, because the raw value write is not bracketed in a gesture. See pulp::state::ParameterEdit for the lower-level primitive used by bespoke (non-widget) controls.

UI-thread only.