| 1285 | } |
| 1286 | |
| 1287 | fn collect_cursors(&self, ui: &Ui, plot_id: Id) -> Vec<Cursor> { |
| 1288 | if let Some((id, _)) = self.linked_cursors.as_ref() { |
| 1289 | ui.data_mut(|data| { |
| 1290 | let frames: &mut CursorLinkGroups = data.get_temp_mut_or_default(Id::NULL); |
| 1291 | let cursors = frames.0.entry(*id).or_default(); |
| 1292 | |
| 1293 | // Look for our previous frame |
| 1294 | let index = cursors |
| 1295 | .iter() |
| 1296 | .enumerate() |
| 1297 | .find(|(_, frame)| frame.id == plot_id) |
| 1298 | .map(|(i, _)| i); |
| 1299 | |
| 1300 | // Remove our previous frame and all older frames as these are no longer |
| 1301 | // displayed. This avoids unbounded growth, as we add an entry |
| 1302 | // each time we draw a plot. |
| 1303 | index.map(|index| cursors.drain(0..=index)); |
| 1304 | |
| 1305 | // Gather all cursors of the remaining frames. This will be all the cursors of |
| 1306 | // the other plots in the group. We want to draw these in the |
| 1307 | // current plot too. |
| 1308 | cursors.iter().flat_map(|frame| frame.cursors.iter().copied()).collect() |
| 1309 | }) |
| 1310 | } else { |
| 1311 | Vec::new() |
| 1312 | } |
| 1313 | } |
| 1314 | |
| 1315 | fn collect_shapes( |
| 1316 | &self, |