Skip to content

Commit

Permalink
every plot object now has an id which is returned as part of the plot…
Browse files Browse the repository at this point in the history
…'s response if it was hovered
  • Loading branch information
Wumpf committed Jan 29, 2024
1 parent 6a94f4f commit 37aa397
Show file tree
Hide file tree
Showing 5 changed files with 1,510 additions and 20 deletions.
19 changes: 19 additions & 0 deletions crates/egui_demo_lib/src/demo/plot_demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,26 @@ impl InteractionDemo {
let PlotResponse {
response,
inner: (screen_pos, pointer_coordinate, pointer_coordinate_drag_delta, bounds, hovered),
hovered_plot_item,
..
} = plot.show(ui, |plot_ui| {
plot_ui.line(
Line::new(PlotPoints::from_explicit_callback(
move |x| x.sin(),
..,
100,
))
.id(egui::Id::new("sin")),
);
plot_ui.line(
Line::new(PlotPoints::from_explicit_callback(
move |x| x.cos(),
..,
100,
))
.id(egui::Id::new("cos")),
);

(
plot_ui.screen_from_plot(PlotPoint::new(0.0, 0.0)),
plot_ui.pointer_coordinate(),
Expand Down Expand Up @@ -823,6 +841,7 @@ impl InteractionDemo {
pointer_coordinate_drag_delta.x, pointer_coordinate_drag_delta.y
);
ui.label(format!("pointer coordinate drag delta: {coordinate_text}"));
ui.label(format!("hovered plot item: {hovered_plot_item:?}"));

response
}
Expand Down
Loading

0 comments on commit 37aa397

Please sign in to comment.