pub enum ParamRange {
Linear {
min: f64,
max: f64,
},
Logarithmic {
min: f64,
max: f64,
},
Discrete {
min: i64,
max: i64,
},
Enum {
count: usize,
},
}Expand description
Defines how a parameter maps between plain and normalized values.
Copy because every variant is POD (two scalar fields). Lets format
wrappers pass info.range by value without clone() noise.
Variants§
Implementations§
Source§impl ParamRange
impl ParamRange
Sourcepub fn normalize(&self, plain: f64) -> f64
pub fn normalize(&self, plain: f64) -> f64
Map a plain value to 0.0–1.0.
Degenerate bounds - min == max for Linear / Discrete,
non-positive or empty for Logarithmic, count <= 1 for
Enum - collapse to 0.0. Combined with Self::denormalize
returning min on the same inputs, the pair is round-trip
stable: the result always converges to the bottom of the
(degenerate) range rather than producing NaN or wrapping into
nonsense.
Sourcepub fn denormalize(&self, normalized: f64) -> f64
pub fn denormalize(&self, normalized: f64) -> f64
Map 0.0–1.0 back to a plain value.
Degenerate bounds collapse to min (or 0.0 for Enum with
count <= 1). See Self::normalize for the round-trip
semantics.
Sourcepub fn step_count(&self) -> Option<NonZeroU32>
pub fn step_count(&self) -> Option<NonZeroU32>
Number of discrete steps for a quantized range.
None means continuous (Linear / Logarithmic). Some(n) means
the range covers n + 1 distinct values (a step count of 3 →
4 picker positions). Cross-format wrappers that serialize a
0 = continuous sentinel into a C struct should call
.map(NonZeroU32::get).unwrap_or(0) at the FFI boundary.
Discrete / Enum variants with degenerate bounds (min > max,
or count <= 1) return None - semantically continuous,
because there’s nothing to step through.
Sourcepub fn step_count_usize(&self) -> usize
pub fn step_count_usize(&self) -> usize
step_count widened to usize with the continuous case
flattened to 1. Convenience for UI code that loops over
discrete values and falls back to a single step for continuous
ranges.
Trait Implementations§
Source§impl Clone for ParamRange
impl Clone for ParamRange
Source§fn clone(&self) -> ParamRange
fn clone(&self) -> ParamRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more