diff --git a/crates/topola-egui/src/config.rs b/crates/topola-egui/src/config.rs index 95b1a42..b85784c 100644 --- a/crates/topola-egui/src/config.rs +++ b/crates/topola-egui/src/config.rs @@ -3,8 +3,17 @@ use std::collections::HashMap; #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] #[serde(default)] pub struct Config { - pub dark_theme: Colors, - pub light_theme: Colors, + dark_colors: Colors, + light_colors: Colors, +} + +impl Config { + pub fn colors(&self, ctx: &egui::Context) -> &Colors { + match ctx.theme() { + egui::Theme::Dark => &self.dark_colors, + egui::Theme::Light => &self.light_colors, + } + } } #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] @@ -34,62 +43,111 @@ pub struct LayerColor { impl Default for Config { fn default() -> Self { - let dark_theme = Colors { - layers: LayerColors { - default: LayerColor { - normal: egui::Color32::from_rgb(255, 255, 255), - highlighted: egui::Color32::from_rgb(255, 255, 255), - }, - colors: HashMap::from([ - ( - "F.Cu".to_string(), - LayerColor { - normal: egui::Color32::from_rgb(255, 52, 52), - highlighted: egui::Color32::from_rgb(255, 100, 100), - }, - ), - ( - "1".to_string(), - LayerColor { - normal: egui::Color32::from_rgb(255, 52, 52), - highlighted: egui::Color32::from_rgb(255, 100, 100), - }, - ), - ( - "B.Cu".to_string(), - LayerColor { - normal: egui::Color32::from_rgb(52, 52, 255), - highlighted: egui::Color32::from_rgb(100, 100, 255), - }, - ), - ( - "2".to_string(), - LayerColor { - normal: egui::Color32::from_rgb(52, 52, 255), - highlighted: egui::Color32::from_rgb(100, 100, 255), - }, - ), - ( - "In1.Cu".to_string(), - LayerColor { - normal: egui::Color32::from_rgb(127, 200, 127), - highlighted: egui::Color32::from_rgb(213, 236, 213), - }, - ), - ( - "In2.Cu".to_string(), - LayerColor { - normal: egui::Color32::from_rgb(206, 125, 44), - highlighted: egui::Color32::from_rgb(232, 195, 158), - }, - ), - ]), - }, - }; - Self { - dark_theme: dark_theme.clone(), - light_theme: dark_theme, + dark_colors: Colors { + layers: LayerColors { + default: LayerColor { + normal: egui::Color32::from_rgb(255, 255, 255), + highlighted: egui::Color32::from_rgb(255, 255, 255), + }, + colors: HashMap::from([ + ( + "F.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(255, 52, 52), + highlighted: egui::Color32::from_rgb(255, 100, 100), + }, + ), + ( + "1".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(255, 52, 52), + highlighted: egui::Color32::from_rgb(255, 100, 100), + }, + ), + ( + "B.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(52, 52, 255), + highlighted: egui::Color32::from_rgb(100, 100, 255), + }, + ), + ( + "2".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(52, 52, 255), + highlighted: egui::Color32::from_rgb(100, 100, 255), + }, + ), + ( + "In1.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(127, 200, 127), + highlighted: egui::Color32::from_rgb(213, 236, 213), + }, + ), + ( + "In2.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(206, 125, 44), + highlighted: egui::Color32::from_rgb(232, 195, 158), + }, + ), + ]), + }, + }, + light_colors: Colors { + layers: LayerColors { + default: LayerColor { + normal: egui::Color32::from_rgb(0, 0, 0), + highlighted: egui::Color32::from_rgb(0, 0, 0), + }, + colors: HashMap::from([ + ( + "F.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(255, 27, 27), + highlighted: egui::Color32::from_rgb(255, 52, 52), + }, + ), + ( + "1".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(255, 27, 27), + highlighted: egui::Color32::from_rgb(255, 52, 52), + }, + ), + ( + "B.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(27, 27, 255), + highlighted: egui::Color32::from_rgb(52, 52, 255), + }, + ), + ( + "2".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(27, 27, 255), + highlighted: egui::Color32::from_rgb(52, 52, 255), + }, + ), + ( + "In1.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(76, 169, 76), + highlighted: egui::Color32::from_rgb(127, 200, 127), + }, + ), + ( + "In2.Cu".to_string(), + LayerColor { + normal: egui::Color32::from_rgb(183, 80, 12), + highlighted: egui::Color32::from_rgb(206, 125, 44), + }, + ), + ]), + }, + }, } } } diff --git a/crates/topola-egui/src/menu_bar.rs b/crates/topola-egui/src/menu_bar.rs index 15e4210..6713ec7 100644 --- a/crates/topola-egui/src/menu_bar.rs +++ b/crates/topola-egui/src/menu_bar.rs @@ -332,7 +332,7 @@ impl MenuBar { pub fn update_view_menu( &mut self, - ctx: &egui::Context, + _ctx: &egui::Context, ui: &mut egui::Ui, tr: &Translator, viewport: &mut Viewport, diff --git a/crates/topola-egui/src/overlay.rs b/crates/topola-egui/src/overlay.rs index 74efa8b..1b804b0 100644 --- a/crates/topola-egui/src/overlay.rs +++ b/crates/topola-egui/src/overlay.rs @@ -9,10 +9,7 @@ use topola::{ graph::{GetLayer, MakePrimitive}, primitive::MakePrimitiveShape, }, - geometry::{ - compound::ManageCompounds, - shape::{AccessShape, Shape}, - }, + geometry::shape::{AccessShape, Shape}, graph::{GenericIndex, GetPetgraphIndex}, layout::{ poly::{MakePolyShape, PolyWeight}, diff --git a/crates/topola-egui/src/viewport.rs b/crates/topola-egui/src/viewport.rs index 81dd942..776dbea 100644 --- a/crates/topola-egui/src/viewport.rs +++ b/crates/topola-egui/src/viewport.rs @@ -17,7 +17,6 @@ use topola::{ geometry::{shape::AccessShape, GenericNode}, layout::{poly::MakePolyShape, via::ViaWeight}, math::Circle, - specctra::mesadata::SpecctraMesadata, }; use crate::{config::Config, menu_bar::MenuBar, painter::Painter, workspace::Workspace}; @@ -93,15 +92,15 @@ impl Viewport { .selection() .contains_node(board, GenericNode::Primitive(primitive)) { - config.dark_theme.layers.color(board.layout().rules().layer_layername(i)).highlighted + config.colors(ctx).layers.color(board.layout().rules().layer_layername(i)).highlighted } else if let Some(activity) = &mut workspace.interactor.maybe_activity() { if activity.obstacles().contains(&primitive) { - config.dark_theme.layers.color(board.layout().rules().layer_layername(i)).highlighted + config.colors(ctx).layers.color(board.layout().rules().layer_layername(i)).highlighted } else { - config.dark_theme.layers.color(board.layout().rules().layer_layername(i)).normal + config.colors(ctx).layers.color(board.layout().rules().layer_layername(i)).normal } } else { - config.dark_theme.layers.color(board.layout().rules().layer_layername(i)).normal + config.colors(ctx).layers.color(board.layout().rules().layer_layername(i)).normal }; painter.paint_primitive(&shape, color); @@ -112,9 +111,9 @@ impl Viewport { .selection() .contains_node(board, GenericNode::Compound(poly.into())) { - config.dark_theme.layers.color(board.layout().rules().layer_layername(i)).highlighted + config.colors(ctx).layers.color(board.layout().rules().layer_layername(i)).highlighted } else { - config.dark_theme.layers.color(board.layout().rules().layer_layername(i)).normal + config.colors(ctx).layers.color(board.layout().rules().layer_layername(i)).normal }; painter.paint_polygon(&board.layout().poly(poly).shape().polygon, color) diff --git a/crates/topola-egui/src/workspace.rs b/crates/topola-egui/src/workspace.rs index 76f392b..e39326b 100644 --- a/crates/topola-egui/src/workspace.rs +++ b/crates/topola-egui/src/workspace.rs @@ -4,14 +4,10 @@ use std::{ }; use topola::{ - autorouter::{history::History, invoker::Invoker, Autorouter}, - interactor::{ - activity::{ActivityContext, ActivityStepperWithStatus, InteractiveInput}, - Interactor, - }, + autorouter::history::History, + interactor::{activity::InteractiveInput, Interactor}, layout::LayoutEdit, specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata}, - stepper::Step, }; use crate::{