Browse Source

Fix: integer DragValue could sometimes not reach all values

Fixes https://github.com/emilk/egui/issues/256
pull/262/head
Emil Ernerfeldt 4 years ago
parent
commit
246ab55a7f
  1. 7
      egui/src/widgets/drag_value.rs

7
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);

Loading…
Cancel
Save