fix(layer): propagate LAY* command changes to panel + dropdown (#39)

LAYOFF / LAYFRZ / LAYLCK / LAYON / LAYTHW / LAYULK / LAYISO /
LAYUNISO mutated the document's layer table (\`turn_off\` /
\`freeze\` / \`lock\` / …) and then called \`sync_ribbon_layers\`,
which feeds the ribbon dropdown from \`self.tabs[i].layers.layers\`
— the \`LayerPanel\` cache. That cache was never refreshed from
the document for these commands, so the dropdown stayed wrong and
the Layers Properties Manager kept showing the old visibility /
lock / freeze icons.

Add \`OpenCADStudio::refresh_layer_panel\` that runs
\`LayerPanel::sync_with_viewports\` from the live document before
calling \`sync_ribbon_layers\`. Replace every direct
\`sync_ribbon_layers\` in \`commands.rs\` (all of them sit inside
LAY* arms) with the new helper.

Closes #39
This commit is contained in:
Hakan Seven 2026-05-29 01:30:02 +03:00
commit 89fcb21b46
2 changed files with 24 additions and 9 deletions

View file

@ -131,7 +131,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line.push_info("Layer(s) turned off.");
}
}
@ -165,7 +165,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line.push_info("Layer(s) frozen.");
}
}
@ -196,7 +196,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line.push_info("Layer(s) locked.");
}
}
@ -215,7 +215,7 @@ impl OpenCADStudio {
self.tabs[i].layers.current_layer = layer.clone();
self.command_line
.push_info(&format!("Current layer set to \"{layer}\"."));
self.sync_ribbon_layers();
self.refresh_layer_panel();
}
}
@ -234,7 +234,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line.push_info("All layers turned on.");
}
@ -253,7 +253,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line.push_info("All layers thawed.");
}
@ -283,7 +283,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line.push_info("Layer(s) unlocked.");
}
}
@ -316,7 +316,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line
.push_info(&format!("LAYISO: isolated {} layer(s).", sel_layers.len()));
}
@ -338,7 +338,7 @@ impl OpenCADStudio {
}
}
self.tabs[i].dirty = true;
self.sync_ribbon_layers();
self.refresh_layer_panel();
self.command_line
.push_info("LAYUNISO: all layers restored.");
}