Handle stepped non-float parameters
The widget now snaps to the correct range. This would always be displayed this way internally, but now we also won't tell the host about the invalid values.
This commit is contained in:
parent
46a7d8a261
commit
e2524a2d81
1 changed files with 8 additions and 1 deletions
|
@ -26,7 +26,14 @@ impl<'a, P: Param> ParamSlider<'a, P> {
|
||||||
fn set_normalized_value(&self, normalized: f32) {
|
fn set_normalized_value(&self, normalized: f32) {
|
||||||
// TODO: The gesture should start on mouse down and end up mouse up
|
// TODO: The gesture should start on mouse down and end up mouse up
|
||||||
self.setter.begin_set_parameter(self.param);
|
self.setter.begin_set_parameter(self.param);
|
||||||
self.setter.set_parameter_normalized(self.param, normalized);
|
|
||||||
|
// This snaps to the nearest plain value if the parameter is stepped in some wayA
|
||||||
|
// TODO: As an optimization, we could add a `const CONTINUOUS: bool` to the parameter to
|
||||||
|
// avoid this normalized->plain->normalized conversion for parameters that don't need
|
||||||
|
// it
|
||||||
|
let value = self.param.preview_plain(normalized);
|
||||||
|
self.setter.set_parameter(self.param, value);
|
||||||
|
|
||||||
self.setter.end_set_parameter(self.param);
|
self.setter.end_set_parameter(self.param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue