Say which box a pin reaches the parent through, and derive the offer
The review pass over the two commits before it: - `LayoutHolds`'s comment said a pin does not compose into the parent. It does, where the box it pinned is the parent's own box, which is the one case where the parent's own length is what was pinned. - `DrawInfo::offer` was stored beside the two fields it is computed from. It is a method now, with the open question written where it is asked rather than only in the handoff. - `Painter::own` is `frame_own` beside `extent_own`, since a widget's own box is the extent and the frame is what it is a part of. - One expression for the length a rule gives a frame (`narrowed_by`) and one for what a widget answered (`ActiveData::measured`), each of which had two. - The counter said "the placement it was pinned to" for what is now a length; the deferral in `redraw` named the seeds that made it necessary before the last commit rather than the ones that do now; three comments claimed an inset that does not exist yet. No behaviour change: 108 suite tests, 20 core, the 11 generated cases, the same two shrinker seeds failing at 400/5, and `view` and `tabs` byte-identical to the renders taken before it.
This commit is contained in:
1 parent
0954770ceb
commit
49cec82c1b
6 files changed
+76
-70
No files matched your search
+25
-23
@@ -20,7 +20,7 @@ pub struct Painter<'a> {
|
||||
/// What a fraction this widget declares or reports is a fraction of, in
|
||||
/// the coordinates of `move_idx`: forwarded from its parent unchanged
|
||||
/// through a span, a stack or a scroll, and narrowed only by what was
|
||||
/// decided above it -- a declared length, an inset, the root. Its length
|
||||
/// decided above it -- a declared length, or the root. Its length
|
||||
/// is the same on every ask of the widget, which is what keeps a fraction
|
||||
/// under it from being resolved twice.
|
||||
pub(super) frame: UiRegion,
|
||||
@@ -55,8 +55,8 @@ pub struct Painter<'a> {
|
||||
pub(super) size_deps: Vec<WidgetId>,
|
||||
/// What this draw itself read of its frame in pixels, per axis: every
|
||||
/// length until it reads one, then that one, unless it says otherwise.
|
||||
pub(super) own: [Holds; 2],
|
||||
/// The same for its extent.
|
||||
pub(super) frame_own: [Holds; 2],
|
||||
/// The same for its own box.
|
||||
pub(super) extent_own: [Holds; 2],
|
||||
/// Dependencies of every child drawing, including unmeasured overlays.
|
||||
pub(super) under: LayoutHolds,
|
||||
@@ -161,8 +161,8 @@ impl<'a> Painter<'a> {
|
||||
/// [`UiRegion::FULL`] forwards this widget's frame, which is what a
|
||||
/// container that only divides room passes, so a fraction under it means
|
||||
/// the same wherever it sits and however deeply it is nested. Narrowing
|
||||
/// it is for what is decided from above -- an inset's margins -- and a
|
||||
/// declared length narrows it here.
|
||||
/// it is for what is decided from above, and a declared length narrows
|
||||
/// it here.
|
||||
///
|
||||
/// `place` is where the drawing goes, per axis, as a part of this
|
||||
/// widget's extent: see [`Place`]. A narrowed frame is its own extent,
|
||||
@@ -176,14 +176,12 @@ impl<'a> Painter<'a> {
|
||||
let region_node = self.rsc.widgets().is_region_node(id.id());
|
||||
let declared = self.declared_lens(id);
|
||||
let align = self.rsc.widgets().alignment(id.id());
|
||||
let narrow = AXES.map(|axis| {
|
||||
let n = axis as usize;
|
||||
// A rule's fraction is a fraction of the frame the child was
|
||||
// given, which is the one length the rule can mean.
|
||||
declared[n]
|
||||
.map(|len| Len::from_parts(len.rel, len.px).within_len(frame.axis(axis).len()))
|
||||
});
|
||||
let (local, extent) = frame_and_extent(frame, part_of(self.extent, place), narrow, align);
|
||||
let (local, extent) = frame_and_extent(
|
||||
frame,
|
||||
part_of(self.extent, place),
|
||||
narrowed_by(declared, frame),
|
||||
align,
|
||||
);
|
||||
let within = match local == UiRegion::FULL {
|
||||
true => self.frame,
|
||||
false => local.within(&self.frame),
|
||||
@@ -224,10 +222,6 @@ impl<'a> Painter<'a> {
|
||||
part: extent,
|
||||
place,
|
||||
offer_place,
|
||||
// The question its parent measured it by, asked again: the
|
||||
// same widget in the same place, however this draw came
|
||||
// about.
|
||||
offer: place == offer_place,
|
||||
px,
|
||||
},
|
||||
None,
|
||||
@@ -429,7 +423,7 @@ impl<'a> Painter<'a> {
|
||||
/// children. Its own box is a part of this one.
|
||||
pub fn frame_px_len(&mut self, axis: Axis) -> Px {
|
||||
let len = self.px.axis(axis);
|
||||
let own = &mut self.own[axis as usize];
|
||||
let own = &mut self.frame_own[axis as usize];
|
||||
if *own == Holds::ANY {
|
||||
*own = Holds::at(len);
|
||||
}
|
||||
@@ -447,7 +441,7 @@ impl<'a> Painter<'a> {
|
||||
self.label(),
|
||||
self.id
|
||||
);
|
||||
self.own[axis as usize] = holds;
|
||||
self.frame_own[axis as usize] = holds;
|
||||
}
|
||||
|
||||
pub fn text_data(&mut self) -> &mut TextData {
|
||||
@@ -663,10 +657,8 @@ pub(crate) fn placed_extent(
|
||||
placed
|
||||
}
|
||||
|
||||
/// The part of a widget's extent a `place` names, in the coordinates its
|
||||
/// extent is in: a span is measured in frame lengths from where the extent
|
||||
/// starts, so nothing under it depends on where that is, and an extent that
|
||||
/// moved re-places every child by re-adding its start.
|
||||
/// The part of a widget's own box a `place` names, in the coordinates that
|
||||
/// box is in.
|
||||
pub(crate) fn part_of(extent: UiRegion, place: [Place; 2]) -> UiRegion {
|
||||
let mut part = extent;
|
||||
for axis in AXES {
|
||||
@@ -675,6 +667,16 @@ pub(crate) fn part_of(extent: UiRegion, place: [Place; 2]) -> UiRegion {
|
||||
part
|
||||
}
|
||||
|
||||
/// The length a rule gives a child's frame, per axis: a fraction in it is a
|
||||
/// fraction of the frame the child was given, which is the one length the
|
||||
/// rule can mean.
|
||||
pub(crate) fn narrowed_by(declared: [Option<LayoutLen>; 2], frame: UiRegion) -> [Option<Len>; 2] {
|
||||
AXES.map(|axis| {
|
||||
declared[axis as usize]
|
||||
.map(|len| Len::from_parts(len.rel, len.px).within_len(frame.axis(axis).len()))
|
||||
})
|
||||
}
|
||||
|
||||
/// The frame a child is asked in and the box its drawing goes in, both in
|
||||
/// the coordinates of the widget asking.
|
||||
///
|
||||
|
||||
Reference in new issue
Block a user