MCPcopy Create free account
hub / github.com/donkeyteethUX/iced_plot / update_tooltip_positions

Method update_tooltip_positions

src/plot_widget.rs:397–415  ·  view source on GitHub ↗

Update tooltip positions for all hovered and picked points This should be called when the plot canvas position changes

(&mut self)

Source from the content-addressed store, hash-verified

395 world,
396 x_axis_scale,
397 y_axis_scale,
398 transform,
399 Some(camera.axis_ranges()),
400 )?;
401 let ndc_x = (world[0] - camera.position.x) / camera.half_extents.x;
402 let ndc_y = (world[1] - camera.position.y) / camera.half_extents.y;
403 let screen_x = (ndc_x as f32 + 1.0) * 0.5 * bounds.width;
404 let screen_y = (1.0 - ndc_y as f32) * 0.5 * bounds.height;
405
406 (screen_x.is_finite() && screen_y.is_finite()).then_some([screen_x, screen_y])
407 }
408
409 /// Compute the world-space anchor point for a tooltip.
410 ///
411 /// For pixel-sized markers (or no markers), this is the point's (x, y).
412 /// For world-sized square markers, the marker is effectively bottom-left anchored,
413 /// so we anchor the tooltip at the marker's center (x + size/2, y + size/2).
414 fn tooltip_anchor_world(point: &HighlightPoint) -> [f64; 2] {
415 if let Some(marker_style) = point.marker_style
416 && let Size::World(size) = marker_style.size
417 {
418 let half = size * 0.5;

Callers 1

updateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected