Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix set_plot_bounds #2653

Merged
merged 1 commit into from
Feb 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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