summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-02-12 11:31:45 +0100
committerLaurenz <laurmaedje@gmail.com>2023-02-12 11:38:42 +0100
commite873468ea7deedd6d43f24100591c60a7de5accc (patch)
tree8150dadde1bf3f6c5a3faf52821df8588ad247d3 /library
parent03cbdea4b4dd81929743154ad79835bfbdf63db3 (diff)
Change grid base for auto columns
Diffstat (limited to 'library')
-rw-r--r--library/src/layout/grid.rs32
1 files changed, 10 insertions, 22 deletions
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs
index 60a5e748..46518f82 100644
--- a/library/src/layout/grid.rs
+++ b/library/src/layout/grid.rs
@@ -410,12 +410,10 @@ impl<'a, 'v> GridLayouter<'a, 'v> {
for y in 0..self.rows.len() {
if let Some(cell) = self.cell(x, y) {
let size = Size::new(available, self.regions.base.y);
- let mut pod =
- Regions::one(size, self.regions.base, Axes::splat(false));
+ let mut pod = Regions::one(size, size, Axes::splat(false));
// For relative rows, we can already resolve the correct
- // base, for auto it's already correct and for fr we could
- // only guess anyway.
+ // base and for auto and fr we could only guess anyway.
if let TrackSizing::Relative(v) = self.rows[y] {
pod.base.y =
v.resolve(self.styles).relative_to(self.regions.base.y);
@@ -488,15 +486,10 @@ impl<'a, 'v> GridLayouter<'a, 'v> {
// Determine the size for each region of the row.
for (x, &rcol) in self.rcols.iter().enumerate() {
if let Some(cell) = self.cell(x, y) {
- let mut pod = self.regions.clone();
+ let mut pod = self.regions;
pod.first.x = rcol;
pod.base.x = rcol;
- // All widths should be `rcol` except the base for auto columns.
- if self.cols[x] == TrackSizing::Auto {
- pod.base.x = self.regions.base.x;
- }
-
let mut sizes = cell
.layout(self.vt, self.styles, pod)?
.into_iter()
@@ -578,13 +571,13 @@ impl<'a, 'v> GridLayouter<'a, 'v> {
for (x, &rcol) in self.rcols.iter().enumerate() {
if let Some(cell) = self.cell(x, y) {
let size = Size::new(rcol, height);
-
- // Set the base to the region's base for auto rows and to the
- // size for relative and fractional rows.
- let base = Axes::new(self.cols[x], self.rows[y])
- .map(|s| s == TrackSizing::Auto)
- .select(self.regions.base, size);
-
+ let base = Size::new(
+ rcol,
+ match self.rows[y] {
+ TrackSizing::Auto => self.regions.base.y,
+ _ => height,
+ },
+ );
let pod = Regions::one(size, base, Axes::splat(true));
let frame = cell.layout(self.vt, self.styles, pod)?.into_frame();
output.push_frame(pos, frame);
@@ -616,11 +609,6 @@ impl<'a, 'v> GridLayouter<'a, 'v> {
pod.first.x = rcol;
pod.base.x = rcol;
- // All widths should be `rcol` except the base for auto columns.
- if self.cols[x] == TrackSizing::Auto {
- pod.base.x = self.regions.base.x;
- }
-
// Push the layouted frames into the individual output frames.
let fragment = cell.layout(self.vt, self.styles, pod)?;
for (output, frame) in outputs.iter_mut().zip(fragment) {