fix(ribbon): highlight follows each tool's mechanism; start-tab dimming (#355)

Tool highlights used to stick: every click set active_tool, but only
interactive commands and a hand-maintained per-modal list ever cleared
it, so one-shots (Cleanup/AUDIT, view actions) and unlisted dialogs
(Customization/ALIASEDIT, CUI, Plugin Manager…) stayed blue forever.

Now the rule is mechanical: state toggles light from state only (the
click highlight drops immediately), interactive commands stay lit
while running, dialog openers stay lit until the modal closes (generic
clear replaces the per-modal list), and one-shots never keep it — the
dispatch site turns the highlight off when nothing stayed running.

On the Start tab, tools whose command the start gate refuses now render
dimmed (grey icon + label) across all button styles, dropdowns and the
quick-access strip; start_allowed() is the single shared authority.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Fable 5 committed 2026-07-22 00:13:48 +03:00
1 parent 7a93ba82b3
commit b7457ba09d
7 files changed
+159 -90

No files matched your search

+27 -21
View File
@@ -108,27 +108,7 @@ impl OpenCADStudio {
// editors (shortcuts, aliases) — none of them read the scene. This is
// the single place that decides; `on_ribbon_tool_click` defers to it
// rather than keeping a second, blunter copy (#388, #389).
if self.tabs[i].is_start
&& !matches!(
cmd,
"NEW"
| "OPEN"
| "EXIT"
| "QUIT"
| "REPORT"
| "CHANGELOG"
| "ABOUT"
| "PLUGINS"
| "PLUGINMANAGER"
| "DONATE"
| "WEBVERSION"
| "HELP"
| "CUI"
| "ALIASEDIT"
| "CUILOAD"
| "CUIIMPORT"
)
{
if self.tabs[i].is_start && !start_allowed(cmd) {
self.command_line
.push_info("No drawing open. Use NEW or OPEN to start a drawing.");
return Task::none();
@@ -235,6 +215,32 @@ impl OpenCADStudio {
}
}
/// Whether `cmd` makes sense on the Start (welcome) tab — document lifecycle,
/// links, and app-wide configuration; nothing that reads the scene. Single
/// source of truth: the dispatch gate refuses everything else, and the ribbon
/// dims the tools this rejects.
pub fn start_allowed(cmd: &str) -> bool {
matches!(
cmd,
"NEW"
| "OPEN"
| "EXIT"
| "QUIT"
| "REPORT"
| "CHANGELOG"
| "ABOUT"
| "PLUGINS"
| "PLUGINMANAGER"
| "DONATE"
| "WEBVERSION"
| "HELP"
| "CUI"
| "ALIASEDIT"
| "CUILOAD"
| "CUIIMPORT"
)
}
// ── Autocomplete registry — one-shot commands ──────────────────────────────
// These commands dispatch a single action (file ops, view, layer/style
// managers, undo/redo, …) rather than installing an interactive `CadCommand`,