(&mut self, message: Message)
| 84 | } |
| 85 | |
| 86 | fn update(&mut self, message: Message) { |
| 87 | const DRAG_PICK_RADIUS_WORLD: f64 = 0.5; |
| 88 | |
| 89 | match message { |
| 90 | Message::Plot(plot_msg) => { |
| 91 | let mut drag_event = None; |
| 92 | |
| 93 | if let PlotUiMessage::RenderUpdate(update) = &plot_msg { |
| 94 | drag_event = update.drag_event; |
| 95 | } |
| 96 | |
| 97 | self.widget.update(plot_msg); |
| 98 | |
| 99 | if let Some(drag_event) = drag_event { |
| 100 | match drag_event { |
| 101 | DragEvent::Start { world, .. } => { |
| 102 | self.active_control_point = nearest_control_point_index( |
| 103 | &self.control_points, |
| 104 | world, |
| 105 | DRAG_PICK_RADIUS_WORLD, |
| 106 | ); |
| 107 | self.move_control_point(world); |
| 108 | } |
| 109 | DragEvent::Update { world, .. } => { |
| 110 | self.move_control_point(world); |
| 111 | } |
| 112 | DragEvent::End { .. } => { |
| 113 | self.active_control_point = None; |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | fn move_control_point(&mut self, world: [f64; 2]) { |
| 122 | if let Some(index) = self.active_control_point |
nothing calls this directly
no test coverage detected