From a805177b250b2316c0a9b4de06a3be4556d6944a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 22 Nov 2024 04:13:38 +0100 Subject: [PATCH] Make `pin` widget `Fill` parent by default --- examples/layout/src/main.rs | 4 ++-- widget/src/helpers.rs | 2 -- widget/src/pin.rs | 10 ++++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/examples/layout/src/main.rs b/examples/layout/src/main.rs index d71cbcbc89..e83a1f7dad 100644 --- a/examples/layout/src/main.rs +++ b/examples/layout/src/main.rs @@ -319,11 +319,11 @@ fn pinning<'a>() -> Element<'a, Message> { "The pin widget can be used to position a widget \ at some fixed coordinates inside some other widget.", stack![ - container(pin("• (50, 50)").width(Fill).height(Fill).x(50).y(50)) + container(pin("• (50, 50)").x(50).y(50)) .width(500) .height(500) .style(container::bordered_box), - pin("• (300, 300)").width(Fill).height(Fill).x(300).y(300), + pin("• (300, 300)").x(300).y(300), ] ] .align_x(Center) diff --git a/widget/src/helpers.rs b/widget/src/helpers.rs index a669b2907e..3d85ba7039 100644 --- a/widget/src/helpers.rs +++ b/widget/src/helpers.rs @@ -267,8 +267,6 @@ where /// /// fn view(state: &State) -> Element<'_, Message> { /// pin("This text is displayed at coordinates (50, 50)!") -/// .width(Fill) -/// .height(Fill) /// .x(50) /// .y(50) /// .into() diff --git a/widget/src/pin.rs b/widget/src/pin.rs index 7d561894b9..1f16771669 100644 --- a/widget/src/pin.rs +++ b/widget/src/pin.rs @@ -14,8 +14,6 @@ //! //! fn view(state: &State) -> Element<'_, Message> { //! pin("This text is displayed at coordinates (50, 50)!") -//! .width(Fill) -//! .height(Fill) //! .x(50) //! .y(50) //! .into() @@ -33,6 +31,8 @@ use crate::core::{ /// A widget that positions its contents at some fixed coordinates inside of its boundaries. /// +/// By default, a [`Pin`] widget will try to fill its parent. +/// /// # Example /// ```no_run /// # mod iced { pub mod widget { pub use iced_widget::*; } pub use iced_widget::core::Length::Fill; } @@ -47,8 +47,6 @@ use crate::core::{ /// /// fn view(state: &State) -> Element<'_, Message> { /// pin("This text is displayed at coordinates (50, 50)!") -/// .width(Fill) -/// .height(Fill) /// .x(50) /// .y(50) /// .into() @@ -75,8 +73,8 @@ where ) -> Self { Self { content: content.into(), - width: Length::Shrink, - height: Length::Shrink, + width: Length::Fill, + height: Length::Fill, position: Point::ORIGIN, } }