fix(ribbon): highlight toggle buttons by their actual state

The UCS Icon, Properties, File Tabs, and Layout Tabs buttons were highlighted unconditionally because their ids fell through to an active_tool equality check in is_active_tool, which activate_tool sets on every click and never clears. Each id is now mapped to its corresponding visibility flag (show_ucs_icon, show_properties, show_file_tabs, show_layout_tabs), and those flags are kept in sync from their toggle handlers so the highlight reflects live state. The per-toggle booleans previously threaded through the render path are consolidated into a single ToggleState struct read from one place, so introducing a further toggle no longer requires changing every render-function signature and call site.
This commit is contained in:
Karim Jerbi authored and Hakan Seven committed 2026-07-12 19:53:48 +03:00
1 parent 15d1bdbdfe
commit 8ef65f59f8
4 files changed
+88 -54

No files matched your search

+2
View File
@@ -81,6 +81,7 @@ impl OpenCADStudio {
let at_origin = sub == "ORIGIN";
// Update model-space icon flags.
self.show_ucs_icon = visible;
self.ribbon.set_ucs_icon(visible);
if sub == "NOORIGIN" || sub == "ORIGIN" {
self.ucs_icon_at_origin = at_origin;
}
@@ -104,6 +105,7 @@ impl OpenCADStudio {
self.push_undo_snapshot(i, "UCSICON");
let visible = !self.show_ucs_icon;
self.show_ucs_icon = visible;
self.ribbon.set_ucs_icon(visible);
for entity in self.tabs[i].scene.document.entities_mut() {
if let acadrust::EntityType::Viewport(vp) = entity {
vp.status.ucs_icon_visible = visible;
+3
View File
@@ -1567,14 +1567,17 @@ impl OpenCADStudio {
}
Message::ToggleProperties => {
self.show_properties ^= true;
self.ribbon.set_properties(self.show_properties);
Task::none()
}
Message::ToggleFileTabs => {
self.show_file_tabs ^= true;
self.ribbon.set_file_tabs(self.show_file_tabs);
Task::none()
}
Message::ToggleLayoutTabs => {
self.show_layout_tabs ^= true;
self.ribbon.set_layout_tabs(self.show_layout_tabs);
Task::none()
}
Message::ToggleOTrack => {