From b6f19d0ff055e14a27c243bfba4373a60d3d36a9 Mon Sep 17 00:00:00 2001 From: Andreas Reich Date: Tue, 30 Jan 2024 15:27:03 +0100 Subject: [PATCH] plot interact demo now prints a human readable item name --- crates/egui_demo_lib/src/demo/plot_demo.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/egui_demo_lib/src/demo/plot_demo.rs b/crates/egui_demo_lib/src/demo/plot_demo.rs index 67d19109d13..f497696ee18 100644 --- a/crates/egui_demo_lib/src/demo/plot_demo.rs +++ b/crates/egui_demo_lib/src/demo/plot_demo.rs @@ -800,6 +800,7 @@ impl InteractionDemo { .., 100, )) + .color(Color32::RED) .id(egui::Id::new("sin")), ); plot_ui.line( @@ -808,6 +809,7 @@ impl InteractionDemo { .., 100, )) + .color(Color32::BLUE) .id(egui::Id::new("cos")), ); @@ -841,7 +843,15 @@ 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:?}")); + + let hovered_item = if hovered_plot_item == Some(egui::Id::new("sin")) { + "red sin" + } else if hovered_plot_item == Some(egui::Id::new("cos")) { + "blue cos" + } else { + "none" + }; + ui.label(format!("hovered plot item: {hovered_item}")); response }