mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Improved plot groups and bounds handling (#2410)
* improve plot groups and bounds handling * changelog entry * fix potential deadlock * fix two more potential deadlocks * syntax fix * move changelog entry * move category * Update crates/egui/src/widgets/plot/mod.rs Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com> * Update crates/egui_demo_lib/src/demo/plot_demo.rs Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com> * clean up suggestions * address comments * use the new methods * fix locked bounds * Sync bounds_modified along with the bounds themselves * move changelog entry * Remove set_bounds_auto - not necessary any more * add a comment about bounds modifications --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com> Co-authored-by: Jackson Kruger <jackson@farprobe.com>
This commit is contained in:
committed by
GitHub
parent
8a2cfbd131
commit
69b568aeb4
@@ -576,8 +576,6 @@ impl CustomAxisDemo {
|
||||
struct LinkedAxisDemo {
|
||||
link_x: bool,
|
||||
link_y: bool,
|
||||
group: plot::LinkedAxisGroup,
|
||||
cursor_group: plot::LinkedCursorsGroup,
|
||||
link_cursor_x: bool,
|
||||
link_cursor_y: bool,
|
||||
}
|
||||
@@ -591,8 +589,6 @@ impl Default for LinkedAxisDemo {
|
||||
Self {
|
||||
link_x,
|
||||
link_y,
|
||||
group: plot::LinkedAxisGroup::new(link_x, link_y),
|
||||
cursor_group: plot::LinkedCursorsGroup::new(link_cursor_x, link_cursor_y),
|
||||
link_cursor_x,
|
||||
link_cursor_y,
|
||||
}
|
||||
@@ -638,37 +634,35 @@ impl LinkedAxisDemo {
|
||||
ui.checkbox(&mut self.link_x, "X");
|
||||
ui.checkbox(&mut self.link_y, "Y");
|
||||
});
|
||||
self.group.set_link_x(self.link_x);
|
||||
self.group.set_link_y(self.link_y);
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Linked cursors:");
|
||||
ui.checkbox(&mut self.link_cursor_x, "X");
|
||||
ui.checkbox(&mut self.link_cursor_y, "Y");
|
||||
});
|
||||
self.cursor_group.set_link_x(self.link_cursor_x);
|
||||
self.cursor_group.set_link_y(self.link_cursor_y);
|
||||
|
||||
let link_group_id = ui.id().with("linked_demo");
|
||||
ui.horizontal(|ui| {
|
||||
Plot::new("linked_axis_1")
|
||||
.data_aspect(1.0)
|
||||
.width(250.0)
|
||||
.height(250.0)
|
||||
.link_axis(self.group.clone())
|
||||
.link_cursor(self.cursor_group.clone())
|
||||
.link_axis(link_group_id, self.link_x, self.link_y)
|
||||
.link_cursor(link_group_id, self.link_cursor_x, self.link_cursor_y)
|
||||
.show(ui, LinkedAxisDemo::configure_plot);
|
||||
Plot::new("linked_axis_2")
|
||||
.data_aspect(2.0)
|
||||
.width(150.0)
|
||||
.height(250.0)
|
||||
.link_axis(self.group.clone())
|
||||
.link_cursor(self.cursor_group.clone())
|
||||
.link_axis(link_group_id, self.link_x, self.link_y)
|
||||
.link_cursor(link_group_id, self.link_cursor_x, self.link_cursor_y)
|
||||
.show(ui, LinkedAxisDemo::configure_plot);
|
||||
});
|
||||
Plot::new("linked_axis_3")
|
||||
.data_aspect(0.5)
|
||||
.width(250.0)
|
||||
.height(150.0)
|
||||
.link_axis(self.group.clone())
|
||||
.link_cursor(self.cursor_group.clone())
|
||||
.link_axis(link_group_id, self.link_x, self.link_y)
|
||||
.link_cursor(link_group_id, self.link_cursor_x, self.link_cursor_y)
|
||||
.show(ui, LinkedAxisDemo::configure_plot)
|
||||
.response
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user