Make alignment a widget property
This commit is contained in:
1 parent
8220a78d4a
commit
d3b0ebf90c
21 files changed
+823
-300
No files matched your search
+15
-5
@@ -159,10 +159,15 @@ fn a_span_child_that_declares_its_length_is_drawn_once() {
|
||||
h.set_root((hinted, asked).span(Dir::RIGHT));
|
||||
|
||||
assert_eq!(told_draws.get(), 1);
|
||||
// Reading its box makes its drawing hold for the measuring box alone,
|
||||
// and it reports less than that box: so it is drawn again in the box its
|
||||
// answer places it in, and once more in the final box the span chooses.
|
||||
// A widget that says what it holds for, as text does, skips the middle
|
||||
// one.
|
||||
assert_eq!(
|
||||
asked_draws.get(),
|
||||
2,
|
||||
"drawn to be measured, then again in its final box"
|
||||
3,
|
||||
"drawn to be measured, in its placed box, then in its final box"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -256,6 +261,11 @@ impl Widget for ReadsBox {
|
||||
|
||||
/// Reads its box across one axis only, so its drawing holds for a taller
|
||||
/// box on its own and only a wider one is worth a draw.
|
||||
///
|
||||
/// Both of these report a quarter of what they read, without saying that the
|
||||
/// drawing holds there too, so each length they are asked at costs two draws:
|
||||
/// one to answer, and one in the quarter-sized box that answer places them
|
||||
/// in. The counts below are in those pairs.
|
||||
struct ReadsWidth {
|
||||
draws: Rc<Cell<usize>>,
|
||||
}
|
||||
@@ -336,7 +346,7 @@ fn a_resize_redraws_what_read_its_box() {
|
||||
h.resize((800, 100));
|
||||
h.frame();
|
||||
|
||||
assert_eq!(draws.get(), settled + 1);
|
||||
assert_eq!(draws.get(), settled + 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -356,7 +366,7 @@ fn a_resize_only_redraws_read_axes() {
|
||||
|
||||
h.resize((800, 300));
|
||||
h.frame();
|
||||
assert_eq!(draws.get(), settled + 1, "width changes its answer");
|
||||
assert_eq!(draws.get(), settled + 2, "width changes its answer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -378,7 +388,7 @@ fn subpixel_resize_changes_accumulate_from_the_last_layout() {
|
||||
|
||||
h.resize((400.06, 200.0));
|
||||
h.frame();
|
||||
assert_eq!(draws.get(), settled + 1);
|
||||
assert_eq!(draws.get(), settled + 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user