diff options
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/par.rs | 5 | ||||
| -rw-r--r-- | src/layout/stack.rs | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/layout/par.rs b/src/layout/par.rs index a88a0f0b..c8512243 100644 --- a/src/layout/par.rs +++ b/src/layout/par.rs @@ -27,7 +27,7 @@ pub struct ParNode { #[cfg_attr(feature = "layout-cache", derive(Hash))] pub enum ParChild { /// Spacing between other nodes. - Spacing(Length), + Spacing(Linear), /// A run of text and how to align it in its line. Text(EcoString, Align, Rc<FontState>), /// Any child node and how to align it in its line. @@ -137,7 +137,8 @@ impl<'a> ParLayouter<'a> { for (range, child) in par.ranges().zip(&par.children) { match *child { ParChild::Spacing(amount) => { - items.push(ParItem::Spacing(amount)); + let resolved = amount.resolve(regions.current.width); + items.push(ParItem::Spacing(resolved)); ranges.push(range); } ParChild::Text(_, align, ref state) => { diff --git a/src/layout/stack.rs b/src/layout/stack.rs index 7f0f2b9d..504c64aa 100644 --- a/src/layout/stack.rs +++ b/src/layout/stack.rs @@ -24,7 +24,7 @@ pub struct StackNode { #[cfg_attr(feature = "layout-cache", derive(Hash))] pub enum StackChild { /// Spacing between other nodes. - Spacing(Length), + Spacing(Linear), /// Any child node and how to align it in the stack. Any(LayoutNode, Gen<Align>), } @@ -125,11 +125,15 @@ impl<'a> StackLayouter<'a> { } /// Add main-axis spacing into the current region. - fn space(&mut self, amount: Length) { + fn space(&mut self, amount: Linear) { + // Resolve the linear. + let full = self.full.get(self.main); + let resolved = amount.resolve(full); + // Cap the spacing to the remaining available space. This action does // not directly affect the constraints because of the cap. let remaining = self.regions.current.get_mut(self.main); - let capped = amount.min(*remaining); + let capped = resolved.min(*remaining); // Grow our size and shrink the available space in the region. self.used.main += capped; |
