Say narrow_rel_base, and let a container pass None for it

`narrow` said what the argument did to a value it never named, so a reader
had to go and find out which value. It is `narrow_rel_base`, and the
resolved one stays the bare `rel_base` -- which is also the only one in
`Painter`, `Placing` and `LayoutHolds`, where there is nothing to tell it
apart from.

It takes `impl Into<Option<[Option<Len>; 2]>>`, so a container that does not
narrow anything writes `None` rather than `[None; 2]`, and `Span` builds the
one case that does with a `then` instead of a mutable array.

Cold layout is byte-identical to `84dad21`.
This commit is contained in:
iris-ai committed 2026-09-19 16:55:48 -04:00
1 parent aeb60e50f5
commit beb138632a
8 files changed
+55 -49

No files matched your search

+3 -3
View File
@@ -120,7 +120,7 @@ impl Widget for Branch {
let cut = Len::from_parts(Rel::ZERO, Px::from_int(40));
let top = Place::Within(Part::From(UiSpan::new(Len::ZERO, cut)));
let measured = painter
.widget_at(&self.probe, [None; 2], [Place::Within(Part::WHOLE), top])
.widget_at(&self.probe, None, [Place::Within(Part::WHOLE), top])
.len(Axis::X);
let len = measured.apply_leftover();
let px = painter.to_px(len, Axis::X);
@@ -137,8 +137,8 @@ impl Widget for Branch {
let below = Place::Within(Part::From(UiSpan::new(cut, painter.region_len(Axis::Y))));
let place = [Place::Within(Part::WHOLE), below];
match px > threshold {
true => painter.widget_at(&self.wide, [None; 2], place),
false => painter.widget_at(&self.narrow, [None; 2], place),
true => painter.widget_at(&self.wide, None, place),
false => painter.widget_at(&self.narrow, None, place),
};
Size::LEFTOVER
}
+2 -2
View File
@@ -14,7 +14,7 @@ impl Widget for Scroll {
let container_len = painter.px_len(self.axis);
// Asked in the whole viewport, then put at the scrolled offset.
let answer_len = painter
.widget_at(&self.inner, [None; 2], [Place::Fill(Part::WHOLE); 2])
.widget_at(&self.inner, None, [Place::Fill(Part::WHOLE); 2])
.len(self.axis);
let fixed = painter.to_px(Len::from_parts(answer_len.rel, answer_len.px), self.axis);
self.container_len = container_len;
@@ -64,7 +64,7 @@ impl Widget for Scroll {
// box, scrolled: its drawing moved there, not made again there.
painter.place_at(
&self.inner,
[None; 2],
None,
self.axis
.pair(Place::Fill(content), Place::Fill(Part::WHOLE)),
);
+3 -5
View File
@@ -36,7 +36,7 @@ impl Widget for Span {
None => {
let room = Place::Within(Part::From(along(cursor, far)));
painter
.widget_at(child, [None; 2], axis.pair(room, across))
.widget_at(child, None, axis.pair(room, across))
.len(axis)
}
};
@@ -121,10 +121,8 @@ impl Widget for Span {
// room is put there as it is, and one not made yet is made here.
let slot = along(from, start);
let place = axis.pair(Place::Fill(Part::From(slot)), across);
let mut narrow = [None; 2];
if len.leftover > Weight::ZERO && shares {
narrow[axis as usize] = Some(slot.len());
}
let narrow =
(len.leftover > Weight::ZERO && shares).then(|| axis.pair(Some(slot.len()), None));
let used = painter.place_at(child, narrow, place).len(!axis);
if shrinks {
// Choosing between a fixed and a relative length from the
+2 -2
View File
@@ -23,7 +23,7 @@ impl Widget for Stack {
Some((i, child)) => {
painter.child_layer_at(i);
painter
.widget_at(child, [None; 2], [Place::Fill(Part::WHOLE); 2])
.widget_at(child, None, [Place::Fill(Part::WHOLE); 2])
.size()
}
None => Size::LEFTOVER,
@@ -45,7 +45,7 @@ impl Widget for Stack {
continue;
}
painter.child_layer_at(i);
painter.widget_at(child, [None; 2], place);
painter.widget_at(child, None, place);
}
size
}