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

Method handle_hover_pick

src/plot_widget.rs:515–580  ·  view source on GitHub ↗
(&mut self, point_id: PointId)

Source from the content-addressed store, hash-verified

513
514 /// Add a hover point to the plot.
515 pub fn add_hover_point(&mut self, point_id: PointId) {
516 self.handle_hover_pick::<false>(point_id);
517 }
518
519 /// Add a pick point to the plot.
520 pub fn add_pick_point(&mut self, point_id: PointId) {
521 self.handle_hover_pick::<true>(point_id);
522 }
523
524 /// Clear all hover points from the plot.
525 pub fn clear_hover(&mut self) {
526 if !self.hovered_points.is_empty() {
527 self.hovered_points.clear();
528 }
529 }
530
531 /// Clear all pick points from the plot.
532 pub fn clear_pick(&mut self) {
533 if !self.picked_points.is_empty() {
534 self.picked_points.clear();
535 }
536 }
537
538 fn cached_style(&self) -> PlotStyle {
539 *self
540 .resolved_style
541 .read()
542 .expect("plot style lock poisoned")
543 }
544
545 fn handle_hover_pick<const PICK: bool>(&mut self, point_id: PointId) -> bool {
546 let mut changed = false;
547 let (highlight_provider, points) = if PICK {
548 // Clicking an already-picked point deselects it.
549 if self.picked_points.shift_remove(&point_id).is_some() {
550 return true;
551 }
552 changed |= self.hovered_points.shift_remove(&point_id).is_some();
553 (&self.pick_highlight_provider, &mut self.picked_points)
554 } else {
555 if self.picked_points.contains_key(&point_id) {
556 return false;
557 }
558 (&self.hover_highlight_provider, &mut self.hovered_points)
559 };
560 if let Some(highlight_provider) = highlight_provider
561 && let Some(series) = self.series.get(&point_id.series_id)
562 && let Some(position) = series.positions.get(point_id.point_index)
563 && let Some(camera_bounds) = &self.camera_bounds
564 {
565 let mut highlight_point = HighlightPoint {
566 x: position[0],
567 y: position[1],
568 transform: series.transform.clone(),
569 color: series
570 .point_colors
571 .as_ref()
572 .map(|colors| colors[point_id.point_index])

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected