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