summaryrefslogtreecommitdiffstats
path: root/examples/toast/src
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-01-12 14:41:40 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-12 14:41:40 +0100
commit50c310fd9f692eafb2350827636ffbd6d7b6c9b9 (patch)
tree0f1ab4182a0cce7469e01881c095e0c3988b3f9a /examples/toast/src
parent63e9adac56e9a4f21ec82137329d7c455fbf630b (diff)
parent11474bdc3e1a43e6c167d7b98f22d87933dbd2b6 (diff)
downloadiced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.tar.gz
iced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.tar.bz2
iced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.zip
Merge pull request #2192 from iced-rs/fix/layout-inconsistencies
Layout consistency
Diffstat (limited to 'examples/toast/src')
-rw-r--r--examples/toast/src/main.rs23
1 files changed, 7 insertions, 16 deletions
diff --git a/examples/toast/src/main.rs b/examples/toast/src/main.rs
index 31b6f191..300343b9 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),
@@ -318,12 +313,8 @@ mod toast {
}
impl<'a, Message> Widget<Message, Renderer> 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<Length> {
+ self.content.as_widget().size()
}
fn layout(
@@ -513,14 +504,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,