From 22226394f7b1a0e0205b9bb5b3ef9b85a3b406f5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 5 Jan 2024 17:24:43 +0100 Subject: Introduce `Widget::size_hint` and fix further layout inconsistencies --- widget/src/container.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'widget/src/container.rs') diff --git a/widget/src/container.rs b/widget/src/container.rs index b41a6023..fbc68db7 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -46,11 +46,22 @@ where where T: Into>, { + let content = content.into(); + let size = content.as_widget().size_hint(); + Container { id: None, padding: Padding::ZERO, - width: Length::Shrink, - height: Length::Shrink, + width: if size.width.is_fill() { + Length::Fill + } else { + Length::Shrink + }, + height: if size.height.is_fill() { + Length::Fill + } else { + Length::Shrink + }, max_width: f32::INFINITY, max_height: f32::INFINITY, horizontal_alignment: alignment::Horizontal::Left, -- cgit