diff --git a/examples/configurable/src/main.rs b/examples/configurable/src/main.rs index 65befd9..ee1c32d 100644 --- a/examples/configurable/src/main.rs +++ b/examples/configurable/src/main.rs @@ -27,8 +27,8 @@ pub struct ConfigurableApp { settings_navigation: SettingsNavigation, settings_style: SettingsStyle, - selected_nodes: Vec>, - selected_edges: Vec>, + selected_nodes: Vec, + selected_edges: Vec, last_events: Vec, simulation_stopped: bool, @@ -128,6 +128,7 @@ impl ConfigurableApp { /// If node or edge is selected it is added to the corresponding selected field in `self`. fn sync_graph_with_simulation(&mut self) { self.selected_nodes = vec![]; + self.selected_edges = vec![]; let g_indices = self.g.g.node_indices().collect::>(); for g_n_idx in &g_indices { @@ -138,7 +139,14 @@ impl ConfigurableApp { g_n.set_location(Pos2::new(loc.x, loc.y)); if g_n.selected() { - self.selected_nodes.push(g_n.clone()); + self.selected_nodes.push(*g_n_idx); + } + } + + for g_e_idx in self.g.g.edge_indices() { + let g_e = self.g.g.edge_weight(g_e_idx).unwrap(); + if g_e.selected() { + self.selected_edges.push(g_e_idx); } } @@ -489,10 +497,10 @@ impl ConfigurableApp { CollapsingHeader::new("Selected").default_open(true).show(ui, |ui| { ScrollArea::vertical().auto_shrink([false, true]).max_height(200.).show(ui, |ui| { self.selected_nodes.iter().for_each(|node| { - ui.label(format!("{:?}", node)); + ui.label(format!("{node:?}")); }); self.selected_edges.iter().for_each(|edge| { - ui.label(format!("{:?}", edge)); + ui.label(format!("{edge:?}")); }); }); }); diff --git a/examples/label_change/src/main.rs b/examples/label_change/src/main.rs index 5260623..f752ad3 100644 --- a/examples/label_change/src/main.rs +++ b/examples/label_change/src/main.rs @@ -23,7 +23,7 @@ impl BasicApp { fn read_data(&mut self) { if let Some((selected_idx, _)) = self.g.nodes_iter().find(|(_, n)| n.selected()) { - self.selected_node = Some(selected_idx.clone()); + self.selected_node = Some(selected_idx); self.label_input = self.g.node(selected_idx).unwrap().label(); } }