Add explicit orthogonal span sizing

This commit is contained in:
iris-ai committed 2026-09-15 16:40:09 -04:00
1 parent 29c7881c8a
commit f437495309
7 files changed
+108 -8

No files matched your search

+33 -1
View File
@@ -20,6 +20,33 @@ fn a_span_gives_each_child_the_width_it_asked_for() {
assert_corners!(h, right, (100, 0), (400, 200));
}
#[test]
fn a_full_ortho_span_reports_relative_full() {
let mut h = Harness::new((400, 200));
let child = rect(Color::RED).height(40).add(&mut h.rsc);
let span = (child,)
.span(Dir::RIGHT)
.ortho(OrthoSize::Full)
.add(&mut h.rsc);
h.set_root(span);
assert_eq!(h.render.active[&span.id()].size.y, Len::rel(1.0));
}
#[test]
fn a_children_ortho_span_reports_its_tallest_fixed_child() {
let mut h = Harness::new((400, 200));
let short = rect(Color::RED).height(40).add(&mut h.rsc);
let tall = rect(Color::BLUE).height(70).add(&mut h.rsc);
let span = (short, tall)
.span(Dir::RIGHT)
.ortho(OrthoSize::Children)
.add(&mut h.rsc);
h.set_root(span);
assert_eq!(h.render.active[&span.id()].size.y, Len::px(70.0));
}
#[test]
fn resizing_relays_out_against_the_new_output() {
let mut h = Harness::new((400, 200));
@@ -158,7 +185,12 @@ fn a_box_with_a_fixed_length_can_be_stretched_on_its_other_axis() {
let inner = rect(Color::BLUE).add(&mut h.rsc);
let row = inner.pad(10).height(40).add(&mut h.rsc);
let filler = rect(Color::GREEN).add(&mut h.rsc);
let column = (row, filler).span(Dir::DOWN).add(&mut h.rsc);
// This column is an item in a row, so it takes the width left for it
// rather than asking for a full row-width in addition to the bar.
let column = (row, filler)
.span(Dir::DOWN)
.ortho(OrthoSize::Children)
.add(&mut h.rsc);
let bar = rect(Color::RED).width(100).add(&mut h.rsc);
h.set_root((bar, column).span(Dir::RIGHT));
assert_corners!(h, inner, (110, 10), (390, 30));