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

Function maybe_submit_hover_request

src/plot_widget.rs:1280–1331  ·  view source on GitHub ↗
(
    widget: &PlotWidget,
    state: &mut PlotState,
    effects: &mut UpdateEffects,
)

Source from the content-addressed store, hash-verified

1278struct UpdateEffects {
1279 needs_redraw: bool,
1280 hover_pick: Option<HoverPickEvent>,
1281 drag_event: Option<DragEvent>,
1282 cursor_ui: Option<CursorPositionUiPayload>,
1283 clear_cursor_position: bool,
1284 /// Request publishing `camera_bounds` even when ticks didn't change.
1285 /// This keeps overlays in sync when tick producers are disabled.
1286 publish_camera_bounds: bool,
1287}
1288
1289#[derive(Default, Debug)]
1290struct CanvasInvalidation {
1291 static_layer: bool,
1292 overlay_layer: bool,
1293}
1294
1295impl CanvasInvalidation {
1296 fn static_layer(&mut self) {
1297 self.static_layer = true;
1298 }
1299
1300 fn overlay_layer(&mut self) {
1301 self.overlay_layer = true;
1302 }
1303
1304 fn all(&mut self) {
1305 self.static_layer = true;
1306 self.overlay_layer = true;
1307 }
1308
1309 fn apply(self, widget: &PlotWidget) {
1310 if self.static_layer {
1311 invalidate_static_canvas(widget);
1312 }
1313 if self.overlay_layer {
1314 invalidate_overlay_canvas(widget);
1315 }
1316 }
1317}
1318
1319fn widget_has_any_tooltips(widget: &PlotWidget) -> bool {
1320 widget
1321 .hovered_points
1322 .values()
1323 .chain(widget.picked_points.values())
1324 .any(|(_, tooltip)| tooltip.is_some())
1325}
1326
1327fn widget_needs_camera_bounds(widget: &PlotWidget) -> bool {
1328 widget_has_any_tooltips(widget) || widget.shape_overlays_enabled.load(Ordering::Relaxed)
1329}
1330
1331fn clear_hover_effect(widget: &PlotWidget, state: &mut PlotState, effects: &mut UpdateEffects) {
1332 let should_clear_hover =
1333 state.picking.last_hover_cache.is_some() || !widget.hovered_points.is_empty();
1334

Callers 1

update_plot_programFunction · 0.85

Calls 5

clear_hover_effectFunction · 0.85
cursor_insideMethod · 0.80
force_cpu_pickingMethod · 0.80
request_hoverMethod · 0.80
valid_point_idMethod · 0.80

Tested by

no test coverage detected