summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2022-07-19 18:34:39 +0200
committerLibravatar GitHub <noreply@github.com>2022-07-19 18:34:39 +0200
commit785385d889f02fc3805920b42ed8195a7f6a5672 (patch)
treef6e46210caf1ee9409f11cd97cad97b642d63bb3 /native
parent61fd5b0050724a6b05f2b959c546a58cb6073de3 (diff)
parentcdd3802e6858c81985849aca9d2daf733828ba29 (diff)
downloadiced-785385d889f02fc3805920b42ed8195a7f6a5672.tar.gz
iced-785385d889f02fc3805920b42ed8195a7f6a5672.tar.bz2
iced-785385d889f02fc3805920b42ed8195a7f6a5672.zip
Merge pull request #1390 from iced-rs/fix/container-layout
Fix `max_width` and `max_height` for `Container`
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/container.rs12
-rw-r--r--native/src/widget/scrollable.rs4
2 files changed, 14 insertions, 2 deletions
diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs
index 493aa67b..3d68a595 100644
--- a/native/src/widget/container.rs
+++ b/native/src/widget/container.rs
@@ -127,12 +127,20 @@ pub fn layout<Renderer>(
limits: &layout::Limits,
width: Length,
height: Length,
+ max_width: u32,
+ max_height: u32,
padding: Padding,
horizontal_alignment: alignment::Horizontal,
vertical_alignment: alignment::Vertical,
layout_content: impl FnOnce(&Renderer, &layout::Limits) -> layout::Node,
) -> layout::Node {
- let limits = limits.loose().width(width).height(height).pad(padding);
+ let limits = limits
+ .loose()
+ .max_width(max_width)
+ .max_height(max_height)
+ .width(width)
+ .height(height)
+ .pad(padding);
let mut content = layout_content(renderer, &limits.loose());
let size = limits.resolve(content.size());
@@ -171,6 +179,8 @@ where
limits,
self.width,
self.height,
+ self.max_width,
+ self.max_height,
self.padding,
self.horizontal_alignment,
self.vertical_alignment,
diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs
index 1b255860..77ed2066 100644
--- a/native/src/widget/scrollable.rs
+++ b/native/src/widget/scrollable.rs
@@ -162,9 +162,10 @@ pub fn layout<Renderer>(
limits: &layout::Limits,
width: Length,
height: Length,
+ max_height: u32,
layout_content: impl FnOnce(&Renderer, &layout::Limits) -> layout::Node,
) -> layout::Node {
- let limits = limits.width(width).height(height);
+ let limits = limits.max_height(max_height).width(width).height(height);
let child_limits = layout::Limits::new(
Size::new(limits.min().width, 0.0),
@@ -648,6 +649,7 @@ where
limits,
Widget::<Message, Renderer>::width(self),
self.height,
+ self.max_height,
|renderer, limits| self.content.layout(renderer, limits),
)
}