Honor fixed child alignment inside parent-selected slots
This commit is contained in:
1 parent
2ed5503717
commit
39f7b08c6c
2 files changed
+26
-14
No files matched your search
+5
-14
@@ -712,16 +712,9 @@ pub(crate) fn placed_box(region: UiRegion, lens: UiVec2, align: RegionAlign) ->
|
||||
placed
|
||||
}
|
||||
|
||||
/// A child's own region and where in it its drawing goes, from the box it is
|
||||
/// offered, the lengths its rules declare, and what its parent chose.
|
||||
///
|
||||
/// A rule gives the region its length outright -- that is what makes a rule
|
||||
/// win, and it is why a widget under one never learns of it -- and the region
|
||||
/// then sits where its parent placed it, or where its alignment says if its
|
||||
/// parent left the axis open. With no rule the region is the whole of what
|
||||
/// was offered, since that is the area a fraction under it is a fraction of,
|
||||
/// and what the parent chose is where in it the drawing goes. So the two
|
||||
/// coordinate spaces are the same one wherever a placement survives.
|
||||
/// A declared axis gets a frame of that length, aligned within the parent's
|
||||
/// slot (or the offer). Undeclared axes keep the offered frame and chosen
|
||||
/// placement, so their reported fractions retain that reference.
|
||||
pub(crate) fn ask_box(
|
||||
mut region: UiRegion,
|
||||
declared: [Option<LayoutLen>; 2],
|
||||
@@ -736,10 +729,8 @@ pub(crate) fn ask_box(
|
||||
};
|
||||
let span = region.axis_mut(axis);
|
||||
let len = Len::from_parts(len.rel, len.px);
|
||||
span.start = match chosen {
|
||||
Some(chosen) => chosen.start,
|
||||
None => span.start + (span.len() - len).scale(align.axis(axis).rel()),
|
||||
};
|
||||
let slot = chosen.unwrap_or(*span);
|
||||
span.start = slot.start + (slot.len() - len).scale(align.axis(axis).rel());
|
||||
span.end = span.start + len;
|
||||
}
|
||||
(region, placed)
|
||||
|
||||
Reference in new issue
Block a user