Skip to content

Commit ca8e982

Browse files
authored
Update tooltip.rs (#26)
1 parent 5759d3d commit ca8e982

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

egui_plot/src/items/tooltip.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ impl PlotUi<'_> {
363363
options.guide_stroke,
364364
);
365365
}
366+
draw_moving_markers(&ctx, *frame, &hits, &visuals, options.marker_radius);
366367

367368
for h in &hits {
368369
painter.circle_filled(h.screen_pos, options.marker_radius, h.color);
@@ -537,3 +538,29 @@ fn default_tooltip_ui(ui: &mut egui::Ui, hits: &[HitPoint], pins: &[PinnedPoints
537538
));
538539
}
539540
}
541+
542+
/// Render moving markers
543+
fn draw_moving_markers(
544+
ctx: &egui::Context,
545+
frame: egui::Rect,
546+
hits: &[HitPoint],
547+
visuals: &egui::style::Visuals,
548+
radius: f32,
549+
) {
550+
if hits.is_empty() {
551+
return;
552+
}
553+
554+
let layer = egui::LayerId::new(egui::Order::Foreground, egui::Id::new("moving_markers"));
555+
let painter = egui::Painter::new(ctx.clone(), layer, frame);
556+
557+
let outline = egui::Stroke::new(1.0, visuals.window_stroke().color);
558+
559+
for h in hits {
560+
if !frame.contains(h.screen_pos) {
561+
continue;
562+
}
563+
painter.circle_filled(h.screen_pos, radius, h.color);
564+
painter.circle_stroke(h.screen_pos, radius, outline);
565+
}
566+
}

0 commit comments

Comments
 (0)