Replace placement calls with region nodes
This commit is contained in:
1 parent
f437495309
commit
71c9c39523
23 files changed
+374
-170
No files matched your search
+28
-6
@@ -111,6 +111,28 @@ fn a_leaf_that_ignores_its_box_is_not_drawn_again_when_the_box_changes() {
|
||||
assert_corners!(h, second, (150, 0), (400, 200));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn moving_an_ordinary_subtree_remaps_its_mask() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
let (first, _) = counted(&mut h, Size::from((100, 200)), false);
|
||||
let inner = rect(Color::BLUE).add(&mut h.rsc);
|
||||
let masked = inner.masked().add(&mut h.rsc);
|
||||
h.set_root((first, masked).span(Dir::RIGHT));
|
||||
|
||||
h.rsc[first].size = Size::from((150, 200));
|
||||
h.frame();
|
||||
|
||||
let active = &h.render.active[&masked.id()];
|
||||
assert_eq!(
|
||||
h.rsc.ui().masks[active.mask.idx()].region,
|
||||
UiRegion::new(
|
||||
UiSpan::new(UiScalar::px(150.0), UiScalar::rel_max()),
|
||||
UiSpan::FULL,
|
||||
)
|
||||
);
|
||||
assert_corners!(h, inner, (150, 0), (400, 200));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_leaf_that_depends_on_its_box_is_drawn_again_when_the_box_changes() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
@@ -121,7 +143,7 @@ fn a_leaf_that_depends_on_its_box_is_drawn_again_when_the_box_changes() {
|
||||
h.frame();
|
||||
|
||||
// The preceding fixed child makes the remaining box this child's real
|
||||
// box, so measuring it also draws it in its final place.
|
||||
// box, so measuring it also draws it in its final box.
|
||||
assert_eq!(draws.get(), settled + 1);
|
||||
assert_corners!(h, second, (150, 0), (400, 200));
|
||||
}
|
||||
@@ -132,7 +154,7 @@ fn a_span_child_that_declares_its_length_is_drawn_once() {
|
||||
let (told, told_draws) = counted(&mut h, Size::from((100, 200)), false);
|
||||
let (asked, asked_draws) = counted(&mut h, Size::from((100, 200)), true);
|
||||
// The span takes one child's length from its hint and has to draw the
|
||||
// other to find out, so only the second is drawn before it is placed.
|
||||
// other to find out, so only the second is drawn before its final box.
|
||||
let hinted = told.width(100).add(&mut h.rsc);
|
||||
h.set_root((hinted, asked).span(Dir::RIGHT));
|
||||
|
||||
@@ -140,7 +162,7 @@ fn a_span_child_that_declares_its_length_is_drawn_once() {
|
||||
assert_eq!(
|
||||
asked_draws.get(),
|
||||
2,
|
||||
"drawn to be measured, then again to be placed"
|
||||
"drawn to be measured, then again in its final box"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -173,10 +195,10 @@ fn a_repaint_that_keeps_its_size_does_not_relay_out() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_placed_child_survives_the_next_frame() {
|
||||
fn a_span_child_survives_the_next_frame() {
|
||||
let mut h = Harness::new((400, 200));
|
||||
// Both children declare a length, so the span places them from their hints
|
||||
// rather than drawing them to find out.
|
||||
// Both children declare a length, so the span chooses their boxes from
|
||||
// hints rather than drawing them to find out.
|
||||
let top = rect(Color::RED).height(80).add(&mut h.rsc);
|
||||
let bottom = rect(Color::BLUE).height(120).add(&mut h.rsc);
|
||||
h.set_root((top, bottom).span(Dir::DOWN));
|
||||
|
||||
Reference in new issue
Block a user