Skip to content

Commit

Permalink
Fix set_plot_bounds (#2653)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvaroqui authored Feb 4, 2023
1 parent 660566c commit 212656f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/egui/src/widgets/plot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ impl Plot {
});

let PlotMemory {
mut bounds_modified,
bounds_modified,
mut hovered_entry,
mut hidden_items,
last_screen_transform,
Expand All @@ -754,6 +754,7 @@ impl Plot {
items: Vec::new(),
next_auto_color_idx: 0,
last_screen_transform,
bounds_modified,
response,
ctx: ui.ctx().clone(),
};
Expand All @@ -762,6 +763,7 @@ impl Plot {
mut items,
mut response,
last_screen_transform,
mut bounds_modified,
..
} = plot_ui;

Expand Down Expand Up @@ -1042,6 +1044,7 @@ pub struct PlotUi {
items: Vec<Box<dyn PlotItem>>,
next_auto_color_idx: usize,
last_screen_transform: ScreenTransform,
bounds_modified: AxisBools,
response: Response,
ctx: Context,
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 212656f

Please sign in to comment.