From cc5ad1505c934e1df822098f0b4947f90e03d1c9 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 20 Mar 2021 22:21:14 +0100 Subject: [PATCH] Fix bug that would allocate the full width of non-centered layouts --- egui/src/layout.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/egui/src/layout.rs b/egui/src/layout.rs index 6dbff720..c4d737ea 100644 --- a/egui/src/layout.rs +++ b/egui/src/layout.rs @@ -482,10 +482,14 @@ impl Layout { let mut frame_size = child_size; - if self.is_vertical() || self.horizontal_justify() { + if (self.is_vertical() && self.horizontal_align() == Align::Center) + || self.horizontal_justify() + { frame_size.x = frame_size.x.at_least(available_rect.width()); // fill full width } - if self.is_horizontal() || self.vertical_justify() { + if (self.is_horizontal() && self.vertical_align() == Align::Center) + || self.vertical_justify() + { frame_size.y = frame_size.y.at_least(available_rect.height()); // fill full height }