From 2c103f8654943c773b6de3c70eb2927e92219422 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Thu, 27 Oct 2022 11:48:42 -0700 Subject: Constrain padding to inner & outer sizes --- native/src/widget/container.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'native/src/widget/container.rs') diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 2afad3f2..cc886dcb 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -293,11 +293,13 @@ pub fn layout( .max_width(max_width) .max_height(max_height) .width(width) - .height(height) - .pad(padding); + .height(height); - let mut content = layout_content(renderer, &limits.loose()); - let size = limits.resolve(content.size()); + let mut content = layout_content(renderer, &limits.pad(padding).loose()); + + let padding = padding.constrain(content.size(), limits.max()); + + let size = limits.pad(padding).resolve(content.size()); content.move_to(Point::new(padding.left.into(), padding.top.into())); content.align( -- cgit From 7476663069572adec25161b46c26570f864f736f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 8 Nov 2022 03:56:05 +0100 Subject: Rename `Padding::constrain` to `fit` --- native/src/widget/container.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native/src/widget/container.rs') diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index cc886dcb..1c060375 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -297,7 +297,7 @@ pub fn layout( let mut content = layout_content(renderer, &limits.pad(padding).loose()); - let padding = padding.constrain(content.size(), limits.max()); + let padding = padding.fit(content.size(), limits.max()); let size = limits.pad(padding).resolve(content.size()); -- cgit From 914f0993428c752937d8db0a70a48f6f6f29c839 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 8 Nov 2022 04:04:01 +0100 Subject: Rearrange `layout` code to improve readability --- native/src/widget/container.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'native/src/widget/container.rs') diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 1c060375..10a80b58 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -296,9 +296,7 @@ pub fn layout( .height(height); let mut content = layout_content(renderer, &limits.pad(padding).loose()); - let padding = padding.fit(content.size(), limits.max()); - let size = limits.pad(padding).resolve(content.size()); content.move_to(Point::new(padding.left.into(), padding.top.into())); -- cgit From 18fb74f20092b2703a90afdb01f39754445998da Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 9 Nov 2022 04:05:31 +0100 Subject: Introduce `Custom` variants for every style in the built-in `Theme` --- native/src/widget/container.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native/src/widget/container.rs') diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 10a80b58..16537c50 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -228,7 +228,7 @@ where cursor_position: Point, viewport: &Rectangle, ) { - let style = theme.appearance(self.style); + let style = theme.appearance(&self.style); draw_background(renderer, &style, layout.bounds()); -- cgit From 1480ab20306e463b69b2229dcd5e81d4c66b2a64 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 10 Nov 2022 00:10:53 +0100 Subject: Fix broken documentation links --- native/src/widget/container.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native/src/widget/container.rs') diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 16537c50..9d3e4d9b 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -309,7 +309,7 @@ pub fn layout( layout::Node::with_children(size.pad(padding), vec![content]) } -/// Draws the background of a [`Container`] given its [`Style`] and its `bounds`. +/// Draws the background of a [`Container`] given its [`Appearance`] and its `bounds`. pub fn draw_background( renderer: &mut Renderer, appearance: &Appearance, -- cgit From f1ada7a803998ac3fb2c1bedc6d6650264f3e603 Mon Sep 17 00:00:00 2001 From: tarkah Date: Sat, 19 Nov 2022 12:25:59 -0800 Subject: Allow &mut self in overlay --- native/src/widget/container.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'native/src/widget/container.rs') diff --git a/native/src/widget/container.rs b/native/src/widget/container.rs index 9d3e4d9b..1c681091 100644 --- a/native/src/widget/container.rs +++ b/native/src/widget/container.rs @@ -248,12 +248,12 @@ where } fn overlay<'b>( - &'b self, + &'b mut self, tree: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, ) -> Option> { - self.content.as_widget().overlay( + self.content.as_widget_mut().overlay( &mut tree.children[0], layout.children().next().unwrap(), renderer, -- cgit