diff --git a/src/bin/topola-egui/app.rs b/src/bin/topola-egui/app.rs index ea0b510..b62574c 100644 --- a/src/bin/topola-egui/app.rs +++ b/src/bin/topola-egui/app.rs @@ -204,6 +204,7 @@ impl eframe::App for App { self.shared_data.clone(), &self.invoker, &mut self.overlay, + &self.layers, ); if ctx.input(|i| i.key_pressed(egui::Key::Escape)) { diff --git a/src/bin/topola-egui/layers.rs b/src/bin/topola-egui/layers.rs index 02a0b05..b0c056a 100644 --- a/src/bin/topola-egui/layers.rs +++ b/src/bin/topola-egui/layers.rs @@ -1,7 +1,7 @@ use topola::board::{mesadata::MesadataTrait, Board}; pub struct Layers { - visible: Box<[bool]>, + pub visible: Box<[bool]>, } impl Layers { diff --git a/src/bin/topola-egui/viewport.rs b/src/bin/topola-egui/viewport.rs index 28b2cf0..43e8e80 100644 --- a/src/bin/topola-egui/viewport.rs +++ b/src/bin/topola-egui/viewport.rs @@ -15,6 +15,7 @@ use topola::{ use crate::{ app::{execute, SharedData}, + layers::Layers, overlay::Overlay, painter::Painter, top::Top, @@ -38,6 +39,7 @@ impl Viewport { shared_data: Arc>, maybe_invoker: &Option>>>, maybe_overlay: &mut Option, + maybe_layers: &Option, ) { egui::CentralPanel::default().show(ctx, |ui| { egui::Frame::canvas(ui.style()).show(ui, |ui| { @@ -106,58 +108,64 @@ impl Viewport { ) { let board = invoker.autorouter().board(); - for primitive in board.layout().drawing().layer_primitive_nodes(1) { - let shape = primitive.primitive(board.layout().drawing()).shape(); + if let Some(layers) = maybe_layers { + if layers.visible[1] { + for primitive in board.layout().drawing().layer_primitive_nodes(1) { + let shape = primitive.primitive(board.layout().drawing()).shape(); - let color = if shared_data.highlighteds.contains(&primitive) - || overlay - .selection() - .contains_node(board, GenericNode::Primitive(primitive)) - { - egui::Color32::from_rgb(100, 100, 255) - } else { - egui::Color32::from_rgb(52, 52, 200) - }; - painter.paint_primitive(&shape, color); - } + let color = if shared_data.highlighteds.contains(&primitive) + || overlay + .selection() + .contains_node(board, GenericNode::Primitive(primitive)) + { + egui::Color32::from_rgb(100, 100, 255) + } else { + egui::Color32::from_rgb(52, 52, 200) + }; + painter.paint_primitive(&shape, color); + } - for zone in board.layout().layer_zone_nodes(1) { - let color = if overlay - .selection() - .contains_node(board, GenericNode::Compound(zone.into())) - { - egui::Color32::from_rgb(100, 100, 255) - } else { - egui::Color32::from_rgb(52, 52, 200) - }; - painter.paint_polygon(&board.layout().zone(zone).shape().polygon, color) - } + for zone in board.layout().layer_zone_nodes(1) { + let color = if overlay + .selection() + .contains_node(board, GenericNode::Compound(zone.into())) + { + egui::Color32::from_rgb(100, 100, 255) + } else { + egui::Color32::from_rgb(52, 52, 200) + }; + painter.paint_polygon(&board.layout().zone(zone).shape().polygon, color) + } + } - for primitive in board.layout().drawing().layer_primitive_nodes(0) { - let shape = primitive.primitive(board.layout().drawing()).shape(); + if layers.visible[0] { + for primitive in board.layout().drawing().layer_primitive_nodes(0) { + let shape = primitive.primitive(board.layout().drawing()).shape(); - let color = if shared_data.highlighteds.contains(&primitive) - || overlay - .selection() - .contains_node(board, GenericNode::Primitive(primitive)) - { - egui::Color32::from_rgb(255, 100, 100) - } else { - egui::Color32::from_rgb(200, 52, 52) - }; - painter.paint_primitive(&shape, color); - } + let color = if shared_data.highlighteds.contains(&primitive) + || overlay + .selection() + .contains_node(board, GenericNode::Primitive(primitive)) + { + egui::Color32::from_rgb(255, 100, 100) + } else { + egui::Color32::from_rgb(200, 52, 52) + }; + painter.paint_primitive(&shape, color); + } - for zone in board.layout().layer_zone_nodes(0) { - let color = if overlay - .selection() - .contains_node(board, GenericNode::Compound(zone.into())) - { - egui::Color32::from_rgb(255, 100, 100) - } else { - egui::Color32::from_rgb(200, 52, 52) - }; - painter.paint_polygon(&board.layout().zone(zone).shape().polygon, color) + for zone in board.layout().layer_zone_nodes(0) { + let color = if overlay + .selection() + .contains_node(board, GenericNode::Compound(zone.into())) + { + egui::Color32::from_rgb(255, 100, 100) + } else { + egui::Color32::from_rgb(200, 52, 52) + }; + painter.paint_polygon(&board.layout().zone(zone).shape().polygon, color) + } + } } if top.show_ratsnest {