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:
iris-ai committed 2026-09-19 17:16:41 -04:00
1 parent beb138632a
commit c55be21761
8 files changed
+41 -38

No files matched your search

+12 -12
View File
@@ -169,30 +169,30 @@ impl<'a> Painter<'a> {
let len = region.axis(axis).len();
(len != Len::FULL).then(|| len.within_len(self.rel_base(axis)))
});
self.widget_at(id, narrow, region_places(region))
self.widget_at(id, region_places(region), narrow)
}
/// Asks a child, saying what its fractions are of and where it is asked.
///
/// `place` is the child's region, per axis, said as a part of this
/// widget's own: see [`Place`]. The child draws once, in that region,
/// and its answer is placed inside it by re-expressing the drawing.
/// Nothing is drawn again in a box an answer chose; a container that
/// puts the answer somewhere else says so with [`Self::place_at`].
///
/// `narrow_rel_base` is the child's rel base, per axis, as a length of
/// the window: a resolved share, or a box a sibling's answer decided.
/// `None`, whole or per axis, forwards this widget's own -- which is
/// what a container that only divides room passes, so a fraction under
/// it means the same wherever it sits and however deeply it is nested.
/// It only ever narrows: a length the child declares narrows it again
/// here whatever the caller says, and what comes of it is also the box
/// the child is asked in, placed in the part by the child's alignment.
///
/// `place` is where the child is asked, per axis, as a part of this
/// widget's box: see [`Place`]. The child draws once, in that box, and
/// its answer is placed inside it by re-expressing the drawing. Nothing
/// is drawn again in a box an answer chose; a container that puts the
/// answer somewhere else says so with [`Self::place_at`].
/// here whatever the caller says, and what comes of it also narrows the
/// region, placed in the part by the child's alignment.
pub fn widget_at<'s, W: ?Sized>(
&'s mut self,
id: &'s StrongWidget<W>,
narrow_rel_base: impl Into<Option<[Option<Len>; 2]>>,
place: [Place; 2],
narrow_rel_base: impl Into<Option<[Option<Len>; 2]>>,
) -> DrawResult<'s, 'a, W> {
let narrow_rel_base = narrow_rel_base.into().unwrap_or([None; 2]);
let region_node = self.rsc.widgets().is_region_node(id.id());
@@ -273,12 +273,12 @@ impl<'a> Painter<'a> {
pub fn place_at<'s, W: ?Sized>(
&'s mut self,
id: &'s StrongWidget<W>,
narrow_rel_base: impl Into<Option<[Option<Len>; 2]>>,
place: [Place; 2],
narrow_rel_base: impl Into<Option<[Option<Len>; 2]>>,
) -> DrawResult<'s, 'a, W> {
let narrow_rel_base = narrow_rel_base.into().unwrap_or([None; 2]);
if narrow_rel_base.iter().any(Option::is_some) || !self.children.contains(&id.id()) {
return self.widget_at(id, narrow_rel_base, place);
return self.widget_at(id, place, narrow_rel_base);
}
let at = self.placing();
self.state.place_in(id.id(), &at, place, self.rsc);