diff --git a/src/app/layers.rs b/src/app/layers.rs index 2e02024c3..849cb0766 100644 --- a/src/app/layers.rs +++ b/src/app/layers.rs @@ -19,6 +19,14 @@ impl OpenCADStudio { pub(super) fn sync_ribbon_layers(&mut self) { let i = self.active_tab; + // The Start (welcome) tab has no document — leave the layer and + // linetype dropdowns empty instead of showing a placeholder "0". + if self.tabs[i].is_start { + self.ribbon.set_layers(vec![], ""); + self.ribbon.set_available_linetypes(vec![]); + self.sync_ribbon_styles(); + return; + } let active = self.tabs[i].active_layer.clone(); let infos: Vec = self.tabs[i] .layers @@ -63,6 +71,13 @@ impl OpenCADStudio { pub(super) fn sync_ribbon_styles(&mut self) { let i = self.active_tab; + // The Start (welcome) tab has no real document — keep the Annotate + // style dropdowns empty rather than showing a placeholder style. + if self.tabs[i].is_start { + self.ribbon + .set_styles(vec![], "", vec![], "", vec![], "", vec![], ""); + return; + } let doc = &self.tabs[i].scene.document; let text_names: Vec = doc.text_styles.iter().map(|s| s.name.clone()).collect(); @@ -73,7 +88,7 @@ impl OpenCADStudio { text_names .first() .cloned() - .unwrap_or_else(|| "Standard".to_string()) + .unwrap_or_default() }; let dim_names: Vec = doc.dim_styles.iter().map(|s| s.name.clone()).collect(); @@ -84,7 +99,7 @@ impl OpenCADStudio { dim_names .first() .cloned() - .unwrap_or_else(|| "Standard".to_string()) + .unwrap_or_default() }; let mleader_names: Vec = doc @@ -105,7 +120,7 @@ impl OpenCADStudio { mleader_names .first() .cloned() - .unwrap_or_else(|| "Standard".to_string()) + .unwrap_or_default() }; let table_names: Vec = doc @@ -126,7 +141,7 @@ impl OpenCADStudio { table_names .first() .cloned() - .unwrap_or_else(|| "Standard".to_string()) + .unwrap_or_default() }; let active_mleader2 = active_mleader.clone(); diff --git a/src/app/properties.rs b/src/app/properties.rs index a393afed0..8eef3bde2 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -325,6 +325,12 @@ impl OpenCADStudio { /// marker to do better). pub(super) fn sync_ribbon_from_selection(&mut self) { let i = self.active_tab; + // The Start (welcome) tab has no document — keep the ribbon's + // current-layer chip empty rather than re-seeding it with a default. + if self.tabs[i].is_start { + self.ribbon.active_layer = String::new(); + return; + } let selected = self.tabs[i].scene.selected_entities(); if selected.is_empty() { // Creation defaults: prefer the file's saved CECOLOR / CELTYPE / diff --git a/src/app/update.rs b/src/app/update.rs index bc1d117a1..b14b6d6d3 100644 --- a/src/app/update.rs +++ b/src/app/update.rs @@ -322,6 +322,10 @@ impl OpenCADStudio { .layers .sync_with_viewports(&doc_layers, vp_info); self.sync_ribbon_layers(); + // Load the Annotate-ribbon style dropdowns (text / dimension / + // multileader / table) from the opened document instead of + // leaving them on the hard-coded "Standard" default. + self.sync_ribbon_styles(); // Reset the Home-ribbon Color / Linetype / Lineweight chips // to the newly opened document's CECOLOR / CELTYPE / CELWEIGHT // defaults (or to ByLayer when the file leaves them empty). @@ -917,6 +921,7 @@ impl OpenCADStudio { self.tabs.push(new_tab); self.active_tab = self.tabs.len() - 1; self.sync_ribbon_layers(); + self.sync_ribbon_styles(); // #21: reset ribbon Color / Linetype / Lineweight to the // fresh tab's defaults (ByLayer) instead of inheriting the // previous tab's last selection. @@ -928,6 +933,7 @@ impl OpenCADStudio { if idx < self.tabs.len() { self.active_tab = idx; self.sync_ribbon_layers(); + self.sync_ribbon_styles(); // #21: also re-seed ribbon Color / Linetype / Lineweight // from the newly active tab so they reflect that doc's // CECOLOR / CELTYPE / CELWEIGHT (or its current selection @@ -963,6 +969,7 @@ impl OpenCADStudio { // different existing tab; in both cases the ribbon needs // to track that doc's defaults / selection. #21. self.sync_ribbon_layers(); + self.sync_ribbon_styles(); self.sync_ribbon_from_selection(); Task::none() } diff --git a/src/ui/ribbon/mod.rs b/src/ui/ribbon/mod.rs index adbbc83f7..1f057288b 100644 --- a/src/ui/ribbon/mod.rs +++ b/src/ui/ribbon/mod.rs @@ -74,15 +74,10 @@ impl Ribbon { ortho_mode: true, open_dropdown: None, last_cmd: HashMap::default(), - layer_names: vec!["0".to_string()], - active_layer: "0".to_string(), - layer_infos: vec![LayerInfo { - name: "0".to_string(), - color: Color::WHITE, - visible: true, - frozen: false, - locked: false, - }], + // Empty until a document is open — populated by sync_ribbon_layers. + layer_names: vec![], + active_layer: String::new(), + layer_infos: vec![], active_color: AcadColor::ByLayer, active_linetype: "ByLayer".to_string(), active_lineweight: LineWeight::ByLayer, @@ -91,14 +86,16 @@ impl Ribbon { art: String::new(), }], prop_color_palette_open: false, - text_style_names: vec!["Standard".to_string()], - active_text_style: "Standard".to_string(), - dim_style_names: vec!["Standard".to_string()], - active_dim_style: "Standard".to_string(), - mleader_style_names: vec!["Standard".to_string()], - active_mleader_style: "Standard".to_string(), - table_style_names: vec!["Standard".to_string()], - active_table_style: "Standard".to_string(), + // Empty until a document is open — the Annotate style dropdowns + // are populated from the active document by sync_ribbon_styles. + text_style_names: vec![], + active_text_style: String::new(), + dim_style_names: vec![], + active_dim_style: String::new(), + mleader_style_names: vec![], + active_mleader_style: String::new(), + table_style_names: vec![], + active_table_style: String::new(), } }