diff --git a/petri/src/lib.rs b/petri/src/lib.rs index e4ef5f3..686c795 100644 --- a/petri/src/lib.rs +++ b/petri/src/lib.rs @@ -18,7 +18,7 @@ pub struct Chunk { pub contents: Box<[[Cell; CHUNK_SIZE]; CHUNK_SIZE]>, } -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize)] pub struct Rule { #[serde(default)] pub name: String, diff --git a/uscope/src/main.rs b/uscope/src/main.rs index 8b5e991..1b47900 100644 --- a/uscope/src/main.rs +++ b/uscope/src/main.rs @@ -174,16 +174,27 @@ impl eframe::App for UScope { ui.heading("Rules"); let mut to_remove = None; + let mut to_clone = None; for (i, rule) in self.dish.rules.iter_mut().enumerate() { ui.separator(); rule_editor(ui, rule, &self.cell_types, &self.dish.cell_groups); - if ui.button("delete").clicked() { - to_remove = Some(i); - } + ui.horizontal(|ui| { + if ui.button("delete").clicked() { + to_remove = Some(i); + } + if ui.button("copy").clicked() { + to_clone = Some(i); + } + }); } if let Some(i) = to_remove { self.dish.rules.remove(i); } + if let Some(i) = to_clone { + let mut new_rule = self.dish.rules[i].clone(); + new_rule.enabled = false; + self.dish.rules.push(new_rule); + } ui.separator(); if ui.button("add rule").clicked() { self.dish.rules.push(Rule::new());