fix: autosize layout limits

This commit is contained in:
Ashley Wulber 2024-12-03 16:46:03 -05:00 committed by Ashley Wulber
parent b524ccb0a4
commit ff0ba4860c

View file

@ -112,23 +112,21 @@ where
&self, &self,
tree: &mut Tree, tree: &mut Tree,
renderer: &Renderer, renderer: &Renderer,
_limits: &layout::Limits, limits: &layout::Limits,
) -> layout::Node { ) -> layout::Node {
let mut limits = self.limits; let mut my_limits = self.limits;
let min = self.limits.min(); let min = limits.min();
let max = self.limits.max(); let max = limits.max();
if self.auto_width { if !self.auto_width {
limits.min_width(min.width); my_limits = limits.min_width(min.width).max_width(max.width);
limits.max_width(max.width);
} }
if self.auto_height { if !self.auto_height {
limits.min_height(min.height); my_limits = limits.min_height(min.height).max_height(max.height);
limits.max_height(max.height);
} }
let node = self let node = self
.content .content
.as_widget() .as_widget()
.layout(&mut tree.children[0], renderer, &self.limits); .layout(&mut tree.children[0], renderer, &my_limits);
let size = node.size(); let size = node.size();
layout::Node::with_children(size, vec![node]) layout::Node::with_children(size, vec![node])
} }