Improve readability of Align::Fill branching

This commit is contained in:
Cory Forsstrom 2021-09-15 11:18:11 -07:00 committed by Héctor Ramón Jiménez
parent e89bbe8a79
commit 95e4791a1e
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -116,23 +116,17 @@ where
.fill_factor();
if fill_factor == 0 {
let (min_width, min_height) = axis.pack(
0.0,
if align_items == Align::Fill {
cross
} else {
0.0
},
);
let (min_width, min_height) = if align_items == Align::Fill {
axis.pack(0.0, cross)
} else {
axis.pack(0.0, 0.0)
};
let (max_width, max_height) = axis.pack(
available,
if align_items == Align::Fill {
cross
} else {
max_cross
},
);
let (max_width, max_height) = if align_items == Align::Fill {
axis.pack(available, cross)
} else {
axis.pack(available, max_cross)
};
let child_limits = Limits::new(
Size::new(min_width, min_height),
@ -171,27 +165,21 @@ where
max_main
};
let (min_main, min_cross) = axis.pack(
min_main,
if align_items == Align::Fill {
cross
} else {
axis.cross(limits.min())
},
);
let (min_width, min_height) = if align_items == Align::Fill {
axis.pack(min_main, cross)
} else {
axis.pack(min_main, axis.cross(limits.min()))
};
let (max_main, max_cross) = axis.pack(
max_main,
if align_items == Align::Fill {
cross
} else {
max_cross
},
);
let (max_width, max_height) = if align_items == Align::Fill {
axis.pack(max_main, cross)
} else {
axis.pack(max_main, max_cross)
};
let child_limits = Limits::new(
Size::new(min_main, min_cross),
Size::new(max_main, max_cross),
Size::new(min_width, min_height),
Size::new(max_width, max_height),
);
let layout = child.layout(renderer, &child_limits);