1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Plot widget - allow disabling scroll for x and y separately (#4051)

To be consistent with the zoom and drag options that were added earlier.
This commit is contained in:
YgorSouza
2024-02-16 09:23:08 +01:00
committed by GitHub
parent 62e80c7729
commit 34e8af87d4
2 changed files with 23 additions and 6 deletions

View File

@@ -878,6 +878,7 @@ struct ChartsDemo {
vertical: bool,
allow_zoom: Vec2b,
allow_drag: Vec2b,
allow_scroll: Vec2b,
}
impl Default for ChartsDemo {
@@ -887,6 +888,7 @@ impl Default for ChartsDemo {
chart: Chart::default(),
allow_zoom: true.into(),
allow_drag: true.into(),
allow_scroll: true.into(),
}
}
}
@@ -921,6 +923,11 @@ impl ChartsDemo {
ui.checkbox(&mut self.allow_drag.x, "X");
ui.checkbox(&mut self.allow_drag.y, "Y");
});
ui.horizontal(|ui| {
ui.label("Allow scroll:");
ui.checkbox(&mut self.allow_scroll.x, "X");
ui.checkbox(&mut self.allow_scroll.y, "Y");
});
});
});
});
@@ -958,6 +965,7 @@ impl ChartsDemo {
.y_axis_width(3)
.allow_zoom(self.allow_zoom)
.allow_drag(self.allow_drag)
.allow_scroll(self.allow_scroll)
.show(ui, |plot_ui| plot_ui.bar_chart(chart))
.response
}