From 1862d90041acae42c7a24bfd753233a16b654531 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 15:06:23 -0800 Subject: [PATCH] Panels: drop the flyout dialog tracking now that popovers are children of their opener craft-libs 5270 makes a popup that a hosted dialog shows a child of the layer the dialog was opened from, when it is opened through WindowDialogs::with from inside that layer's body. The Gradient panel's stop popover opens that way from an icon column's flyout, so the flyout keeps it as its own: the focus moving into the popover and presses in it no longer collapse the flyout, and one press away closes both. panel_docking::show no longer notes the dialogs opened while a flyout is open or turns auto-collapse off while one of them shows. The flyout test also checks that a press away with the popover open closes the popover and the flyout together. --- crates/ui-egui/src/panel_docking.rs | 30 +---------------------- crates/ui-egui/src/panel_docking/tests.rs | 16 +++++++++++- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/crates/ui-egui/src/panel_docking.rs b/crates/ui-egui/src/panel_docking.rs index e5b0110b77..c7f3d1bfa5 100644 --- a/crates/ui-egui/src/panel_docking.rs +++ b/crates/ui-egui/src/panel_docking.rs @@ -21,7 +21,6 @@ use std::sync::Arc; use craft::behavior::{Axis, DockSide, IconId}; use craft::ui::buttons::IconButton; use craft::ui::contract::{Bind, BodyCx, PlainData, Props as _, Show as _, SizeLimits, Tracked}; -use craft::ui::dialog::DialogId; use craft::ui::docking::{ ColumnCards, DockCommands, DockConfig, DockEvent, DockGrid, DockPanels, DockScene, DockSizes, DockTo, DragUnit, FloatSpace, GroupAt, HidePanels, PanelKey, PanelSpec, PanelSpecs, actions as command_actions, move_actions, request_actions, @@ -74,9 +73,6 @@ pub(crate) struct Runtime { /// A panel just floated out of a tool rail, whose window takes over the held press on the next /// pass, with the pointer at this point inside it ([`continue_move`]). hand_over: Option<(String, egui::Vec2)>, - /// The dialogs a panel in the open flyout opened, by id and opening serial: while one is open, Auto-Collapse Iconic - /// Panels leaves the flyout open ([`show`]). - flyout_dialogs: Vec<(DialogId, u64)>, } /// `ui.docking`: the layout in use, the hidden panels, the open flyout, the focused panel, the @@ -1350,16 +1346,6 @@ fn raise(app: &VectorcraftApp, ctx: &egui::Context, panel: &str) { } } -/// The open dialogs of the main window, by id and opening serial: a dialog closed and opened again has a new serial. -fn open_dialogs(app: &VectorcraftApp) -> Vec<(DialogId, u64)> { - app.dialogs().map_or_else(Vec::new, |dialogs| { - dialogs.with(|host| { - let host = &*host; - host.stack().ids().filter_map(|id| Some((id, host.open_serial(id)?))).collect() - }) - }) -} - /// The floating window holding `panel` takes over the held primary press on the next pass, with the /// pointer at `grab` inside it: a panel floated out of a tool rail mid-drag follows the pointer and /// docks where the release lands. @@ -1385,15 +1371,7 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, keeps_tools: boo let presenting = app.ui.screen_mode >= 3; // Shift+Tab, from its key, a menu or automation, closes a panel popped out of the icon column. let mut flyout = flyout_before.clone().filter(|_| !keeps_tools); - let dialogs_before = open_dialogs(app); - if flyout_before.is_some() { - app.dock_rt.flyout_dialogs.retain(|dialog| dialogs_before.contains(dialog)); - } else { - app.dock_rt.flyout_dialogs.clear(); - } - // A dialog a panel of the flyout opened (the Gradient panel's stop popover) is a layer of the window's dialog host, - // outside the flyout's: while one is open, a press in it or the focus moving into it leaves the flyout open. - let auto_collapse = app.session.prefs.auto_collapse_icon_panels && app.dock_rt.flyout_dialogs.is_empty(); + let auto_collapse = app.session.prefs.auto_collapse_icon_panels; // The specs and rails leave the app for the pass, which lends the app to the panel bodies. let specs = std::mem::take(&mut app.dock_rt.specs); let rails = std::mem::take(&mut app.dock_rt.rails); @@ -1439,12 +1417,6 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui, keeps_tools: boo if app.ui.open_panel == flyout_before { app.ui.open_panel = flyout; } - if app.ui.open_panel.is_some() { - let opened: Vec<_> = open_dialogs(app).into_iter().filter(|dialog| !dialogs_before.contains(dialog)).collect(); - app.dock_rt.flyout_dialogs.extend(opened); - } else { - app.dock_rt.flyout_dialogs.clear(); - } if output.error.is_some() { Arc::make_mut(&mut app.ui.dock_workspace).replace(default_workspace(&[])); app.status(tl!("Invalid panel layout; restored the default dock").to_string()); diff --git a/crates/ui-egui/src/panel_docking/tests.rs b/crates/ui-egui/src/panel_docking/tests.rs index 4db88f1fc5..25fa80f924 100644 --- a/crates/ui-egui/src/panel_docking/tests.rs +++ b/crates/ui-egui/src/panel_docking/tests.rs @@ -1351,7 +1351,8 @@ fn a_tab_menus_stock_items_start_at_the_panel_items_check_column() { } /// With Auto-Collapse Iconic Panels on, the popover the Gradient panel's stop chip opens from the panel's flyout leaves -/// the flyout open while it shows; once it closes, a click away from the flyout still closes it. +/// the flyout open while it shows; once it closes, a click away from the flyout still closes it, and a press away from +/// both closes the popover and the flyout together. #[test] fn a_popover_opened_from_an_auto_collapsing_flyout_leaves_the_flyout_open() { let mut h = Harness::new(); @@ -1385,4 +1386,17 @@ fn a_popover_opened_from_an_auto_collapsing_flyout_leaves_the_flyout_open() { assert_eq!(h.app.ui.open_panel, flyout, "closing the popover leaves the flyout open"); h.click(h.canvas().center()); assert_eq!(h.app.ui.open_panel, None, "a click away from the flyout still closes it"); + + // With the popover open again, one press away from both closes the popover and the flyout. + h.app.run("window.panel", json!({"panel": "gradient"})).unwrap(); + h.frames(3); + assert_eq!(h.app.ui.open_panel, flyout, "the flyout opens again"); + h.click(chip.center()); + h.frames(3); + assert!(popover_open(&h), "the chip opens the stop popover again"); + assert_eq!(h.app.ui.open_panel, flyout, "the flyout stays open while the popover shows"); + h.click(h.canvas().center()); + h.frames(2); + assert!(!popover_open(&h), "a press away closes the popover"); + assert_eq!(h.app.ui.open_panel, None, "and the flyout with it"); }