From d62bb8193c1c43f565fcc5c52293d564c91e215d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 9 Jan 2024 06:35:33 +0100 Subject: Introduce useful helpers in `layout` module --- widget/src/button.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'widget/src/button.rs') diff --git a/widget/src/button.rs b/widget/src/button.rs index 1ce4f662..86abee77 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -10,8 +10,8 @@ use crate::core::touch; use crate::core::widget::tree::{self, Tree}; use crate::core::widget::Operation; use crate::core::{ - Background, Clipboard, Color, Element, Layout, Length, Padding, Point, - Rectangle, Shell, Size, Vector, Widget, + Background, Clipboard, Color, Element, Layout, Length, Padding, Rectangle, + Shell, Size, Vector, Widget, }; pub use iced_style::button::{Appearance, StyleSheet}; @@ -430,20 +430,7 @@ pub fn layout( padding: Padding, layout_content: impl FnOnce(&layout::Limits) -> layout::Node, ) -> layout::Node { - let limits = limits.width(width).height(height); - - let content = layout_content(&limits.shrink(padding)); - let padding = padding.fit(content.size(), limits.max()); - - let size = limits - .shrink(padding) - .resolve(content.size(), width, height) - .expand(padding); - - layout::Node::with_children( - size, - vec![content.move_to(Point::new(padding.left, padding.top))], - ) + layout::padded(limits, width, height, padding, layout_content) } /// Returns the [`mouse::Interaction`] of a [`Button`]. -- cgit