From b9a99237a1fb2187f1a037690d893cb14b288e26 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Mon, 8 Jul 2024 01:38:16 +0200 Subject: [PATCH] egui: clear selection when routing is initiated --- src/bin/topola-egui/overlay.rs | 4 ++++ src/bin/topola-egui/top.rs | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bin/topola-egui/overlay.rs b/src/bin/topola-egui/overlay.rs index 9dfb0a4..cedc5ce 100644 --- a/src/bin/topola-egui/overlay.rs +++ b/src/bin/topola-egui/overlay.rs @@ -38,6 +38,10 @@ impl Overlay { }) } + pub fn clear_selection(&mut self) { + self.selection = Selection::new(); + } + pub fn click(&mut self, board: &Board, at: Point) { let geoms: Vec<_> = board .layout() diff --git a/src/bin/topola-egui/top.rs b/src/bin/topola-egui/top.rs index a24b24e..bc92517 100644 --- a/src/bin/topola-egui/top.rs +++ b/src/bin/topola-egui/top.rs @@ -36,7 +36,7 @@ impl Top { history_sender: Sender, arc_mutex_maybe_invoker: Arc>>>, maybe_execute: &mut Option, - maybe_overlay: &Option, + maybe_overlay: &mut Option, ) { egui::TopBottomPanel::top("top_panel").show(ctx, |ui| { egui::menu::bar(ui, |ui| { @@ -105,11 +105,12 @@ impl Top { if maybe_execute.as_mut().map_or(true, |execute| { matches!(execute.maybe_status(), Some(InvokerStatus::Finished)) }) { - if let (Some(invoker), Some(ref overlay)) = ( + if let (Some(invoker), Some(ref mut overlay)) = ( arc_mutex_maybe_invoker.lock().unwrap().as_mut(), maybe_overlay, ) { let selection = overlay.selection().clone(); + overlay.clear_selection(); maybe_execute.insert(ExecuteWithStatus::new( invoker.execute_walk(Command::Autoroute(selection)), ));