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

Function update_plot_program

src/plot_widget.rs:1455–1685  ·  view source on GitHub ↗
(
    widget: &PlotWidget,
    state: &mut PlotState,
    event: &iced::Event,
    bounds: Rectangle,
    cursor: mouse::Cursor,
)

Source from the content-addressed store, hash-verified

1453) {
1454 if !(state.hover_enabled || state.pick_enabled)
1455 || state.points.len() < picking::CPU_PICK_THRESHOLD
1456 {
1457 return;
1458 }
1459
1460 if effects.hover_pick.is_some() {
1461 return;
1462 }
1463
1464 match state
1465 .picking
1466 .consume_gpu_result(widget.instance_id, |pid| widget.valid_point_id(pid))
1467 {
1468 Some(picking::GpuResultEvent::Pick(point)) => {
1469 effects.hover_pick = Some(HoverPickEvent::Pick(point));
1470 }
1471 Some(picking::GpuResultEvent::Hover(point)) => {
1472 effects.hover_pick = Some(HoverPickEvent::Hover(point));
1473 }
1474 Some(picking::GpuResultEvent::HoverMiss) => {
1475 clear_hover_effect(widget, state, effects);
1476 }
1477 None => {}
1478 }
1479}
1480
1481fn update_ticks_and_build_payload(
1482 widget: &PlotWidget,
1483 state: &mut PlotState,
1484 effects: &mut UpdateEffects,
1485 first_time_widget_view: bool,
1486) -> (Option<Vec<PositionedTick>>, Option<Vec<PositionedTick>>) {
1487 if !effects.needs_redraw {
1488 return (None, None);
1489 }
1490
1491 let old_x = state.x_ticks.clone();
1492 let old_y = state.y_ticks.clone();
1493 state.update_ticks(
1494 widget.x_tick_producer.as_ref(),
1495 widget.y_tick_producer.as_ref(),
1496 );
1497
1498 let publish_x =
1499 (first_time_widget_view || (state.x_ticks != old_x)).then(|| state.x_ticks.clone());
1500 let publish_y =
1501 (first_time_widget_view || (state.y_ticks != old_y)).then(|| state.y_ticks.clone());
1502
1503 // If tick producers are disabled, ticks might never change. Still publish camera/bounds
1504 // when overlays need them so screen-space positions stay in sync.
1505 if publish_x.is_none()
1506 && publish_y.is_none()
1507 && widget_needs_camera_bounds(widget)
1508 && widget.camera_bounds != Some((state.camera, state.bounds))
1509 {
1510 effects.publish_camera_bounds = true;
1511 }
1512

Callers

nothing calls this directly

Calls 15

clear_hover_effectFunction · 0.85
apply_data_aspectFunction · 0.85
consume_gpu_pick_resultsFunction · 0.85
has_pick_actionMethod · 0.80
cached_styleMethod · 0.80
static_layerMethod · 0.80
overlay_layerMethod · 0.80
rebuild_from_widgetMethod · 0.80

Tested by

no test coverage detected