diff options
| author | 2024-07-12 15:11:30 +0200 | |
|---|---|---|
| committer | 2024-07-12 15:14:43 +0200 | |
| commit | f9dd5cbb099bbe44a57b6369be54a442363b7a8d (patch) | |
| tree | fe16084bc47faadc32d698aa446ea202f7949a4c /examples/stopwatch/src | |
| parent | be06060117da061ad8cad94ab0830c06def6b147 (diff) | |
| download | iced-f9dd5cbb099bbe44a57b6369be54a442363b7a8d.tar.gz iced-f9dd5cbb099bbe44a57b6369be54a442363b7a8d.tar.bz2 iced-f9dd5cbb099bbe44a57b6369be54a442363b7a8d.zip | |
Introduce helper methods for alignment for all widgets
Diffstat (limited to '')
| -rw-r--r-- | examples/stopwatch/src/main.rs | 16 | 
1 files changed, 4 insertions, 12 deletions
| diff --git a/examples/stopwatch/src/main.rs b/examples/stopwatch/src/main.rs index bd56785a..ca7b8f91 100644 --- a/examples/stopwatch/src/main.rs +++ b/examples/stopwatch/src/main.rs @@ -1,8 +1,7 @@ -use iced::alignment;  use iced::keyboard;  use iced::time;  use iced::widget::{button, center, column, row, text}; -use iced::{Alignment, Element, Subscription, Theme}; +use iced::{Element, Subscription, Theme};  use std::time::{Duration, Instant}; @@ -101,13 +100,8 @@ impl Stopwatch {          )          .size(40); -        let button = |label| { -            button( -                text(label).horizontal_alignment(alignment::Horizontal::Center), -            ) -            .padding(10) -            .width(80) -        }; +        let button = +            |label| button(text(label).center_x()).padding(10).width(80);          let toggle_button = {              let label = match self.state { @@ -124,9 +118,7 @@ impl Stopwatch {          let controls = row![toggle_button, reset_button].spacing(20); -        let content = column![duration, controls] -            .align_items(Alignment::Center) -            .spacing(20); +        let content = column![duration, controls].center_x().spacing(20);          center(content).into()      } | 
