egui: add button to toggle showing ratsnest

This commit is contained in:
Mikolaj Wielgus 2024-05-20 21:15:57 +02:00
parent f03545124f
commit 8999fcb160
1 changed files with 28 additions and 18 deletions

View File

@ -68,6 +68,9 @@ pub struct App {
#[serde(skip)]
from_rect: egui::emath::Rect,
#[serde(skip)]
show_ratsnest: bool,
}
impl Default for App {
@ -78,6 +81,7 @@ impl Default for App {
shared_data: Default::default(),
text_channel: channel(),
from_rect: egui::Rect::from_x_y_ranges(0.0..=1000000.0, 0.0..=500000.0),
show_ratsnest: true,
}
}
}
@ -267,6 +271,10 @@ impl eframe::App for App {
ui.separator();
ui.toggle_value(&mut self.show_ratsnest, "Show Ratsnest");
ui.separator();
egui::widgets::global_dark_light_mode_buttons(ui);
});
});
@ -367,6 +375,7 @@ impl eframe::App for App {
painter.paint_polygon(&layout.zone(zone).shape().polygon, color)
}
if self.show_ratsnest {
for edge in overlay.ratsnest().graph().edge_references() {
let from = overlay
.ratsnest()
@ -387,6 +396,7 @@ impl eframe::App for App {
egui::Stroke::new(1.0, egui::Color32::from_rgb(90, 90, 200)),
);
}
}
if let Some(navmesh) = &shared_data.navmesh {
for edge in navmesh.edge_references() {