From 7b66db1672dc46304c8d8a5e2794d5a9f9b3bb52 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 30 Oct 2025 18:06:32 +0100 Subject: [PATCH] feat(topola-egui): Add checkboxes to toggle displaying obstacles and ghosts Disabled showing them by default. --- crates/topola-egui/src/actions.rs | 8 ++++++++ crates/topola-egui/src/displayer.rs | 17 ++++++++++------- crates/topola-egui/src/menu_bar.rs | 4 ++++ locales/en-US/main.ftl | 2 ++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/crates/topola-egui/src/actions.rs b/crates/topola-egui/src/actions.rs index bd5a680..a2ca713 100644 --- a/crates/topola-egui/src/actions.rs +++ b/crates/topola-egui/src/actions.rs @@ -364,6 +364,8 @@ impl InspectActions { } pub struct DebugActions { + pub highlight_obstacles: Switch, + pub show_ghosts: Switch, pub show_navmesh: Switch, pub show_guide_circles: Switch, pub show_guide_bitangents: Switch, @@ -379,6 +381,9 @@ pub struct DebugActions { impl DebugActions { pub fn new(tr: &Translator) -> Self { Self { + highlight_obstacles: Action::new_keyless(tr.text("tr-menu-debug-highlight-obstacles")) + .into_switch(), + show_ghosts: Action::new_keyless(tr.text("tr-menu-debug-show-ghosts")).into_switch(), show_navmesh: Action::new_keyless(tr.text("tr-menu-debug-show-navmesh")).into_switch(), show_guide_circles: Action::new_keyless(tr.text("tr-menu-debug-show-guide-circles")) .into_switch(), @@ -409,6 +414,9 @@ impl DebugActions { } pub fn render_menu(&mut self, _ctx: &Context, ui: &mut Ui, menu_bar: &mut MenuBar) { + self.highlight_obstacles + .checkbox(ui, &mut menu_bar.highlight_obstacles); + self.show_ghosts.checkbox(ui, &mut menu_bar.show_ghosts); self.show_navmesh.checkbox(ui, &mut menu_bar.show_navmesh); self.show_guide_circles .checkbox(ui, &mut menu_bar.show_guide_circles); diff --git a/crates/topola-egui/src/displayer.rs b/crates/topola-egui/src/displayer.rs index 2742c2e..8e7177e 100644 --- a/crates/topola-egui/src/displayer.rs +++ b/crates/topola-egui/src/displayer.rs @@ -49,7 +49,7 @@ impl<'a> Displayer<'a> { } pub fn update(&mut self, ctx: &egui::Context, menu_bar: &MenuBar) { - self.display_layout(ctx); + self.display_layout(ctx, menu_bar); if menu_bar.show_ratsnest { self.display_ratsnest(menu_bar); @@ -82,7 +82,7 @@ impl<'a> Displayer<'a> { } } - fn display_layout(&mut self, ctx: &egui::Context) { + fn display_layout(&mut self, ctx: &egui::Context, menu_bar: &MenuBar) { let board = self.workspace.interactor.invoker().autorouter().board(); let active_polygons = self .workspace @@ -109,7 +109,8 @@ impl<'a> Displayer<'a> { .color(board.layout().rules().layer_layername(i)) .highlighted } else if let Some(activity) = &mut self.workspace.interactor.maybe_activity() { - if activity.obstacles().contains(&primitive) { + if menu_bar.highlight_obstacles && activity.obstacles().contains(&primitive) + { self.config .colors(ctx) .layers @@ -527,9 +528,11 @@ impl<'a> Displayer<'a> { let board = self.workspace.interactor.invoker().autorouter().board(); if let Some(activity) = self.workspace.interactor.maybe_activity() { - for ghost in activity.ghosts() { - self.painter - .paint_primitive(ghost, egui::Color32::from_rgb(75, 75, 150)); + if menu_bar.show_ghosts { + for ghost in activity.ghosts() { + self.painter + .paint_primitive(ghost, egui::Color32::from_rgb(75, 75, 150)); + } } if let ActivityStepper::Interaction(InteractionStepper::RoutePlan(rp)) = @@ -585,7 +588,7 @@ impl<'a> Displayer<'a> { .center(); let color = if let Some(activity) = &mut self.workspace.interactor.maybe_activity() { - if activity.obstacles().contains(&primitive) { + if menu_bar.highlight_obstacles && activity.obstacles().contains(&primitive) { egui::Color32::from_rgb(255, 255, 255) } else { egui::Color32::from_rgb(150, 150, 150) diff --git a/crates/topola-egui/src/menu_bar.rs b/crates/topola-egui/src/menu_bar.rs index dbe06d0..d35bf37 100644 --- a/crates/topola-egui/src/menu_bar.rs +++ b/crates/topola-egui/src/menu_bar.rs @@ -28,6 +28,8 @@ use crate::{ pub struct MenuBar { pub multilayer_autoroute_options: MultilayerAutorouteOptions, pub is_placing_via: bool, + pub highlight_obstacles: bool, + pub show_ghosts: bool, pub show_ratsnest: bool, pub show_navmesh: bool, pub show_guide_circles: bool, @@ -63,6 +65,8 @@ impl MenuBar { }, }, is_placing_via: false, + highlight_obstacles: false, + show_ghosts: false, show_ratsnest: true, show_navmesh: false, show_guide_circles: false, diff --git a/locales/en-US/main.ftl b/locales/en-US/main.ftl index 9f04228..8844d9a 100644 --- a/locales/en-US/main.ftl +++ b/locales/en-US/main.ftl @@ -37,6 +37,8 @@ tr-menu-route-routed-band-width = Routed Band Width tr-menu-route-fanout-clearance = Fanout Clearance tr-menu-debug = Debug +tr-menu-debug-highlight-obstacles = Highlight Obstacles +tr-menu-debug-show-ghosts = Show Ghosts tr-menu-debug-show-navmesh = Show Navmesh tr-menu-debug-show-guide-circles = Show Guide-Circles tr-menu-debug-show-guide-bitangents = Show Guide-Bitangents