Fix set_plot_bounds (#2653)

This commit is contained in:
Luc (Echow) Varoqui 2023-02-04 16:17:15 +01:00 committed by GitHub
parent 660566c499
commit 212656f3fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -742,7 +742,7 @@ impl Plot {
}); });
let PlotMemory { let PlotMemory {
mut bounds_modified, bounds_modified,
mut hovered_entry, mut hovered_entry,
mut hidden_items, mut hidden_items,
last_screen_transform, last_screen_transform,
@ -754,6 +754,7 @@ impl Plot {
items: Vec::new(), items: Vec::new(),
next_auto_color_idx: 0, next_auto_color_idx: 0,
last_screen_transform, last_screen_transform,
bounds_modified,
response, response,
ctx: ui.ctx().clone(), ctx: ui.ctx().clone(),
}; };
@ -762,6 +763,7 @@ impl Plot {
mut items, mut items,
mut response, mut response,
last_screen_transform, last_screen_transform,
mut bounds_modified,
.. ..
} = plot_ui; } = plot_ui;
@ -1042,6 +1044,7 @@ pub struct PlotUi {
items: Vec<Box<dyn PlotItem>>, items: Vec<Box<dyn PlotItem>>,
next_auto_color_idx: usize, next_auto_color_idx: usize,
last_screen_transform: ScreenTransform, last_screen_transform: ScreenTransform,
bounds_modified: AxisBools,
response: Response, response: Response,
ctx: Context, ctx: Context,
} }
@ -1069,11 +1072,13 @@ impl PlotUi {
/// Set the plot bounds. Can be useful for implementing alternative plot navigation methods. /// Set the plot bounds. Can be useful for implementing alternative plot navigation methods.
pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds) { pub fn set_plot_bounds(&mut self, plot_bounds: PlotBounds) {
self.last_screen_transform.set_bounds(plot_bounds); 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. /// Move the plot bounds. Can be useful for implementing alternative plot navigation methods.
pub fn translate_bounds(&mut self, delta_pos: Vec2) { pub fn translate_bounds(&mut self, delta_pos: Vec2) {
self.last_screen_transform.translate_bounds(delta_pos); self.last_screen_transform.translate_bounds(delta_pos);
self.bounds_modified = true.into();
} }
/// Returns `true` if the plot area is currently hovered. /// Returns `true` if the plot area is currently hovered.