From fbab4c493425f73a172ea27e56138e08c913694b Mon Sep 17 00:00:00 2001 From: Karim Jerbi Date: Fri, 14 Aug 2026 23:33:45 +0100 Subject: [PATCH] feat(ribbon): Block Palette button reflects panel open state The Insert tab's Block Palette button now behaves like the View tab toggles (UCS Icon, View Cube, Ortho, Properties, File Tabs, Layout Tabs): it stays highlighted while the block palette panel is open and clears when closed. The Ribbon gains a show_block_palette flag with a set_block_palette setter, fed into ToggleState and mapped in is_active_tool for the BLOCKPALETTE tool id. show_block_palette on the app remains the single source of truth; both mutation paths now mirror it onto the ribbon: - BLOCKPALETTE / BLOCKSPALETTE command toggles ribbon state alongside the panel (src/app/commands/blocks.rs). - Closing the panel via the dock rail close button clears the ribbon state, matching how Close(Properties) already syncs (src/app/update/dialog.rs). --- src/app/commands/blocks.rs | 1 + src/app/update/dialog.rs | 1 + src/ui/ribbon/mod.rs | 8 ++++++++ src/ui/ribbon/widgets.rs | 2 ++ 4 files changed, 12 insertions(+) diff --git a/src/app/commands/blocks.rs b/src/app/commands/blocks.rs index 6cf2394ae..2d0e94e5c 100644 --- a/src/app/commands/blocks.rs +++ b/src/app/commands/blocks.rs @@ -486,6 +486,7 @@ 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. diff --git a/src/app/update/dialog.rs b/src/app/update/dialog.rs index 10795046f..318957ea1 100644 --- a/src/app/update/dialog.rs +++ b/src/app/update/dialog.rs @@ -597,6 +597,7 @@ 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 => { diff --git a/src/ui/ribbon/mod.rs b/src/ui/ribbon/mod.rs index 626a6c6e0..1d187f5e7 100644 --- a/src/ui/ribbon/mod.rs +++ b/src/ui/ribbon/mod.rs @@ -50,6 +50,9 @@ pub struct Ribbon { pub show_ucs_icon: bool, /// Properties panel (PROPERTIES) visibility — drives the Properties button highlight. pub show_properties: bool, + /// Block Palette panel (BLOCKPALETTE) visibility — drives the Block Palette + /// button highlight. + pub show_block_palette: bool, /// File tabs (FILETAB) visibility — drives the File Tabs button highlight. pub show_file_tabs: bool, /// Layout tabs (LAYOUTTAB) visibility — drives the Layout Tabs button highlight. @@ -158,6 +161,7 @@ impl Ribbon { show_viewcube: true, show_ucs_icon: true, show_properties: true, + show_block_palette: false, show_file_tabs: true, show_layout_tabs: true, open_dropdown: None, @@ -311,6 +315,9 @@ impl Ribbon { pub fn set_properties(&mut self, on: bool) { self.show_properties = on; } + pub fn set_block_palette(&mut self, on: bool) { + self.show_block_palette = on; + } pub fn set_file_tabs(&mut self, on: bool) { self.show_file_tabs = on; } @@ -325,6 +332,7 @@ impl Ribbon { show_viewcube: self.show_viewcube, show_ucs_icon: self.show_ucs_icon, show_properties: self.show_properties, + show_block_palette: self.show_block_palette, show_file_tabs: self.show_file_tabs, show_layout_tabs: self.show_layout_tabs, } diff --git a/src/ui/ribbon/widgets.rs b/src/ui/ribbon/widgets.rs index a2807cf9b..2b3b7d1a5 100644 --- a/src/ui/ribbon/widgets.rs +++ b/src/ui/ribbon/widgets.rs @@ -37,6 +37,7 @@ pub(super) struct ToggleState { pub show_viewcube: bool, pub show_ucs_icon: bool, pub show_properties: bool, + pub show_block_palette: bool, pub show_file_tabs: bool, pub show_layout_tabs: bool, } @@ -359,6 +360,7 @@ pub(super) fn is_active_tool( "NAVVCUBE" => state.show_viewcube, "UCSICON" => state.show_ucs_icon, "PROPERTIES" => state.show_properties, + "BLOCKPALETTE" => state.show_block_palette, "FILETAB" => state.show_file_tabs, "LAYOUTTAB" => state.show_layout_tabs, id => active_tool.as_deref() == Some(id),