From a8656c63312cd0d0474199c98f9170c5b5289817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 8 Sep 2022 04:13:11 +0200 Subject: [PATCH] Allow box zoom in any direction --- crates/egui/src/widgets/plot/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index fd5a121fc95d..9e82d2565e5d 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -876,14 +876,18 @@ impl Plot { let box_start_pos = transform.value_from_position(box_start_pos); let box_end_pos = transform.value_from_position(box_end_pos); let new_bounds = PlotBounds { - min: [box_start_pos.x, box_end_pos.y], - max: [box_end_pos.x, box_start_pos.y], + min: [ + box_start_pos.x.min(box_end_pos.x), + box_start_pos.y.min(box_end_pos.y), + ], + max: [ + box_start_pos.x.max(box_end_pos.x), + box_start_pos.y.max(box_end_pos.y), + ], }; if new_bounds.is_valid() { transform.set_bounds(new_bounds); auto_bounds = false.into(); - } else { - auto_bounds = true.into(); } // reset the boxed zoom state last_click_pos_for_zoom = None;