Measure container children without intermediate placement
This commit is contained in:
1 parent
c330ecec2b
commit
7601aa2a5d
6 files changed
+81
-38
No files matched your search
+15
-10
@@ -193,7 +193,7 @@ impl UiRenderState {
|
||||
if let Some(id) = root {
|
||||
let region = Self::root_region(id.id(), rsc.widgets());
|
||||
let info = self.root_info(region);
|
||||
self.draw_inner(id.id(), region, info, None, rsc);
|
||||
self.draw_inner(id.id(), region, info, None, false, rsc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ impl UiRenderState {
|
||||
region: UiRegion,
|
||||
info: DrawInfo,
|
||||
mut old: Option<ActiveData>,
|
||||
measuring: bool,
|
||||
rsc: &mut dyn UiRsc,
|
||||
) -> (Size, LayoutHolds) {
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
@@ -239,16 +240,20 @@ impl UiRenderState {
|
||||
self.draw_at(id, region, info.offered_placement(), info, old.take(), rsc)
|
||||
});
|
||||
|
||||
let declared = declared_lens(rsc.widgets(), id);
|
||||
// Where the drawing goes, in the region's own coordinates: what the
|
||||
// parent chose, and on any axis it left open, what the answer took of
|
||||
// the region placed by the widget's alignment. The region itself does
|
||||
// not change, so nothing under it resolves a fraction a second time.
|
||||
let lens = placed_lens(answer.0, declared, info.decided());
|
||||
let own = placed_box(UiRegion::FULL, lens, align);
|
||||
let placement = UiRegion {
|
||||
x: info.placement[0].unwrap_or(own.x),
|
||||
y: info.placement[1].unwrap_or(own.y),
|
||||
let placement = if measuring {
|
||||
info.offered_placement()
|
||||
} else {
|
||||
let declared = declared_lens(rsc.widgets(), id);
|
||||
let lens = placed_lens(answer.0, declared, info.decided());
|
||||
let own = placed_box(UiRegion::FULL, lens, align);
|
||||
UiRegion {
|
||||
x: info.placement[0].unwrap_or(own.x),
|
||||
y: info.placement[1].unwrap_or(own.y),
|
||||
}
|
||||
};
|
||||
self.place(id, region, placement, info, rsc);
|
||||
|
||||
@@ -1137,7 +1142,7 @@ impl UiRenderState {
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
diag::bump(Counter::LocalRedraws);
|
||||
let old = self.remove(id, false, rsc);
|
||||
self.draw_inner(id, region, info, old, rsc);
|
||||
self.draw_inner(id, region, info, old, false, rsc);
|
||||
return true;
|
||||
};
|
||||
let (given_px, offered_px) = self.asked_px(id);
|
||||
@@ -1179,9 +1184,9 @@ impl UiRenderState {
|
||||
placement: info.offer_placement,
|
||||
..info
|
||||
};
|
||||
let answer = self.draw_inner(id, given, offered, old, rsc);
|
||||
let answer = self.draw_inner(id, given, offered, old, false, rsc);
|
||||
if info.placement != offered.placement {
|
||||
self.draw_inner(id, given, info, None, rsc);
|
||||
self.draw_inner(id, given, info, None, false, rsc);
|
||||
}
|
||||
if Some(answer) != was_answer {
|
||||
// Its parent chose its box knowing the old answer, so it lays out
|
||||
|
||||
Reference in new issue
Block a user