mirror of
https://github.com/robbert-vdh/nih-plug.git
synced 2026-07-01 02:36:54 +00:00
add new ParamSliderStyle::FromMidPoint
This commit is contained in:
committed by
Robbert van der Helm
parent
40269e1394
commit
55c41bfa9e
@@ -49,9 +49,11 @@ pub enum ParamSliderStyle {
|
||||
Centered,
|
||||
/// Always fill the bar starting from the left.
|
||||
FromLeft,
|
||||
/// Fill the bar from the mid point, regardless of where the default value lies
|
||||
FromMidPoint,
|
||||
/// Show the current step instead of filling a portion of the bar, useful for discrete
|
||||
/// parameters. Set `even` to `true` to distribute the ticks evenly instead of following the
|
||||
/// parameter's distribution. This can be desireable because discrete parameters have smaller
|
||||
/// parameter's distribution. This can be desirable because discrete parameters have smaller
|
||||
/// ranges near the edges (they'll span only half the range, which can make the display look
|
||||
/// odd).
|
||||
CurrentStep { even: bool },
|
||||
@@ -333,6 +335,16 @@ impl ParamSlider {
|
||||
if delta >= 1e-3 { delta } else { 0.0 },
|
||||
)
|
||||
}
|
||||
ParamSliderStyle::FromMidPoint => {
|
||||
let delta = (0.5 - current_value).abs();
|
||||
|
||||
// Don't draw the filled portion at all if it could have been a
|
||||
// rounding error since those slivers just look weird
|
||||
(
|
||||
0.5_f32.min(current_value),
|
||||
if delta >= 1e-3 { delta } else { 0.0 },
|
||||
)
|
||||
}
|
||||
ParamSliderStyle::Centered | ParamSliderStyle::FromLeft => (0.0, current_value),
|
||||
ParamSliderStyle::CurrentStep { even: true }
|
||||
| ParamSliderStyle::CurrentStepLabeled { even: true }
|
||||
@@ -369,7 +381,9 @@ impl ParamSlider {
|
||||
ParamSliderStyle::CurrentStep { .. } | ParamSliderStyle::CurrentStepLabeled { .. } => {
|
||||
(0.0, 0.0)
|
||||
}
|
||||
ParamSliderStyle::Centered | ParamSliderStyle::FromLeft => {
|
||||
ParamSliderStyle::Centered
|
||||
| ParamSliderStyle::FromMidPoint
|
||||
| ParamSliderStyle::FromLeft => {
|
||||
let modulation_start = param.unmodulated_normalized_value();
|
||||
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user