From 0655a20ad119e2e9790afcc45039fd4ac0e7d432 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 16 Mar 2023 20:23:25 +0100 Subject: Make `Shrink` have priority over `Fill` in layout --- examples/toast/src/main.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'examples/toast/src/main.rs') diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs index 31b6f191..711d8223 100644 --- a/examples/toast/src/main.rs +++ b/examples/toast/src/main.rs @@ -106,9 +106,7 @@ impl Application for App { fn view<'a>(&'a self) -> Element<'a, Message> { let subtitle = |title, content: Element<'a, Message>| { - column![text(title).size(14), content] - .width(Length::Fill) - .spacing(5) + column![text(title).size(14), content].spacing(5) }; let mut add_toast = button("Add Toast"); @@ -153,14 +151,11 @@ impl Application for App { Message::Timeout ) .step(1.0) - .width(Length::Fill) ] .spacing(5) .into() ), - column![add_toast] - .width(Length::Fill) - .align_items(Alignment::End) + column![add_toast].align_items(Alignment::End) ] .spacing(10) .max_width(200), @@ -513,14 +508,14 @@ mod toast { position: Point, _translation: Vector, ) -> layout::Node { - let limits = layout::Limits::new(Size::ZERO, bounds) - .width(Length::Fill) - .height(Length::Fill); + let limits = layout::Limits::new(Size::ZERO, bounds); layout::flex::resolve( layout::flex::Axis::Vertical, renderer, &limits, + Length::Fill, + Length::Fill, 10.into(), 10.0, Alignment::End, -- cgit From d278bfd21d0399009e652560afb9a4d185e92637 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 5 Jan 2024 17:46:33 +0100 Subject: Replace `width` and `height` with `Widget::size` --- examples/toast/src/main.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'examples/toast/src/main.rs') diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs index 711d8223..300343b9 100644 --- a/examples/toast/src/main.rs +++ b/examples/toast/src/main.rs @@ -313,12 +313,8 @@ mod toast { } impl<'a, Message> Widget for Manager<'a, Message> { - fn width(&self) -> Length { - self.content.as_widget().width() - } - - fn height(&self) -> Length { - self.content.as_widget().height() + fn size(&self) -> Size { + self.content.as_widget().size() } fn layout( -- cgit