ui-contract: an unwrapped row reports its line in every alignment

A row that places its block at its end, centred or spread recorded its line but
reported it to no first-line target: it read the target from its block's Ui
after restoring that Ui's entry, which found none. It reports to its body's
target as a row placed from its start does, so it sits on an outer row's line
by its own line and a container takes it as its first line.
This commit is contained in:
aiongg committed 2026-11-27 01:09:30 +00:00
1 parent fdfcecf201
commit 8f65586076
2 files changed
+26 -3

No files matched your search

+3 -3
View File
@@ -2039,7 +2039,7 @@ fn run_spread_row<R>(ui: &mut Ui, env: &Env, at: &RowIn, mut body: impl FnMut(&m
let installed = Env::install_for(ui, row.clone());
let inner = run_spread(ui, &row, id, gap.x, rtl, &mut body);
Env::restore(&ctx, installed);
record_line(ui, sizing, id, shared, None);
record_line(ui, sizing, id, shared, env.first_line);
inner
});
inner
@@ -2061,7 +2061,7 @@ fn run_start_row<R>(ui: &mut Ui, env: &Env, at: &RowIn, mut body: impl FnMut(&mu
let installed = Env::install_for(ui, row.clone());
let inner = run_shrinking(ui, &row, id, &mut body);
Env::restore(&ctx, installed);
record_line(ui, sizing, id, shared, sweep.first_line);
record_line(ui, sizing, id, shared, env.first_line);
inner
})
}
@@ -2124,7 +2124,7 @@ fn run_row<R>(ui: &mut Ui, env: &Env, at: &RowIn, (wrap, align): (bool, RowAlign
}
Env::restore(&ctx, installed);
if !wrap {
record_line(ui, sizing, id, shared, None);
record_line(ui, sizing, id, shared, env.first_line);
}
inner
});
@@ -567,6 +567,29 @@ fn a_memoized_view_sits_on_the_rows_line() {
}
}
/// An unwrapped row in a row sits on the outer row's line by its own line, whatever its alignment: a row that places
/// its block from its start, at its end, centred or spread reports its line as its first line alike.
#[trial]
fn an_unwrapped_row_sits_on_the_outer_line_by_its_line_in_every_alignment() {
for align in [RowAlign::Start, RowAlign::SpaceBetween, RowAlign::Center, RowAlign::End] {
let seen = Rc::new(Cell::new((Rect::NOTHING, Rect::NOTHING)));
let shown = Rc::clone(&seen);
let mut fixture = Fixture::new(move |ui| {
Panel::new().layout(BodyLayout::row()).id_salt("outer").show(ui, |ui, _| {
let tall = Block::new(Vec2::new(20.0, 30.0)).show(ui).rect;
let short = Panel::new().layout(BodyLayout::row().align(align)).id_salt("inner").show(ui, |ui, _| Block::new(ITEM).show(ui).rect);
if !is_measuring(ui.ctx()) {
shown.set((tall, short.inner.unwrap_or(Rect::NOTHING)));
}
});
});
fixture.room(Vec2::splat(400.0)).settle();
let (tall, short) = seen.get();
assert!(short.height() > 0.0, "{align:?}: the inner row showed its block: {short:?}");
assert!((short.center().y - tall.center().y).abs() < SLACK, "{align:?}: the inner row's block {short:?} is off the line of {tall:?}");
}
}
/// A Row in right-to-left holding a vertically scrolling container (content-sized, then filling its height) beside a
/// probe: the container, the probe inside it and the probe beside it are finite, and the container lies in the row.
#[trial]