From 3ba0ddffee40dde5fb7c405c3adf03b02037323c Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 29 Nov 2022 20:34:02 +0100 Subject: [PATCH] Simmplify safe mode granular drag mapping --- plugins/diopser/src/editor/slider.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/plugins/diopser/src/editor/slider.rs b/plugins/diopser/src/editor/slider.rs index 749e77cc..f911bed0 100644 --- a/plugins/diopser/src/editor/slider.rs +++ b/plugins/diopser/src/editor/slider.rs @@ -405,25 +405,19 @@ impl View for RestrictedParamSlider { }); // These positions should be compensated for the DPI scale so it remains - // consistent - let start_x = - util::remap_current_entity_x_t(cx, granular_drag_status.starting_value); - - // When the range is restricted the `delta_x` should also change - // accordingly - let min_x = (self.renormalize_event)(0.0); - let max_x = (self.renormalize_event)(1.0); + // consistent. When the range is restricted the `delta_x` should also change + // accordingly. + let start_x = util::remap_current_entity_x_t( + cx, + (self.renormalize_display)(granular_drag_status.starting_value), + ); let delta_x = (*x - granular_drag_status.starting_x_coordinate) * GRANULAR_DRAG_MULTIPLIER - * cx.style.dpi_factor as f32 - * (max_x - min_x); + * cx.style.dpi_factor as f32; - // We don't use `set_normalized_value_drag` because these values are already - // in the correct 'remapped' domain - self.param_base.set_normalized_value( + self.set_normalized_value_drag( cx, - util::remap_current_entity_x_coordinate(cx, start_x + delta_x) - .clamp(min_x, max_x), + util::remap_current_entity_x_coordinate(cx, start_x + delta_x), ); } else { self.granular_drag_status = None;