From 810c19d7dfa5eaff1b8feb74c023a5e9a1b27036 Mon Sep 17 00:00:00 2001 From: Emilia Date: Sat, 22 Nov 2025 23:07:44 -0500 Subject: [PATCH] Edit plate was not working, and new plate by dbl click --- plate-tool-eframe/src/tree.rs | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/plate-tool-eframe/src/tree.rs b/plate-tool-eframe/src/tree.rs index 5d4635c..9ee3dfa 100644 --- a/plate-tool-eframe/src/tree.rs +++ b/plate-tool-eframe/src/tree.rs @@ -44,12 +44,14 @@ fn tree_label( } ui.painter().galley(text_pos, galley, visuals.text_color()); - if response.clicked() { - return (Some(uuid), false); - } + // Important to process double click first, since a double click is also a normal click if response.double_clicked() { return (None, true); } + + if response.clicked() { + return (Some(uuid), false); + } (None, false) } @@ -61,7 +63,19 @@ pub fn tree( ) { // Add all source plates ui.vertical(|ui| { - ui.heading("Source Plates"); + let src_heading_res = ui.add( + egui::Label::new(egui::RichText::new("Source Plates").heading()) + .selectable(false) + .sense(egui::Sense::click()), + ); + // Open new plate modal if double clicked + if src_heading_res.double_clicked() { + crate::modals::open_new_plate_modal_with_default_type( + modal_state, + plate_tool_lib::plate::PlateType::Source, + ); + } + let mut new_uuid: Option = None; for (name, uuid) in ms.source_plates.iter().map(|x| (&x.name, x.get_uuid())) { let (potential_new_uuid, dbl_clicked) = tree_label( @@ -97,7 +111,19 @@ pub fn tree( // Add all destination plates ui.vertical(|ui| { - ui.heading("Destination Plates"); + let dest_heading_res = ui.add( + egui::Label::new(egui::RichText::new("Destination Plates").heading()) + .selectable(false) + .sense(egui::Sense::click()), + ); + // Open new plate modal if double clicked + if dest_heading_res.double_clicked() { + crate::modals::open_new_plate_modal_with_default_type( + modal_state, + plate_tool_lib::plate::PlateType::Destination, + ); + } + let mut new_uuid: Option = None; for (name, uuid) in ms .destination_plates