From f9dd5cbb099bbe44a57b6369be54a442363b7a8d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 12 Jul 2024 15:11:30 +0200 Subject: Introduce helper methods for alignment for all widgets --- examples/component/src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'examples/component/src') diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs index 5625f12a..14d3d9ba 100644 --- a/examples/component/src/main.rs +++ b/examples/component/src/main.rs @@ -34,7 +34,6 @@ impl Component { } mod numeric_input { - use iced::alignment::{self, Alignment}; use iced::widget::{button, component, row, text, text_input, Component}; use iced::{Element, Length, Size}; @@ -108,8 +107,7 @@ mod numeric_input { text(label) .width(Length::Fill) .height(Length::Fill) - .horizontal_alignment(alignment::Horizontal::Center) - .vertical_alignment(alignment::Vertical::Center), + .center(), ) .width(40) .height(40) @@ -130,7 +128,7 @@ mod numeric_input { .padding(10), button("+", Event::IncrementPressed), ] - .align_items(Alignment::Center) + .center_y() .spacing(10) .into() } -- cgit From 76737351ea9e116291112b7d576d9ed4f6bb5c2a Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 12 Jul 2024 18:12:34 +0200 Subject: Re-export variants of `Length` and `alignment` types --- examples/component/src/main.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'examples/component/src') diff --git a/examples/component/src/main.rs b/examples/component/src/main.rs index 14d3d9ba..a5d2e508 100644 --- a/examples/component/src/main.rs +++ b/examples/component/src/main.rs @@ -35,7 +35,7 @@ impl Component { mod numeric_input { use iced::widget::{button, component, row, text, text_input, Component}; - use iced::{Element, Length, Size}; + use iced::{Center, Element, Fill, Length, Size}; pub struct NumericInput { value: Option, @@ -103,15 +103,10 @@ mod numeric_input { fn view(&self, _state: &Self::State) -> Element<'_, Event, Theme> { let button = |label, on_press| { - button( - text(label) - .width(Length::Fill) - .height(Length::Fill) - .center(), - ) - .width(40) - .height(40) - .on_press(on_press) + button(text(label).width(Fill).height(Fill).center()) + .width(40) + .height(40) + .on_press(on_press) }; row![ @@ -128,7 +123,7 @@ mod numeric_input { .padding(10), button("+", Event::IncrementPressed), ] - .center_y() + .align_y(Center) .spacing(10) .into() } -- cgit