diff --git a/crates/ui-panels/src/docking/flyout.rs b/crates/ui-panels/src/docking/flyout.rs index 89a735604..65fcb0095 100644 --- a/crates/ui-panels/src/docking/flyout.rs +++ b/crates/ui-panels/src/docking/flyout.rs @@ -111,10 +111,10 @@ impl Flyout { if bounded { overlay.bounds(self.within) } else { overlay } } - /// Shows the flyout of `popup` while it is open, its top left at `anchor` (a point, or a rect's top left), and - /// returns what it showed; `None` while it is closed. `body` returns the height it measures for + /// Shows the flyout as the layer of `popup` while it is open, its top left at `anchor` (a point, or a rect's top + /// left), and returns what it showed; `None` while it is closed. `body` returns the height it measures for /// `GroupAt::Measure`, or `None` to take the flyout's own height. - pub fn show( + pub fn show_popup( mut self, ui: &mut OverlayUi<'_>, popup: PopupHandle, diff --git a/crates/ui-panels/src/docking/iconic.rs b/crates/ui-panels/src/docking/iconic.rs index 38c3e0d32..39bf60718 100644 --- a/crates/ui-panels/src/docking/iconic.rs +++ b/crates/ui-panels/src/docking/iconic.rs @@ -553,7 +553,7 @@ impl Component for IconicColumn<'_, P> { let mut resized = None; for (at, plan) in plans.into_iter().enumerate() { let Some(FlyoutPlan { group, top_left, size, fixed, icons_top }) = plan else { continue }; - let shown = Flyout::new(edge, size, auto_collapse).within(bounds).least(least).show( + let shown = Flyout::new(edge, size, auto_collapse).within(bounds).least(least).show_popup( ui, popup.at(at), Anchor::Point(top_left), diff --git a/crates/ui-panels/src/docking/panels.rs b/crates/ui-panels/src/docking/panels.rs index 0c5f72e66..a403a80ef 100644 --- a/crates/ui-panels/src/docking/panels.rs +++ b/crates/ui-panels/src/docking/panels.rs @@ -4,6 +4,7 @@ use super::flyout::GroupAt; use super::spec::PanelSpec; use crate::contract::BodyCx; use crate::menu::PanelRow; +use crate::runtime::memory; use craft_behavior::dock::{Action, Permissions}; use egui::{Context, Id, Ui}; @@ -54,7 +55,7 @@ pub trait DockPanels

{ type Running

= Vec>>; fn running_id() -> Id { - Id::unique("dock area requests") + memory::unique("dock area requests") } /// Hands `actions` to the dock area over panels `P` whose pass is running on `ctx`: a panel body, or code a body @@ -64,33 +65,23 @@ fn running_id() -> Id { /// /// With no such pass running, the actions come back for the caller to apply. pub fn request_actions(ctx: &Context, actions: Vec>) -> Result<(), Vec>> { - ctx.data_mut(|data| { - let running = data.get_temp_mut_or_default::>(running_id()); - if let Some(open) = running.last_mut() { + memory::with_session(ctx, running_id(), |running: &mut Running

| match running.last_mut() { + Some(open) => { open.extend(actions); - return Ok(()); + Ok(()) } - data.remove::>(running_id()); - Err(actions) + None => Err(actions), }) } /// Opens the request list of a dock area's pass on `ctx`. The area calls it before its bodies run. #[doc(hidden)] pub fn open_requests(ctx: &Context) { - ctx.data_mut(|data| data.get_temp_mut_or_default::>(running_id()).push(Vec::new())); + memory::with_session(ctx, running_id(), |running: &mut Running

| running.push(Vec::new())); } -/// Closes the innermost request list on `ctx` and returns what it took. The area calls it when its bodies have run; -/// the last close leaves nothing in the context. +/// Closes the innermost request list on `ctx` and returns what it took. The area calls it when its bodies have run. #[doc(hidden)] pub fn close_requests(ctx: &Context) -> Vec> { - ctx.data_mut(|data| { - let running = data.get_temp_mut_or_default::>(running_id()); - let requested = running.pop().unwrap_or_default(); - if running.is_empty() { - data.remove::>(running_id()); - } - requested - }) + memory::with_session(ctx, running_id(), |running: &mut Running

| running.pop().unwrap_or_default()) }