diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-14 12:34:16 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-14 12:34:16 +0100 |
| commit | b9c0fd87d304942db315ca6fdbccddf233d045cd (patch) | |
| tree | ae8231ab2999d44fd67cdba120a336704c4a6242 /library/src/layout/stack.rs | |
| parent | cc9b52ddd4defa3894ee3a4b28e411fa0b0991ba (diff) | |
Fix grid sizing
Diffstat (limited to 'library/src/layout/stack.rs')
| -rw-r--r-- | library/src/layout/stack.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/library/src/layout/stack.rs b/library/src/layout/stack.rs index 1452a889..864b7b42 100644 --- a/library/src/layout/stack.rs +++ b/library/src/layout/stack.rs @@ -129,8 +129,8 @@ struct StackLayouter<'a> { styles: StyleChain<'a>, /// Whether the stack itself should expand to fill the region. expand: Axes<bool>, - /// The full size of the current region that was available at the start. - full: Size, + /// The initial size of the current region before we started subtracting. + initial: Size, /// The generic size used by the frames for the current region. used: Gen<Abs>, /// The sum of fractions in the current region. @@ -154,13 +154,11 @@ enum StackItem { impl<'a> StackLayouter<'a> { /// Create a new stack layouter. - fn new(dir: Dir, regions: Regions<'a>, styles: StyleChain<'a>) -> Self { + fn new(dir: Dir, mut regions: Regions<'a>, styles: StyleChain<'a>) -> Self { let axis = dir.axis(); let expand = regions.expand; - let full = regions.size; // Disable expansion along the block axis for children. - let mut regions = regions.clone(); regions.expand.set(axis, false); Self { @@ -169,7 +167,7 @@ impl<'a> StackLayouter<'a> { regions, styles, expand, - full, + initial: regions.size, used: Gen::zero(), fr: Fr::zero(), items: vec![], @@ -251,11 +249,13 @@ impl<'a> StackLayouter<'a> { fn finish_region(&mut self) { // Determine the size of the stack in this region dependening on whether // the region expands. - let used = self.used.to_axes(self.axis); - let mut size = self.expand.select(self.full, used); + let mut size = self + .expand + .select(self.initial, self.used.to_axes(self.axis)) + .min(self.initial); // Expand fully if there are fr spacings. - let full = self.full.get(self.axis); + let full = self.initial.get(self.axis); let remaining = full - self.used.main; if self.fr.get() > 0.0 && full.is_finite() { self.used.main = full; @@ -303,7 +303,7 @@ impl<'a> StackLayouter<'a> { // Advance to the next region. self.regions.next(); - self.full = self.regions.size; + self.initial = self.regions.size; self.used = Gen::zero(); self.fr = Fr::zero(); self.finished.push(output); |
