fix(ribbon): clear blue tool state when its popup window closes (#40)

A ribbon tool that opens a popup window (LAYERS, PAGESETUP,
ABOUT, the style managers, …) marks itself blue via
\`activate_tool\` when the user clicks it, but nothing un-marked
the tool after the window was dismissed — \`OsWindowClosed\`
cleared the matching \`_window\` slot, the active-tool string
stayed put, and the button kept rendering as if the panel were
still open.

Add \`Ribbon::deactivate_tool_if(id)\` (clears only when the
active tool matches) and call it for every popup-window slot in
\`OsWindowClosed\`. Also clear inside the \`ToggleLayers\` close
branch — that path \`take()\`s \`layer_window\` to \`None\` before
\`OsWindowClosed\` fires, so the conditional in the
\`OsWindowClosed\` handler would miss the close otherwise.

Mapped IDs match the matching ribbon \`ToolDef.id\`s (LAYERS,
PAGESETUP, ABOUT) plus command names for the popups normally
opened via the command line (TEXTSTYLE, TABLESTYLE, MLSTYLE,
LAYOUTMANAGER / LAYOUTPANEL, PLOTSTYLE / STYLESMANAGER, DIMSTYLE,
SHORTCUTS / KEYBOARD) so a future ribbon tool with one of those
ids gets the same correct deactivate.

Closes #40
This commit is contained in:
Hakan Seven committed 2026-05-29 01:23:25 +03:00
1 parent e9bc923677
commit 8f9fe5226b
2 files changed
+34

No files matched your search

+9
View File
@@ -144,6 +144,15 @@ impl Ribbon {
pub fn deactivate_tool(&mut self) {
self.active_tool = None;
}
/// Clear `active_tool` only when it currently equals `id`. Used by the
/// window-close path to deactivate the tool that owned a popup window
/// without disturbing a different tool the user picked in the
/// meantime. See #40.
pub fn deactivate_tool_if(&mut self, id: &str) {
if self.active_tool.as_deref() == Some(id) {
self.active_tool = None;
}
}
pub fn set_wireframe(&mut self, w: bool) {
self.wireframe = w;
}