forked from 1b-agent/opencadstudio-upstream
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:
1 parent
8f9fe5226b
commit
89fcb21b46
2 files changed
+24
-9
No files matched your search
@@ -2,6 +2,21 @@ use super::OpenCADStudio;
|
||||
use crate::ui;
|
||||
|
||||
impl OpenCADStudio {
|
||||
/// Reload the `LayerPanel` cache from the document and push the
|
||||
/// fresh state through to the ribbon dropdown + every other
|
||||
/// layer-aware UI mirror. Use this whenever a command mutates the
|
||||
/// document's layer table directly (LAYOFF / LAYFRZ / LAYLCK …) so
|
||||
/// the panel + dropdown reflect the change. See #39.
|
||||
pub(super) fn refresh_layer_panel(&mut self) {
|
||||
let i = self.active_tab;
|
||||
let doc_layers = self.tabs[i].scene.document.layers.clone();
|
||||
let vp_info = self.tabs[i].scene.viewport_list();
|
||||
self.tabs[i]
|
||||
.layers
|
||||
.sync_with_viewports(&doc_layers, vp_info);
|
||||
self.sync_ribbon_layers();
|
||||
}
|
||||
|
||||
pub(super) fn sync_ribbon_layers(&mut self) {
|
||||
let i = self.active_tab;
|
||||
let active = self.tabs[i].active_layer.clone();
|
||||
|
||||
Reference in new issue
Block a user