fix(ribbon): load style/layer dropdowns from the document

The Annotate style dropdowns (text / dimension / multileader / table) and
the layer dropdown were hard-coded to "Standard" / "0" and never synced
from the opened document, so they showed placeholder values even with no
file open and stale values after closing one.

- Start the ribbon's style and layer lists empty instead of with a
  placeholder entry.
- Sync the style dropdowns from the document on file open and on tab
  new/switch/close (the layer sync already ran there).
- Guard sync_ribbon_layers / sync_ribbon_styles / sync_ribbon_from_selection
  for the Start (welcome) tab so all three dropdowns stay empty there.
- When a style family is absent (e.g. no table/multileader styles), fall
  back to empty rather than a non-existent "Standard".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-12 01:46:17 +03:00
commit b47e1bf706
4 changed files with 46 additions and 21 deletions

View file

@ -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(),
}
}