9CurveLookAndFeel::CurveLookAndFeel() { }
12 float slider_t,
float start_angle,
float end_angle,
24 float rounding = 0.0f;
25 float short_side = std::min(width, height);
26 float max_width = short_side;
33 int inset = rounding / sqrtf(2.0f) + (short_side - max_width) / 2.0f;
34 drawCurve(g, slider, x + inset, y + inset, width - 2.0f * inset, height - 2.0f * inset, active, bipolar);
38 bool active,
bool bipolar) {
39 static constexpr int kResolution = 16;
40 static constexpr float kLineWidth = 2.0f;
41 PathStrokeType stroke(kLineWidth, PathStrokeType::beveled, PathStrokeType::rounded);
43 float curve_width = std::min(width, height);
44 float x_offset = (width - curve_width) / 2.0f;
45 float power = -slider.getValue();
47 float start_x = x + x_offset + kLineWidth / 2.0f;
48 float start_y = y + height - kLineWidth / 2.0f;
49 path.startNewSubPath(start_x, start_y);
50 float active_width = curve_width - kLineWidth;
51 float active_height = curve_width - kLineWidth;
55 float half_width = active_width / 2.0f;
56 float half_height = active_height / 2.0f;
58 for (
int i = 0; i < kResolution / 2; ++i) {
59 float t = 2 * (i + 1.0f) / kResolution;
61 path.lineTo(start_x + t * half_width, start_y - power_t * half_height);
64 for (
int i = 0; i < kResolution / 2; ++i) {
65 float t = 2 * (i + 1.0f) / kResolution;
67 path.lineTo(start_x + t * half_width + half_width, start_y - power_t * half_height - half_height);
72 for (
int i = 0; i < kResolution; ++i) {
73 float t = (i + 1.0f) / kResolution;
75 path.lineTo(start_x + t * active_width, start_y - power_t * active_height);
84 g.strokePath(path, stroke);
void drawRotarySlider(Graphics &g, int x, int y, int width, int height, float slider_t, float start_angle, float end_angle, Slider &slider) override
Draws a rotary slider with a curve-shaped indicator.
Definition curve_look_and_feel.cpp:11
void drawCurve(Graphics &g, Slider &slider, int x, int y, int width, int height, bool active, bool bipolar)
Draws the power-scale curve for the slider.
Definition curve_look_and_feel.cpp:37
bool isBipolar() const
Definition synth_slider.h:168
bool isActive() const
Definition synth_slider.h:172
@ kKnobArcSize
Definition skin.h:89
@ kWidgetRoundedCorner
Definition skin.h:104
@ kWidgetPrimaryDisabled
Definition skin.h:167
@ kRotaryArc
Definition skin.h:150
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
float findValue(Skin::ValueId value_id) const
Finds a value in the skin overrides or from the parent if not found locally.
Definition synth_section.cpp:18
A specialized slider with extended functionality for modulation, parameter control,...
Definition synth_slider.h:314
Contains faster but less accurate versions of utility math functions, such as exponential,...
force_inline mono_float powerScale(mono_float value, mono_float power)
A power-scaling function to map a linear range to a curved response.
Definition futils.h:455
Declares the SynthSlider and related classes, providing various slider styles and functionality in th...