From f8337b8da7ff6bcf876b54d1c7dac460d2e03747 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 24 Jan 2025 15:55:24 +0100 Subject: Add helper functions for alignment to `widget` module --- examples/tour/src/main.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'examples/tour/src') diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index d8c0b29a..32720c47 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -1,6 +1,6 @@ use iced::widget::{ - button, checkbox, column, container, horizontal_space, image, radio, row, - scrollable, slider, text, text_input, toggler, vertical_space, + button, center_x, center_y, checkbox, column, horizontal_space, image, + radio, row, scrollable, slider, text, text_input, toggler, vertical_space, }; use iced::widget::{Button, Column, Container, Slider}; use iced::{Center, Color, Element, Fill, Font, Pixels}; @@ -166,16 +166,13 @@ impl Tour { .padding(20) .into(); - let scrollable = scrollable( - container(if self.debug { - content.explain(Color::BLACK) - } else { - content - }) - .center_x(Fill), - ); + let scrollable = scrollable(center_x(if self.debug { + content.explain(Color::BLACK) + } else { + content + })); - container(scrollable).center_y(Fill).into() + center_y(scrollable).into() } fn can_continue(&self) -> bool { @@ -543,7 +540,7 @@ fn ferris<'a>( width: u16, filter_method: image::FilterMethod, ) -> Container<'a, Message> { - container( + center_x( // This should go away once we unify resource loading on native // platforms if cfg!(target_arch = "wasm32") { @@ -554,7 +551,6 @@ fn ferris<'a>( .filter_method(filter_method) .width(width), ) - .center_x(Fill) } fn padded_button(label: &str) -> Button<'_, Message> { -- cgit