From d1bf3f02c7161e35e40f89fd0a6b3da9834a1616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 10 Jan 2020 04:58:13 +0100 Subject: [PATCH] Fix flex layout cross-alignment when not filled --- native/src/layout/flex.rs | 2 +- native/src/layout/limits.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/native/src/layout/flex.rs b/native/src/layout/flex.rs index 03b13e38..bd37b75a 100644 --- a/native/src/layout/flex.rs +++ b/native/src/layout/flex.rs @@ -77,7 +77,7 @@ where let max_cross = axis.cross(limits.max()); let mut fill_sum = 0; - let mut cross = axis.cross(limits.min()); + let mut cross = axis.cross(limits.min()).max(axis.cross(limits.fill())); let mut available = axis.main(limits.max()) - total_spacing; let mut nodes: Vec = Vec::with_capacity(items.len()); diff --git a/native/src/layout/limits.rs b/native/src/layout/limits.rs index a35f7ff7..b674b58a 100644 --- a/native/src/layout/limits.rs +++ b/native/src/layout/limits.rs @@ -44,6 +44,14 @@ impl Limits { self.max } + /// Returns the fill [`Size`] of the [`Limits`]. + /// + /// [`Limits`]: struct.Limits.html + /// [`Size`]: ../struct.Size.html + pub fn fill(&self) -> Size { + self.fill + } + /// Applies a width constraint to the current [`Limits`]. /// /// [`Limits`]: struct.Limits.html