Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
control_painters.hpp
Go to the documentation of this file.
1#pragma once
2
23
24#include <cstddef>
25
28
30
31// ── Mod-ring knob ────────────────────────────────────────────────────────────
32
33struct KnobStyle {
34 canvas::Color track{0.25f, 0.28f, 0.32f, 1.0f};
35 canvas::Color ring{0.08f, 0.72f, 0.65f, 1.0f};
36 canvas::Color indicator{0.92f, 0.94f, 0.96f, 1.0f};
37 float start_angle_deg = 135.0f;
38 float sweep_deg = 270.0f;
39 float ring_width = 4.0f;
40 float indicator_width = 2.5f;
41 float radius_scale = 0.5f;
62 bool draw_indicator = true;
63};
64
70 const KnobStyle& style = {});
71
72// ── Level fader ──────────────────────────────────────────────────────────────
73
74struct FaderStyle {
75 bool horizontal = false;
76 canvas::Color track{0.20f, 0.22f, 0.26f, 1.0f};
77 canvas::Color fill{0.08f, 0.72f, 0.65f, 1.0f};
78 canvas::Color thumb{0.92f, 0.94f, 0.96f, 1.0f};
79 float track_thickness = 6.0f;
80 float thumb_length = 14.0f;
81 float corner_radius = 3.0f;
82};
83
88 const FaderStyle& style = {});
89
90// ── Bipolar dual-thumb range slider ──────────────────────────────────────────
91
93 bool horizontal = true;
94 canvas::Color track{0.20f, 0.22f, 0.26f, 1.0f};
95 canvas::Color fill{0.08f, 0.72f, 0.65f, 1.0f};
96 canvas::Color thumb{0.92f, 0.94f, 0.96f, 1.0f};
97 float track_thickness = 6.0f;
98 float thumb_radius = 7.0f;
99};
100
105 float lo, float hi, const RangeSliderStyle& style = {});
106
107// ── Toggle switch ─────────────────────────────────────────────────────────────
108
110 canvas::Color track_off{0.24f, 0.26f, 0.30f, 1.0f};
111 canvas::Color track_on{0.08f, 0.72f, 0.65f, 1.0f};
112 canvas::Color knob{0.96f, 0.97f, 0.98f, 1.0f};
113 float knob_inset = 2.0f;
114};
115
118void paint_toggle(canvas::Canvas& canvas, const Rect& rect, bool on,
119 const ToggleStyle& style = {});
120
121// ── Waveform ──────────────────────────────────────────────────────────────────
122
124 canvas::Color line{0.08f, 0.72f, 0.65f, 1.0f};
125 canvas::Color baseline{0.30f, 0.33f, 0.38f, 1.0f};
126 float line_width = 1.5f;
127 bool draw_baseline = true;
128};
129
134 const float* samples, std::size_t count,
135 const WaveformStyle& style = {});
136
137} // namespace pulp::view::painters
Definition canvas.hpp:240
Definition affine_transform.hpp:24
Definition control_painters.hpp:29
void 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 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 (sampl...
void 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,...
void 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 paint_toggle(canvas::Canvas &canvas, const Rect &rect, bool on, const ToggleStyle &style={})
Draw a pill toggle.
@ value
the widget's primary value (Knob, Fader, RangeSlider, Toggle, ProgressBar)
Definition binding_diagnostics.hpp:19
@ on
Definition accessibility.hpp:132
Definition canvas.hpp:52
Axis-aligned rectangle in continuous (float) coordinates.
Definition geometry.hpp:52
Definition control_painters.hpp:74
canvas::Color thumb
Definition control_painters.hpp:78
bool horizontal
default vertical (0=bottom, 1=top)
Definition control_painters.hpp:75
float track_thickness
Definition control_painters.hpp:79
canvas::Color track
Definition control_painters.hpp:76
float thumb_length
thumb size along the travel axis
Definition control_painters.hpp:80
canvas::Color fill
the filled portion up to value
Definition control_painters.hpp:77
float corner_radius
Definition control_painters.hpp:81
Definition control_painters.hpp:33
float indicator_inner_scale
Where the pointer STARTS, as a fraction of min(w,h).
Definition control_painters.hpp:51
float ring_width
Definition control_painters.hpp:39
float indicator_width
Definition control_painters.hpp:40
float radius_scale
arc radius as a fraction of min(w,h)
Definition control_painters.hpp:41
canvas::Color ring
the active value arc
Definition control_painters.hpp:35
canvas::Color track
the full inactive arc
Definition control_painters.hpp:34
float start_angle_deg
angle of value 0 (screen coords, y-down, 0=+x, CW+)
Definition control_painters.hpp:37
canvas::Color indicator
the pointer line
Definition control_painters.hpp:36
float indicator_outer_scale
Where the pointer ENDS, as a fraction of min(w,h).
Definition control_painters.hpp:54
bool draw_indicator
Definition control_painters.hpp:62
bool draw_track_and_fill
Which layers to emit.
Definition control_painters.hpp:61
float sweep_deg
total travel from value 0 to value 1
Definition control_painters.hpp:38
Definition control_painters.hpp:92
float thumb_radius
Definition control_painters.hpp:98
canvas::Color thumb
Definition control_painters.hpp:96
bool horizontal
Definition control_painters.hpp:93
canvas::Color fill
the span between the thumbs
Definition control_painters.hpp:95
float track_thickness
Definition control_painters.hpp:97
canvas::Color track
Definition control_painters.hpp:94
Definition control_painters.hpp:109
canvas::Color track_on
Definition control_painters.hpp:111
canvas::Color knob
Definition control_painters.hpp:112
canvas::Color track_off
Definition control_painters.hpp:110
float knob_inset
Definition control_painters.hpp:113
Definition control_painters.hpp:123
bool draw_baseline
Definition control_painters.hpp:127
canvas::Color baseline
Definition control_painters.hpp:125
canvas::Color line
Definition control_painters.hpp:124
float line_width
Definition control_painters.hpp:126