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

Skinnable paint-space control painters. More...

#include <cstddef>
#include <pulp/canvas/canvas.hpp>
#include <pulp/view/geometry.hpp>

Go to the source code of this file.

Classes

struct  pulp::view::painters::KnobStyle
struct  pulp::view::painters::FaderStyle
struct  pulp::view::painters::RangeSliderStyle
struct  pulp::view::painters::ToggleStyle
struct  pulp::view::painters::WaveformStyle

Namespaces

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

Functions

void pulp::view::painters::paint_mod_ring_knob (canvas::Canvas &canvas, const Rect &rect, float value, const KnobStyle &style={})
 Draw a rotary knob whose active ring sweeps from start_angle_deg by value * sweep_deg, with a pointer line at the value angle.
void pulp::view::painters::paint_level_fader (canvas::Canvas &canvas, const Rect &rect, float value, const FaderStyle &style={})
 Draw a linear fader with a filled level bar and a thumb at value [0,1].
void pulp::view::painters::paint_range_slider (canvas::Canvas &canvas, const Rect &rect, float lo, float hi, const RangeSliderStyle &style={})
 Draw a two-thumb range slider spanning [lo, hi] (each [0,1], clamped, and lo <= hi enforced).
void pulp::view::painters::paint_toggle (canvas::Canvas &canvas, const Rect &rect, bool on, const ToggleStyle &style={})
 Draw a pill toggle.
void pulp::view::painters::paint_waveform (canvas::Canvas &canvas, const Rect &rect, const float *samples, std::size_t count, const WaveformStyle &style={})
 Draw count samples (each ~[-1,1]) as a polyline filling rect horizontally, centered vertically (sample +1 = top, -1 = bottom).

Detailed Description

Skinnable paint-space control painters.

A faithful port often needs to draw a control directly from a paint() in panel coordinates — no View, no layout, no hit-testing — because the interaction is owned elsewhere (a DesignFrameView overlay, a custom widget) and only the LOOK is wanted, at an arbitrary rect, in an arbitrary skin.

Each painter is a free function taking a style struct, a Canvas&, a rect, and a value, and emitting that control's visual. Rendering a knob / fader / toggle is therefore decoupled from any widget CLASS: the same painter serves a Pulp widget that owns its own state, an overlay element whose value lives in a design frame, and a preview/thumbnail that has no interaction at all. Restyle a control by passing a different style struct; re-host it by calling the painter from a different paint(); neither requires subclassing or replacing a widget.

Every painter is pure w.r.t. the canvas (it only issues draw ops), so a RecordingCanvas can assert the emitted geometry is value-dependent (the arc sweep grows with the knob value, the fader thumb tracks the level, …) with no GPU / Skia raster surface.