Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::SliderCore Class Reference

#include <slider_core.hpp>

Public Member Functions

void set_range (double min_value, double max_value, double interval=0.0)
 Set the real-world range and the quantization interval.
double minimum () const
double maximum () const
double interval () const
void set_skew (double skew)
 1 = linear. Below 1, the low end of the range gets more travel.
double skew () const
void set_skew_from_midpoint (double mid_value)
 Choose the skew that places mid_value (real-world units) at half travel.
double value () const
bool set_value (double v, Notify notify=Notify::sync)
 Write a real-world value.
double proportion () const
 Travel proportion in [0,1] for the current value, after the curve.
bool set_proportion (double p, Notify notify=Notify::sync)
 Write from a travel proportion (what a drag or a painter's inverse hit-test produces).
double normalized () const
 LINEAR position of the value in the range, in [0,1], with NO response curve applied.
double value_for_normalized (double n) const
bool set_normalized (double n, Notify notify=Notify::sync)
double proportion_for (double v) const
double value_for_proportion (double p) const
double constrain (double v) const
 Clamp to the range and snap to the interval.
void set_default_value (double v)
 The value the control returns to on a reset gesture (conventionally a double-click or alt-click).
bool has_default () const
double default_value () const
bool reset_to_default (Notify notify=Notify::sync)
void set_drag_sensitivity (int pixels)
 Pointer pixels that cross the FULL range in a plain (non-velocity) drag.
int drag_sensitivity () const
void set_velocity_mode (bool on)
 In velocity mode the value moves by pointer SPEED rather than by absolute pointer travel, so a fast flick covers the range and a slow one does not — the pointer and the control decouple.
bool velocity_mode () const
void set_velocity_sensitivity (double s)
bool drag_to (double delta_pixels, double proportion_at_press, bool fine, Notify notify=Notify::sync)
 ABSOLUTE drag: delta_pixels is the pointer's total travel SINCE the gesture began (positive = increase), and proportion_at_press is the proportion the control held when it began.
bool drag_step (double delta_pixels, bool fine, Notify notify=Notify::sync)
 VELOCITY drag: delta_pixels is the pointer's travel since the LAST tick, and the control integrates it from wherever it currently is.
void set_fine_divisor (double d)
double fine_divisor () const
void begin_gesture ()
void end_gesture ()
bool gesture_active () const

Public Attributes

std::function< void(double)> on_value_change
std::function< void()> on_gesture_begin
std::function< void()> on_gesture_end

Member Function Documentation

◆ begin_gesture()

void pulp::view::SliderCore::begin_gesture ( )
inline

◆ constrain()

double pulp::view::SliderCore::constrain ( double v) const
inline

Clamp to the range and snap to the interval.

◆ default_value()

double pulp::view::SliderCore::default_value ( ) const
inline

◆ drag_sensitivity()

int pulp::view::SliderCore::drag_sensitivity ( ) const
inline

◆ drag_step()

bool pulp::view::SliderCore::drag_step ( double delta_pixels,
bool fine,
Notify notify = Notify::sync )
inline

VELOCITY drag: delta_pixels is the pointer's travel since the LAST tick, and the control integrates it from wherever it currently is.

The pointer and the control deliberately decouple — a fast flick covers more range than the same distance moved slowly, and the control never "snaps" to the pointer. Use when velocity_mode() is set.

◆ drag_to()

bool pulp::view::SliderCore::drag_to ( double delta_pixels,
double proportion_at_press,
bool fine,
Notify notify = Notify::sync )
inline

ABSOLUTE drag: delta_pixels is the pointer's total travel SINCE the gesture began (positive = increase), and proportion_at_press is the proportion the control held when it began.

The pointer and the control stay locked together, so releasing and re-pressing does not drift. fine (a modifier held) divides the travel by fine_divisor().

◆ end_gesture()

void pulp::view::SliderCore::end_gesture ( )
inline

◆ fine_divisor()

double pulp::view::SliderCore::fine_divisor ( ) const
inline

◆ gesture_active()

bool pulp::view::SliderCore::gesture_active ( ) const
inline

◆ has_default()

bool pulp::view::SliderCore::has_default ( ) const
inline

◆ interval()

double pulp::view::SliderCore::interval ( ) const
inline

◆ maximum()

double pulp::view::SliderCore::maximum ( ) const
inline

◆ minimum()

double pulp::view::SliderCore::minimum ( ) const
inline

◆ normalized()

double pulp::view::SliderCore::normalized ( ) const
inline

LINEAR position of the value in the range, in [0,1], with NO response curve applied.

This is the space a parameter store and a normalized automation lane live in; proportion() is the space a painter and a drag live in. They coincide only when the skew is 1.

◆ proportion()

double pulp::view::SliderCore::proportion ( ) const
inline

Travel proportion in [0,1] for the current value, after the curve.

◆ proportion_for()

double pulp::view::SliderCore::proportion_for ( double v) const
inline

◆ reset_to_default()

bool pulp::view::SliderCore::reset_to_default ( Notify notify = Notify::sync)
inline

◆ set_default_value()

void pulp::view::SliderCore::set_default_value ( double v)
inline

The value the control returns to on a reset gesture (conventionally a double-click or alt-click).

Unset by default; has_default() is false and reset_to_default() is then a no-op, so a control with no meaningful home position does not silently jump to the minimum.

◆ set_drag_sensitivity()

void pulp::view::SliderCore::set_drag_sensitivity ( int pixels)
inline

Pointer pixels that cross the FULL range in a plain (non-velocity) drag.

Larger = finer. Default 250.

◆ set_fine_divisor()

void pulp::view::SliderCore::set_fine_divisor ( double d)
inline

◆ set_normalized()

bool pulp::view::SliderCore::set_normalized ( double n,
Notify notify = Notify::sync )
inline

◆ set_proportion()

bool pulp::view::SliderCore::set_proportion ( double p,
Notify notify = Notify::sync )
inline

Write from a travel proportion (what a drag or a painter's inverse hit-test produces).

Applies the curve, then clamp + snap.

◆ set_range()

void pulp::view::SliderCore::set_range ( double min_value,
double max_value,
double interval = 0.0 )
inline

Set the real-world range and the quantization interval.

interval == 0 leaves the value continuous. The current value is re-clamped and re-snapped, silently — a range change is a reconfiguration, not a user edit, and firing listeners here would report a value the user never set.

◆ set_skew()

void pulp::view::SliderCore::set_skew ( double skew)
inline

1 = linear. Below 1, the low end of the range gets more travel.

◆ set_skew_from_midpoint()

void pulp::view::SliderCore::set_skew_from_midpoint ( double mid_value)
inline

Choose the skew that places mid_value (real-world units) at half travel.

◆ set_value()

bool pulp::view::SliderCore::set_value ( double v,
Notify notify = Notify::sync )
inline

Write a real-world value.

Clamped to the range and snapped to the interval first; listeners only fire if the STORED value actually moved, so a redundant write in a sync loop is free.

◆ set_velocity_mode()

void pulp::view::SliderCore::set_velocity_mode ( bool on)
inline

In velocity mode the value moves by pointer SPEED rather than by absolute pointer travel, so a fast flick covers the range and a slow one does not — the pointer and the control decouple.

◆ set_velocity_sensitivity()

void pulp::view::SliderCore::set_velocity_sensitivity ( double s)
inline

◆ skew()

double pulp::view::SliderCore::skew ( ) const
inline

◆ value()

double pulp::view::SliderCore::value ( ) const
inline

◆ value_for_normalized()

double pulp::view::SliderCore::value_for_normalized ( double n) const
inline

◆ value_for_proportion()

double pulp::view::SliderCore::value_for_proportion ( double p) const
inline

◆ velocity_mode()

bool pulp::view::SliderCore::velocity_mode ( ) const
inline

Member Data Documentation

◆ on_gesture_begin

std::function<void()> pulp::view::SliderCore::on_gesture_begin

◆ on_gesture_end

std::function<void()> pulp::view::SliderCore::on_gesture_end

◆ on_value_change

std::function<void(double)> pulp::view::SliderCore::on_value_change

The documentation for this class was generated from the following file: