Put place before the rel base, and say what a Place decides
An argument that is usually `None` goes last. So `widget_at` and `place_at` take the place first, and `narrow_rel_base` after it. `Place` and `Part` also now say which of the two boxes they decide, since that is the question a caller has to answer to pick between them: `Part` is the child's region, said as a part of the caller's own, and `Within`/`Fill` is what becomes of the placement in it.
This commit is contained in:
1 parent
beb138632a
commit
c55be21761
8 files changed
+41
-38
No files matched your search
+3
-3
@@ -120,7 +120,7 @@ impl Widget for Branch {
|
||||
let cut = Len::from_parts(Rel::ZERO, Px::from_int(40));
|
||||
let top = Place::Within(Part::From(UiSpan::new(Len::ZERO, cut)));
|
||||
let measured = painter
|
||||
.widget_at(&self.probe, None, [Place::Within(Part::WHOLE), top])
|
||||
.widget_at(&self.probe, [Place::Within(Part::WHOLE), top], None)
|
||||
.len(Axis::X);
|
||||
let len = measured.apply_leftover();
|
||||
let px = painter.to_px(len, Axis::X);
|
||||
@@ -137,8 +137,8 @@ impl Widget for Branch {
|
||||
let below = Place::Within(Part::From(UiSpan::new(cut, painter.region_len(Axis::Y))));
|
||||
let place = [Place::Within(Part::WHOLE), below];
|
||||
match px > threshold {
|
||||
true => painter.widget_at(&self.wide, None, place),
|
||||
false => painter.widget_at(&self.narrow, None, place),
|
||||
true => painter.widget_at(&self.wide, place, None),
|
||||
false => painter.widget_at(&self.narrow, place, None),
|
||||
};
|
||||
Size::LEFTOVER
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl Widget for Scroll {
|
||||
let container_len = painter.px_len(self.axis);
|
||||
// Asked in the whole viewport, then put at the scrolled offset.
|
||||
let answer_len = painter
|
||||
.widget_at(&self.inner, None, [Place::Fill(Part::WHOLE); 2])
|
||||
.widget_at(&self.inner, [Place::Fill(Part::WHOLE); 2], None)
|
||||
.len(self.axis);
|
||||
let fixed = painter.to_px(Len::from_parts(answer_len.rel, answer_len.px), self.axis);
|
||||
self.container_len = container_len;
|
||||
@@ -64,9 +64,9 @@ impl Widget for Scroll {
|
||||
// box, scrolled: its drawing moved there, not made again there.
|
||||
painter.place_at(
|
||||
&self.inner,
|
||||
None,
|
||||
self.axis
|
||||
.pair(Place::Fill(content), Place::Fill(Part::WHOLE)),
|
||||
None,
|
||||
);
|
||||
// What it occupies is its box, on both axes: it clips its content to
|
||||
// that box, so it can neither take less of one nor honestly ask for
|
||||
|
||||
@@ -36,7 +36,7 @@ impl Widget for Span {
|
||||
None => {
|
||||
let room = Place::Within(Part::From(along(cursor, far)));
|
||||
painter
|
||||
.widget_at(child, None, axis.pair(room, across))
|
||||
.widget_at(child, axis.pair(room, across), None)
|
||||
.len(axis)
|
||||
}
|
||||
};
|
||||
@@ -123,7 +123,7 @@ impl Widget for Span {
|
||||
let place = axis.pair(Place::Fill(Part::From(slot)), across);
|
||||
let narrow =
|
||||
(len.leftover > Weight::ZERO && shares).then(|| axis.pair(Some(slot.len()), None));
|
||||
let used = painter.place_at(child, narrow, place).len(!axis);
|
||||
let used = painter.place_at(child, place, narrow).len(!axis);
|
||||
if shrinks {
|
||||
// Choosing between a fixed and a relative length from the
|
||||
// span's own eventual width admits multiple fixed points.
|
||||
|
||||
@@ -23,7 +23,7 @@ impl Widget for Stack {
|
||||
Some((i, child)) => {
|
||||
painter.child_layer_at(i);
|
||||
painter
|
||||
.widget_at(child, None, [Place::Fill(Part::WHOLE); 2])
|
||||
.widget_at(child, [Place::Fill(Part::WHOLE); 2], None)
|
||||
.size()
|
||||
}
|
||||
None => Size::LEFTOVER,
|
||||
@@ -45,7 +45,7 @@ impl Widget for Stack {
|
||||
continue;
|
||||
}
|
||||
painter.child_layer_at(i);
|
||||
painter.widget_at(child, None, place);
|
||||
painter.widget_at(child, place, None);
|
||||
}
|
||||
size
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user