From 212656f3fc6b931b21eaad401e5cec2b0da93baa Mon Sep 17 00:00:00 2001 From: "Luc (Echow) Varoqui" <48593807+lvaroqui@users.noreply.github.com> Date: Sat, 4 Feb 2023 16:17:15 +0100 Subject: [PATCH] Fix set_plot_bounds (#2653) --- crates/egui/src/widgets/plot/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/plot/mod.rs b/crates/egui/src/widgets/plot/mod.rs index e18ce0cd..63873f86 100644 --- a/crates/egui/src/widgets/plot/mod.rs +++ b/crates/egui/src/widgets/plot/mod.rs @@ -742,7 +742,7 @@ impl Plot { }); let PlotMemory { - mut bounds_modified, + bounds_modified, mut hovered_entry, mut hidden_items, last_screen_transform, @@ -754,6 +754,7 @@ impl Plot { items: Vec::new(), next_auto_color_idx: 0, last_screen_transform, + bounds_modified, response, ctx: ui.ctx().clone(), }; @@ -762,6 +763,7 @@ impl Plot { mut items, mut response, last_screen_transform, + mut bounds_modified, .. } = plot_ui; @@ -1042,6 +1044,7 @@ pub struct PlotUi { items: Vec>, next_auto_color_idx: usize, last_screen_transform: ScreenTransform, + bounds_modified: AxisBools, response: Response, ctx: Context, } @@ -1069,11 +1072,13 @@ impl PlotUi { /// Set the plot bounds. Can be useful for implementing alternative plot navigation methods. pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds) { self.last_screen_transform.set_bounds(plot_bounds); + self.bounds_modified = true.into(); } /// Move the plot bounds. Can be useful for implementing alternative plot navigation methods. pub fn translate_bounds(&mut self, delta_pos: Vec2) { self.last_screen_transform.translate_bounds(delta_pos); + self.bounds_modified = true.into(); } /// Returns `true` if the plot area is currently hovered.