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

+11 -11
View File
@@ -33,7 +33,7 @@ pub(super) struct DrawInfo {
pub asked: [Place; 2],
/// A rel base the parent decided for it on each axis, as a length of the
/// window, which the widget's own declaration is a fraction of.
pub narrow: [Option<Len>; 2],
pub narrow_rel_base: [Option<Len>; 2],
/// Whether the parent already asked about this widget in this draw.
pub re_asked: bool,
/// The rel base in pixels, resolved once against the window.
@@ -133,7 +133,7 @@ impl UiRenderState {
}
}
/// The root is asked about in the output. Its own rules narrow both its
/// The root is asked about in the output. Its own rules narrow_rel_base both its
/// rel base and box; nothing above it chose a different one.
fn root_info(&self, rel_base: UiVec2, region: UiRegion) -> DrawInfo {
let px = rel_base.to_px(self.output_size);
@@ -148,7 +148,7 @@ impl UiRenderState {
region,
placed: [Place::Within(Part::WHOLE); 2],
asked: [Place::Within(Part::WHOLE); 2],
narrow: [None; 2],
narrow_rel_base: [None; 2],
re_asked: false,
px,
}
@@ -273,7 +273,7 @@ impl UiRenderState {
// and what of its own box it asked in. A local redraw asks the same
// question again from these.
active.rel_base = info.rel_base;
active.narrow = info.narrow;
active.narrow_rel_base = info.narrow_rel_base;
active.re_asked = info.re_asked;
active.answer = Some(answer);
active.asked = info.asked;
@@ -470,7 +470,7 @@ impl UiRenderState {
region: UiRegion::FULL,
placed: [Place::Within(Part::WHOLE); 2],
asked: [Place::Within(Part::WHOLE); 2],
narrow: [None; 2],
narrow_rel_base: [None; 2],
re_asked: false,
px,
},
@@ -484,7 +484,7 @@ impl UiRenderState {
id,
placement: region,
rel_base: info.rel_base,
narrow: info.narrow,
narrow_rel_base: info.narrow_rel_base,
placed: info.placed,
asked: info.asked,
region,
@@ -741,7 +741,7 @@ impl UiRenderState {
region,
placed: place,
asked: active.asked,
narrow: active.narrow,
narrow_rel_base: active.narrow_rel_base,
re_asked: active.re_asked,
px: rel_base.to_px(at.window),
};
@@ -757,7 +757,7 @@ impl UiRenderState {
at.region,
at.rel_base,
place,
active.narrow,
active.narrow_rel_base,
active.declared,
active.own_align,
)
@@ -886,7 +886,7 @@ impl UiRenderState {
id,
placement: UiRegion::FULL,
rel_base: UiVec2::FULL_SIZE,
narrow: [None; 2],
narrow_rel_base: [None; 2],
placed: [Place::Within(Part::WHOLE); 2],
asked: [Place::Within(Part::WHOLE); 2],
region: UiRegion::FULL,
@@ -1146,7 +1146,7 @@ impl UiRenderState {
region,
placed: active.asked,
asked: active.asked,
narrow: active.narrow,
narrow_rel_base: active.narrow_rel_base,
re_asked: false,
px: rel_base.to_px(self.output_size),
};
@@ -1171,7 +1171,7 @@ impl UiRenderState {
}
if active.answer != was_answer || active.holds != was_holds {
// The parent retains both the answer and the drawing's validity;
// even an unchanged size can narrow the range safe for a resize.
// even an unchanged size can narrow_rel_base the range safe for a resize.
#[cfg(feature = "layout-diagnostics")]
{
diag::bump(Counter::SizeChanges);