WIP: a stack does not take its sizing child's fraction twice

Every child gets the whole of the stack's box rather than `box_of(size)`,
and `widget_at` does not resolve a rule into a box already chosen from it.
Fixes half a row becoming a quarter, which no oracle can see because warm
and cold shrink alike. Pinned by
`a_stack_sized_by_a_child_does_not_take_that_childs_fraction_twice`.

Not landed. Seed 1091 at depth 4, `shuffle-swap-for-three`, disagrees by
three steps of the grid -- warm 1053.9971 against cold 1054 -- where the
oracle tolerates two. Not a structural divergence: `box_of` was also making
a child's placement exact, by handing it a box of exactly the length it
asked for, and giving it the whole box instead puts a rounding back at each
nesting level. Two nested stacks is three steps. Widening AGREE_STEPS is
not the answer; finding the composition that went from exact to rounded is.

Everything else is green: suite, shrinker at 400 seeds of depth 5, oracle at
1000 seeds of depth 6, and the rest of 2000 seeds at depth 4.

Also carries examples/text.rs's top panel taking the full width.
This commit is contained in:
iris-ai committed 2026-09-17 04:50:00 -04:00
1 parent a92c6acdbf
commit a2cb4f05da
4 files changed
+66 -27

No files matched your search

+12 -10
View File
@@ -168,10 +168,20 @@ 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());
// A rule this box was already chosen from is not resolved into it a
// second time. The box is that rule's length already, so resolving
// it again takes the fraction twice -- a widget declaring half of a
// stack, in the stack its own answer made half a row, is a quarter
// of the row. Pixels survive it, being the same length wherever they
// are taken from, which is why only a share ever shrank.
let resolve = AXES.map(|axis| match decided[axis as usize] {
true => None,
false => declared[axis as usize],
});
// Composing `FULL` through a box is not quite the identity in f32,
// so a child with nothing declared keeps the box it would have had.
let local = match declared.iter().any(Option::is_some) {
true => declared_box(region, declared, align),
let local = match resolve.iter().any(Option::is_some) {
true => declared_box(region, resolve, align),
false => region,
};
let within = match local == UiRegion::FULL {
@@ -393,14 +403,6 @@ impl<'a> Painter<'a> {
.is_some()
}
/// The part of this widget's box that something of `size` takes, at the
/// near edge. A container that reports one child's size gives every child
/// this, so what it draws is inside what it says it occupies.
pub fn box_of(&self, size: Size) -> UiRegion {
let lens = placed_lens(size, [None; 2], [false; 2]);
placed_box(UiRegion::FULL, lens, RegionAlign::NEAR)
}
/// This widget's box in pixels. Reading it makes the drawing one that
/// holds for this box only, until `holds` says how far it goes.
pub fn px_size(&mut self) -> PxVec2 {