From 246ab55a7f379c247f70c0cc5799d7d1d5180dda Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 27 Mar 2021 15:41:44 +0100 Subject: [PATCH] Fix: integer DragValue could sometimes not reach all values Fixes https://github.com/emilk/egui/issues/256 --- egui/src/widgets/drag_value.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/egui/src/widgets/drag_value.rs b/egui/src/widgets/drag_value.rs index cbd30d75c..a5b4fc6ad 100644 --- a/egui/src/widgets/drag_value.rs +++ b/egui/src/widgets/drag_value.rs @@ -263,14 +263,11 @@ impl<'a> Widget for DragValue<'a> { .flatten(); let stored_value = stored_value.unwrap_or(value); let stored_value = stored_value + delta_value as f64; - let stored_value = clamp_to_range(stored_value, clamp_range.clone()); - - let rounded_new_value = stored_value; let aim_delta = aim_rad * speed; let rounded_new_value = emath::smart_aim::best_in_range_f64( - rounded_new_value - aim_delta, - rounded_new_value + aim_delta, + stored_value - aim_delta, + stored_value + aim_delta, ); let rounded_new_value = emath::round_to_decimals(rounded_new_value, auto_decimals);