summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2024-09-24 21:59:41 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-24 21:59:41 +0200
commit142aba2f172c2df2572f6f5b19cdf8b2d565905a (patch)
tree70026cbed3c35693c38d09df02813afb4125df39 /core
parent88a2fac1f9171f162ecfe2a033cba5ae62e23231 (diff)
parent1383c6a4f700ff246148c913000e9b9368ea9afc (diff)
downloadiced-142aba2f172c2df2572f6f5b19cdf8b2d565905a.tar.gz
iced-142aba2f172c2df2572f6f5b19cdf8b2d565905a.tar.bz2
iced-142aba2f172c2df2572f6f5b19cdf8b2d565905a.zip
Merge pull request #2598 from iced-rs/fix/shrink-cross-flex-layout
Fix flex layout of `Fill` elements in a `Shrink` cross axis
Diffstat (limited to 'core')
-rw-r--r--core/src/layout/flex.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/src/layout/flex.rs b/core/src/layout/flex.rs
index dcb4d8de..ac80d393 100644
--- a/core/src/layout/flex.rs
+++ b/core/src/layout/flex.rs
@@ -79,10 +79,10 @@ where
let max_cross = axis.cross(limits.max());
let mut fill_main_sum = 0;
- let mut cross = match axis {
- Axis::Vertical if width == Length::Shrink => 0.0,
- Axis::Horizontal if height == Length::Shrink => 0.0,
- _ => max_cross,
+ let (mut cross, cross_compress) = match axis {
+ Axis::Vertical if width == Length::Shrink => (0.0, true),
+ Axis::Horizontal if height == Length::Shrink => (0.0, true),
+ _ => (max_cross, false),
};
let mut available = axis.main(limits.max()) - total_spacing;
@@ -97,7 +97,8 @@ where
axis.pack(size.width.fill_factor(), size.height.fill_factor())
};
- if fill_main_factor == 0 {
+ if fill_main_factor == 0 && (!cross_compress || fill_cross_factor == 0)
+ {
let (max_width, max_height) = axis.pack(
available,
if fill_cross_factor == 0 {
@@ -141,7 +142,7 @@ where
axis.pack(size.width.fill_factor(), size.height.fill_factor())
};
- if fill_main_factor != 0 {
+ if fill_main_factor != 0 || (cross_compress && fill_cross_factor != 0) {
let max_main =
remaining * fill_main_factor as f32 / fill_main_sum as f32;