diff options
| author | Martin Haug <mhaug@live.de> | 2021-06-27 18:06:39 +0200 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2021-06-27 18:06:39 +0200 |
| commit | 9bd8b7ddac046f581dc750e148147901d08cb0f4 (patch) | |
| tree | 0e7a39d25fe2bcccc7625568548759b330b48008 /src/layout/stack.rs | |
| parent | 57bd3e23c79878d106ab8be17c71caca6c4f5a7c (diff) | |
Code review, new stack test
Diffstat (limited to 'src/layout/stack.rs')
| -rw-r--r-- | src/layout/stack.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 92a1337f..045a06e1 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -62,6 +62,8 @@ struct StackLayouter<'a> { ruler: Align, /// The constraints for the current region. constraints: Constraints, + /// Whether the last region can fit all the remaining content. + overflowing: bool, /// Offset, alignment and frame for all children that fit into the current /// region. The exact positions are not known yet. frames: Vec<(Length, Gen<Align>, Rc<Frame>)>, @@ -92,6 +94,7 @@ impl<'a> StackLayouter<'a> { full, used: Gen::zero(), ruler: Align::Start, + overflowing: false, frames: vec![], finished: vec![], } @@ -142,9 +145,12 @@ impl<'a> StackLayouter<'a> { } // Find a fitting region. - while !self.regions.current.get(self.main).fits(size.main) - && !self.regions.in_full_last() - { + while !self.regions.current.get(self.main).fits(size.main) { + if self.regions.in_full_last() { + self.overflowing = true; + break; + } + self.constraints .max .get_mut(self.main) @@ -203,6 +209,12 @@ impl<'a> StackLayouter<'a> { size = Size::new(width, width / aspect.into_inner()); } + if self.overflowing { + self.constraints.min.vertical = None; + self.constraints.max.vertical = None; + self.constraints.exact = self.full.to_spec().map(Some); + } + let mut output = Frame::new(size, size.height); let mut first = true; |
