feat(styles): seed current table/multileader style from the file

Bump acadrust to pick up the new $CTABLESTYLE / $CMLEADERSTYLE header
variables, then on load seed the ribbon's active table style and the
tab's active multileader style from the document header so the ✓ marks
the style the file actually declares (DXF). Set Current writes the header
field as the round-trip source of truth, and the style-manager staging
snapshot now covers it. sync_ribbon_styles honours the active table style
instead of always falling back to the first one.

DWG still leaves these at "Standard" until acadrust parses them from the
binary header.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-10 19:05:07 +03:00
commit e65a7a6d67
4 changed files with 36 additions and 5 deletions

2
Cargo.lock generated
View file

@ -56,7 +56,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618"
[[package]]
name = "acadrust"
version = "0.3.4"
source = "git+https://github.com/HakanSeven12/acadrust?branch=main#041df8c0568ea1242a39e22f2d04e770317bdf7c"
source = "git+https://github.com/HakanSeven12/acadrust?branch=main#2f3ff7995110b570bf64e22c5d8752803b8ecf7d"
dependencies = [
"ahash",
"anyhow",

View file

@ -119,10 +119,15 @@ impl OpenCADStudio {
}
})
.collect();
let active_table = table_names
.first()
.cloned()
.unwrap_or_else(|| "Standard".to_string());
let active_table = self.ribbon.active_table_style.clone();
let active_table = if table_names.contains(&active_table) {
active_table
} else {
table_names
.first()
.cloned()
.unwrap_or_else(|| "Standard".to_string())
};
let active_mleader2 = active_mleader.clone();
let active_table2 = active_table.clone();

View file

@ -473,6 +473,8 @@ impl OpenCADStudio {
current_text: doc.header.current_text_style_name.clone(),
current_dim: doc.header.current_dimstyle_name.clone(),
multiline_style: doc.header.multiline_style.clone(),
current_table: doc.header.current_table_style_name.clone(),
current_mleader: doc.header.current_mleader_style_name.clone(),
active_table: self.ribbon.active_table_style.clone(),
active_mleader: self.ribbon.active_mleader_style.clone(),
tab_active_mleader: self.tabs[i].active_mleader_style.clone(),
@ -500,6 +502,8 @@ impl OpenCADStudio {
doc.header.current_text_style_name = snap.current_text.clone();
doc.header.current_dimstyle_name = snap.current_dim.clone();
doc.header.multiline_style = snap.multiline_style.clone();
doc.header.current_table_style_name = snap.current_table.clone();
doc.header.current_mleader_style_name = snap.current_mleader.clone();
self.ribbon.active_table_style = snap.active_table.clone();
self.ribbon.active_mleader_style = snap.active_mleader.clone();
self.tabs[i].active_mleader_style = snap.tab_active_mleader.clone();
@ -563,6 +567,8 @@ pub(super) struct StyleStateSnapshot {
current_text: String,
current_dim: String,
multiline_style: String,
current_table: String,
current_mleader: String,
active_table: String,
active_mleader: String,
tab_active_mleader: String,

View file

@ -300,6 +300,19 @@ impl OpenCADStudio {
self.tabs[i].scene.current_layout = "Model".to_string();
crate::linetypes::populate_document(&mut self.tabs[i].scene.document);
self.tabs[i].properties = PropertiesPanel::empty();
// Seed the current table / multileader style from the file's
// header so the ✓ marks the right one (text/dim/mline come from
// the document header directly). DXF provides these via
// $CTABLESTYLE / $CMLEADERSTYLE; DWG leaves them at "Standard".
self.ribbon.active_table_style =
self.tabs[i].scene.document.header.current_table_style_name.clone();
self.tabs[i].active_mleader_style = self
.tabs[i]
.scene
.document
.header
.current_mleader_style_name
.clone();
let doc_layers = self.tabs[i].scene.document.layers.clone();
let vp_info = self.tabs[i].scene.viewport_list();
self.tabs[i]
@ -6556,11 +6569,15 @@ impl OpenCADStudio {
Task::none()
}
Message::TableStyleDialogSetCurrent => {
// Staged: persists on Apply. The header field is the round-trip
// source of truth ($CTABLESTYLE); the ribbon mirrors it.
let i = self.active_tab;
let name = self.tablestyle_selected.clone();
if self
.style_names(crate::app::StyleKind::Table)
.contains(&name)
{
self.tabs[i].scene.document.header.current_table_style_name = name.clone();
self.ribbon.active_table_style = name.clone();
self.command_line
.push_output(&format!("Current table style: {name}"));
@ -6727,6 +6744,9 @@ impl OpenCADStudio {
.values()
.any(|o| matches!(o, ObjectType::MultiLeaderStyle(s) if s.name == name));
if exists {
// Staged: header field is the round-trip source of truth
// ($CMLEADERSTYLE); the ribbon/tab mirror it.
self.tabs[i].scene.document.header.current_mleader_style_name = name.clone();
self.tabs[i].active_mleader_style = name.clone();
self.ribbon.active_mleader_style = name.clone();
self.command_line