diff --git a/topola-egui/src/appearance_panel.rs b/topola-egui/src/layers_panel.rs similarity index 90% rename from topola-egui/src/appearance_panel.rs rename to topola-egui/src/layers_panel.rs index c2e1390..51b0395 100644 --- a/topola-egui/src/appearance_panel.rs +++ b/topola-egui/src/layers_panel.rs @@ -34,18 +34,20 @@ pub struct LayerColors { } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct AppearancePanel { +pub struct LayersPanel { // TODO: // In1.Cu shall be #7fc87f (#d5ecd5 when selected). // In2.Cu shall be #ce7d2c (#e8c39e when selected). dark_colors: Colors, light_colors: Colors, + #[serde(skip)] + pub active: usize, #[serde(skip)] pub visible: Box<[bool]>, } -impl AppearancePanel { +impl LayersPanel { pub fn new(board: &Board) -> Self { let dark_colors = Colors { layers: ColorLayers { @@ -159,6 +161,7 @@ impl AppearancePanel { Self { dark_colors, light_colors, + active: 0, visible, } } @@ -178,22 +181,11 @@ impl AppearancePanel { .num_columns(3) .start_row(start_row) .show(ui, |ui| { - for (layer, visible) in self.visible[row_range].iter_mut().enumerate() { - let layer = layer + start_row; + for layer in row_range { + let visible = &mut self.visible[layer]; let layer_name = board.layer_name(layer); - // unnamed layers can't be used for routing - /*if layer_name.is_some() { - ui.radio_value( - &mut options.planar.principal_layer, - layer, - WidgetText::default(), - ); - } else { - // dummy item to bump the grid - ui.label(""); - }*/ - + ui.radio_value(&mut self.active, layer, WidgetText::default()); ui.checkbox(visible, WidgetText::default()); ui.label( layer_name diff --git a/topola-egui/src/main.rs b/topola-egui/src/main.rs index ecfd1b8..2843e72 100644 --- a/topola-egui/src/main.rs +++ b/topola-egui/src/main.rs @@ -7,8 +7,8 @@ mod action; mod actions; mod app; -mod appearance_panel; mod display; +mod layers_panel; mod menu_bar; mod translator; mod viewport; diff --git a/topola-egui/src/viewport.rs b/topola-egui/src/viewport.rs index 39e10ae..32da440 100644 --- a/topola-egui/src/viewport.rs +++ b/topola-egui/src/viewport.rs @@ -59,7 +59,7 @@ impl Viewport { .navmesher_board() .board() .point_pin_selector( - 0, + workspace.appearance_panel.active, Vector2::new( pointer_scene_pos.x as i64, pointer_scene_pos.y as i64, diff --git a/topola-egui/src/workspace.rs b/topola-egui/src/workspace.rs index 1479460..59f5992 100644 --- a/topola-egui/src/workspace.rs +++ b/topola-egui/src/workspace.rs @@ -4,17 +4,17 @@ use topola::{Autorouter, Board, selections::PersistableSelection}; -use crate::{appearance_panel::AppearancePanel, translator::Translator}; +use crate::{layers_panel::LayersPanel, translator::Translator}; pub struct Workspace { pub autorouter: Autorouter, - pub appearance_panel: AppearancePanel, + pub appearance_panel: LayersPanel, pub selection: PersistableSelection, } impl Workspace { pub fn new(board: Board, tr: &Translator) -> Self { - let appearance_panel = AppearancePanel::new(&board); + let appearance_panel = LayersPanel::new(&board); Self { autorouter: Autorouter::new(board),