refactor(ribbon): derive the Block Palette button highlight from app state

The ribbon kept its own \show_block_palette\ copy that the app had to
manually sync at every mutation point (the BLOCKPALETTE command and the
dock Close handler). Drop the copy and thread the app's authoritative
\show_block_palette\ into \Ribbon::view\ at render time, so the button
highlight can't drift from the panel's true visibility — those two
handlers are now mutate-points only and the ribbon view is the single
place that reads the state back.
This commit is contained in:
Karim Jerbi committed 2026-08-15 14:42:08 +01:00
1 parent c3e3132b39
commit b4da342f0e
4 files changed
+27 -12

No files matched your search

-1
View File
@@ -486,7 +486,6 @@ impl OpenCADStudio {
// BLOCKPALETTE / BLOCKSPALETTE — toggle the docked Insert Block panel.
"BLOCKPALETTE" | "BLOCKSPALETTE" => {
self.show_block_palette ^= true;
self.ribbon.set_block_palette(self.show_block_palette);
if self.show_block_palette {
// Always open expanded so the panel is immediately usable;
// the user can still collapse it via the pin (Auto) button.
-1
View File
@@ -597,7 +597,6 @@ pub(super) fn on_ribbon_tool_click(&mut self, tool_id: String, event: ModuleEven
match id {
PanelId::BlockPalette => {
self.show_block_palette = false;
self.ribbon.set_block_palette(false);
self.block_palette.placing = None;
}
PanelId::Properties => {
+1
View File
@@ -1742,6 +1742,7 @@ impl OpenCADStudio {
self.tabs[self.active_tab].is_start,
self.tabs[self.active_tab].history.undo_stack.len(),
self.tabs[self.active_tab].history.redo_stack.len(),
self.show_block_palette,
));
}
if self.show_file_tabs {