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 4f3b9e8594.
This commit is contained in:
aiongg
2026-11-19 01:56:16 +00:00
parent 4f3b9e8594
commit 43bf8e87bc
2 changed files with 17 additions and 22 deletions
+9 -18
View File
@@ -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<T, U>(self, ui: &mut Ui, add: impl FnOnce(&mut Ui) -> Option<T>, otherwise: impl FnOnce(&mut Ui) -> U) -> Option<Result<T, U>> {
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))
}
})
}
+8 -4
View File
@@ -980,10 +980,14 @@ impl<P: Clone + Eq + Hash + Debug + Send + Sync + 'static> 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))
},