Constrain offered boxes with independent widget size bounds

This commit is contained in:
iris-ai committed 2026-09-20 19:47:32 -04:00
1 parent 4cb6f6882a
commit 2ac0843cb2
18 files changed
+554 -379

No files matched your search

+7 -7
View File
@@ -35,16 +35,16 @@ static ALLOCATOR: Counting = Counting;
#[test]
fn unchanged_tree_reuses_layout_storage() {
for deferred in [false, true] {
for rule in [
SizeRule::FREE,
leftover(1).clamp(20, 80).into(),
SizeRule::clamp(20.into(), 80.into()),
] {
let mut h = Harness::new((600, 200));
let mut children: Vec<StrongWidget> = Vec::new();
for _ in 0..8 {
let a = rect(Color::RED).add(&mut h.rsc);
if deferred {
h.rsc
.widgets_mut()
.set_size_rule(a, Axis::X, leftover(1).clamp(20, 80).into());
}
h.rsc.widgets_mut().set_size_rule(a, Axis::X, rule.clone());
let row = (a, rect(Color::BLUE))
.span(Dir::RIGHT)
.add_strong(&mut h.rsc);
@@ -74,7 +74,7 @@ fn unchanged_tree_reuses_layout_storage() {
h.frame();
}
let allocations = COUNT.replace(None).unwrap();
println!("deferred={deferred}: {allocations} allocations over 100 resize frames");
println!("rule={rule:?}: {allocations} allocations over 100 resize frames");
assert_eq!(allocations, 0);
}
}