From ff0ba4860c9ba732e601485f1952fde5fe5f6952 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Tue, 3 Dec 2024 16:46:03 -0500 Subject: [PATCH] fix: autosize layout limits --- src/widget/autosize.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/widget/autosize.rs b/src/widget/autosize.rs index 8c65e5c..a792c6c 100644 --- a/src/widget/autosize.rs +++ b/src/widget/autosize.rs @@ -112,23 +112,21 @@ where &self, tree: &mut Tree, renderer: &Renderer, - _limits: &layout::Limits, + limits: &layout::Limits, ) -> layout::Node { - let mut limits = self.limits; - let min = self.limits.min(); - let max = self.limits.max(); - if self.auto_width { - limits.min_width(min.width); - limits.max_width(max.width); + let mut my_limits = self.limits; + let min = limits.min(); + let max = limits.max(); + if !self.auto_width { + my_limits = limits.min_width(min.width).max_width(max.width); } - if self.auto_height { - limits.min_height(min.height); - limits.max_height(max.height); + if !self.auto_height { + my_limits = limits.min_height(min.height).max_height(max.height); } let node = self .content .as_widget() - .layout(&mut tree.children[0], renderer, &self.limits); + .layout(&mut tree.children[0], renderer, &my_limits); let size = node.size(); layout::Node::with_children(size, vec![node]) }