mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 18:02:45 +00:00
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:
@@ -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))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user