MCPcopy Create free account
hub / github.com/emilk/egui_plot / show_coordinates

Method show_coordinates

egui_plot/src/plot.rs:1422–1454  ·  view source on GitHub ↗
(
        ui: &Ui,
        response: &Response,
        transform: &PlotTransform,
        painter: &Painter,
        coordinates_formatter: &Option<(Corner, CoordinatesFormatter<'_>)>,
    )

Source from the content-addressed store, hash-verified

1420 }
1421
1422 fn show_coordinates(
1423 ui: &Ui,
1424 response: &Response,
1425 transform: &PlotTransform,
1426 painter: &Painter,
1427 coordinates_formatter: &Option<(Corner, CoordinatesFormatter<'_>)>,
1428 ) {
1429 if let Some((corner, formatter)) = coordinates_formatter.as_ref() {
1430 let hover_pos = response.hover_pos();
1431 if let Some(pointer) = hover_pos {
1432 let font_id = TextStyle::Monospace.resolve(ui.style());
1433 let coordinate = transform.value_from_position(pointer);
1434 let text = formatter.format(&coordinate, transform.bounds());
1435 let padded_frame = transform.frame().shrink(4.0);
1436 let (anchor, position) = match corner {
1437 Corner::LeftTop => (Align2::LEFT_TOP, padded_frame.left_top()),
1438 Corner::RightTop => (Align2::RIGHT_TOP, padded_frame.right_top()),
1439 Corner::LeftBottom => (Align2::LEFT_BOTTOM, padded_frame.left_bottom()),
1440 Corner::RightBottom => (Align2::RIGHT_BOTTOM, padded_frame.right_bottom()),
1441 };
1442
1443 let text_color = ui.visuals().text_color();
1444 let galley = painter.layout_no_wrap(text, font_id, text_color);
1445 let rect = anchor.anchor_size(position, galley.size());
1446 painter.rect_filled(
1447 rect.expand(4.0),
1448 ui.style().visuals.window_corner_radius,
1449 ui.style().visuals.extreme_bg_color.gamma_multiply(0.75),
1450 );
1451 painter.galley(rect.min, galley, text_color);
1452 }
1453 }
1454 }
1455
1456 fn paint_grid_direction(
1457 &self,

Callers

nothing calls this directly

Calls 6

value_from_positionMethod · 0.80
formatMethod · 0.80
frameMethod · 0.80
sizeMethod · 0.80
styleMethod · 0.45
boundsMethod · 0.45

Tested by

no test coverage detected