Menus: an interaction a dialog or the font menu begins reads the menus

CI failed `the_font_menu_preview_reads_the_menus_when_it_ends`: with the
state key holding the revision an interaction began from, the key no
longer changed when the font menu's preview began, so the menus were not
read then, though commands that check for an open interaction change
state at that point and the menu stays open while it previews.

The key now also holds whether an interaction that the active tool did
not begin is open. A tool's drag still keeps the key as it begins; a
dialog's, a panel's or the font menu's preview changes it as it begins
and as it ends. `Interaction::by_tool` reads the flag for the UI crate.
This commit is contained in:
dotCooCoo committed 2026-11-29 14:58:15 -08:00
1 parent 17b4758709
commit cb6703c0f1
2 files changed
+12 -2

No files matched your search

+7
View File
@@ -55,6 +55,13 @@ pub struct Interaction {
pub keep_on_switch: bool,
}
impl Interaction {
/// The active tool began it (a drag).
pub fn by_tool(&self) -> bool {
self.tool
}
}
/// An interaction that a command from outside the tool set aside while it runs
/// ([`crate::Session::outside_interaction`]).
#[derive(Debug)]
+5 -2
View File
@@ -90,7 +90,9 @@ pub(crate) fn translate_label(english: &'static str) -> String {
/// doesn't list (panels shown, a tool picked). While an
/// interaction is open (for example a move, scale or shape drag, a dialog's or the font menu's
/// preview, or a typing session), the hash takes the revision the interaction began from in place of the current one,
/// which each of its previews changes: the hash stays the same as the interaction begins, and changes as it ends.
/// which each of its previews changes, and changes as it ends. The hash stays the same as a tool's drag begins. An
/// interaction that a dialog, a panel or the font menu begins changes the hash as it begins, since commands that check
/// for an open interaction change state then and the menus stay open while it previews.
pub(crate) fn state_key(app: &VectorcraftApp, input: Option<u64>) -> u64 {
let mut h = DefaultHasher::new();
input.hash(&mut h);
@@ -102,7 +104,8 @@ pub(crate) fn state_key(app: &VectorcraftApp, input: Option<u64>) -> u64 {
(s.journal.len(), s.active_index(), s.clipboard.is_empty(), s.tool_composing()).hash(&mut h);
if let Some(d) = s.active() {
let revision = d.interaction.as_ref().map_or(d.revision, |it| it.revision);
(d.uid, revision, d.history.undo.len(), d.history.redo.len(), d.transparency_grid, d.print_tiling).hash(&mut h);
let previewing = d.interaction.as_ref().is_some_and(|it| !it.by_tool());
(d.uid, revision, previewing, d.history.undo.len(), d.history.redo.len(), d.transparency_grid, d.print_tiling).hash(&mut h);
}
(app.system_paste, app.last_effect.is_some(), app.ui.recent_files.len(), app.ui.recent_files.first(), app.recent_fonts().len()).hash(&mut h);
// Apply Last Filter and Last Filter… are named after the filter that ran last.