From 43bf8e87bcf7e837bd7743b6acd471b370fb6509 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 19 Nov 2026 01:56:16 +0000 Subject: [PATCH] Revert "Lazy::show_or: the first child takes room only when it shows, so a dock group's extent is the same run or replayed" This reverts commit 4f3b9e859419af8ca13dd98a733e9e8845424227. --- crates/ui-contract/src/contract/lazy.rs | 27 +++++++------------- crates/ui-patterns/src/patterns/dock/area.rs | 12 ++++++--- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/crates/ui-contract/src/contract/lazy.rs b/crates/ui-contract/src/contract/lazy.rs index ae12a755f..722af42b8 100644 --- a/crates/ui-contract/src/contract/lazy.rs +++ b/crates/ui-contract/src/contract/lazy.rs @@ -97,25 +97,16 @@ impl Lazy { } /// [`show`](Self::show) for a child that may leave its room to other content: `add` runs first and settles; when - /// it returns `None`, `otherwise` runs in the child's room and the run is not kept, so a settling child runs again - /// in the next pass rather than replay it. A dock group's host view is one: where the host leaves the group to the - /// dock, the dock's group shows in its place and settles by its own rules. `None` when the child did not run: it - /// replayed a run of `add`, or was out of view. - /// - /// `add` runs in a `Ui` of its own that takes room only when it shows, so `otherwise` takes the child's whole room - /// from its start, and the child's extent is the same whether `otherwise` runs or replays. + /// it returns `None`, `otherwise` runs in the same child `Ui` and the run is not kept, so a settling child runs + /// again in the next pass rather than replay it. A dock group's host view is one: where the host leaves the group + /// to the dock, the dock's group shows in its place and settles by its own rules. `None` when the child did not + /// run: it replayed a run of `add`, or was out of view. pub fn show_or(self, ui: &mut Ui, add: impl FnOnce(&mut Ui) -> Option, otherwise: impl FnOnce(&mut Ui) -> U) -> Option> { - self.run(ui, |ui, run| { - let mut own = alloc::child(ui, UiBuilder::new().max_rect(ui.max_rect()).layout(*ui.layout())); - match add(&mut own) { - Some(shown) => { - alloc::advance_past(ui, own.min_rect()); - Ok(shown) - } - None => { - run.unkept(ui.ctx()); - Err(otherwise(ui)) - } + self.run(ui, |ui, run| match add(ui) { + Some(shown) => Ok(shown), + None => { + run.unkept(ui.ctx()); + Err(otherwise(ui)) } }) } diff --git a/crates/ui-patterns/src/patterns/dock/area.rs b/crates/ui-patterns/src/patterns/dock/area.rs index c4604174a..902dda70e 100644 --- a/crates/ui-patterns/src/patterns/dock/area.rs +++ b/crates/ui-patterns/src/patterns/dock/area.rs @@ -980,10 +980,14 @@ impl Pass<'_, P> { view.show_or( ui, |ui| { - // The view draws in a `Ui` held to the group's rect, clipped to it: it lays out in the group's - // room, never in the room the area has left. - ui.shrink_clip_rect(rect); - let taken = panels.borrow_mut().group_view(members, active, ui, at, body); + // The view draws held to the group's rect and clipped to it: it lays out in the group's room, + // never in the room the area has left. + let taken = ui + .scope_builder(UiBuilder::new().max_rect(rect), |ui| { + ui.shrink_clip_rect(rect); + panels.borrow_mut().group_view(members, active, ui, at, body) + }) + .inner; // The run covers the group, so the pointer over it runs the view again. taken.map(|_| ui.expand_to_include_rect(rect)) },