From 9a798ce6f6e734a02764473891632c071fed41ee Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 17 Aug 2021 00:17:28 +0200 Subject: Make percentages for h and v relative to area instead of font size --- src/layout/stack.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/layout/stack.rs') 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), } @@ -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; -- cgit v1.2.3