From 0552dd3f33b6ba9074c395130e9a4ee7d68ee4b0 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sun, 21 Jul 2024 13:59:08 +0200 Subject: [PATCH] egui: put debug visualization checkboxes in a dropdown menu --- src/bin/topola-egui/top.rs | 11 ++++++++--- src/bin/topola-egui/viewport.rs | 32 +++++++++++++++++--------------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/bin/topola-egui/top.rs b/src/bin/topola-egui/top.rs index 9d68312..027126d 100644 --- a/src/bin/topola-egui/top.rs +++ b/src/bin/topola-egui/top.rs @@ -23,6 +23,7 @@ pub struct Top { pub show_ratsnest: bool, pub show_navmesh: bool, pub show_bboxes: bool, + pub show_origin_destination: bool, } impl Top { @@ -32,6 +33,7 @@ impl Top { show_ratsnest: false, show_navmesh: false, show_bboxes: false, + show_origin_destination: false, } } @@ -109,9 +111,12 @@ impl Top { ui.separator(); - ui.toggle_value(&mut self.show_ratsnest, "Show Ratsnest"); - ui.toggle_value(&mut self.show_navmesh, "Show Navmesh"); - ui.toggle_value(&mut self.show_bboxes, "Show Bboxes"); + ui.menu_button("Debug", |ui| { + ui.checkbox(&mut self.show_ratsnest, "Show Ratsnest"); + ui.checkbox(&mut self.show_navmesh, "Show Navmesh"); + ui.checkbox(&mut self.show_bboxes, "Show BBoxes"); + ui.checkbox(&mut self.show_origin_destination, "Show Origin–Destination"); + }); ui.separator(); diff --git a/src/bin/topola-egui/viewport.rs b/src/bin/topola-egui/viewport.rs index 296b52f..2966751 100644 --- a/src/bin/topola-egui/viewport.rs +++ b/src/bin/topola-egui/viewport.rs @@ -230,21 +230,23 @@ impl Viewport { } if let Some(navmesh) = execute.maybe_navmesh() { - if let (origin, destination) = (navmesh.origin(), navmesh.destination()) { - painter.paint_dot( - Circle { - pos: board.layout().drawing().primitive(origin).shape().center(), - r: 150.0, - }, - egui::Color32::from_rgb(255, 255, 100), - ); - painter.paint_dot( - Circle { - pos: board.layout().drawing().primitive(destination).shape().center(), - r: 150.0, - }, - egui::Color32::from_rgb(255, 255, 100), - ); + if top.show_origin_destination { + if let (origin, destination) = (navmesh.origin(), navmesh.destination()) { + painter.paint_dot( + Circle { + pos: board.layout().drawing().primitive(origin).shape().center(), + r: 150.0, + }, + egui::Color32::from_rgb(255, 255, 100), + ); + painter.paint_dot( + Circle { + pos: board.layout().drawing().primitive(destination).shape().center(), + r: 150.0, + }, + egui::Color32::from_rgb(255, 255, 100), + ); + } } } }