diff options
author | 2019-11-11 05:26:08 +0100 | |
---|---|---|
committer | 2019-11-11 05:26:08 +0100 | |
commit | ceb02f4a36769c488c2525db2fb73f092a6c2706 (patch) | |
tree | d7a43c6b9444fb3079501e49ca1f80e31f1b4740 /examples/tour.rs | |
parent | bfe19193b95e9d1be0694bbc6a96e20a9aefdc09 (diff) | |
download | iced-ceb02f4a36769c488c2525db2fb73f092a6c2706.tar.gz iced-ceb02f4a36769c488c2525db2fb73f092a6c2706.tar.bz2 iced-ceb02f4a36769c488c2525db2fb73f092a6c2706.zip |
Implement `Container` widget
Remove `align_self` and `justify_content` methods
Diffstat (limited to 'examples/tour.rs')
-rw-r--r-- | examples/tour.rs | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/examples/tour.rs b/examples/tour.rs index 9e93170a..2e60f090 100644 --- a/examples/tour.rs +++ b/examples/tour.rs @@ -1,7 +1,7 @@ use iced::{ button, scrollable, slider, text::HorizontalAlignment, text_input, Align, - Application, Background, Button, Checkbox, Color, Column, Element, Image, - Justify, Length, Radio, Row, Scrollable, Slider, Text, TextInput, + Application, Background, Button, Checkbox, Color, Column, Container, + Element, Image, Length, Radio, Row, Scrollable, Slider, Text, TextInput, }; pub fn main() { @@ -78,7 +78,7 @@ impl Application for Tour { ); } - let element: Element<_> = Column::new() + let content: Element<_> = Column::new() .max_width(540) .spacing(20) .padding(20) @@ -86,20 +86,18 @@ impl Application for Tour { .push(controls) .into(); - let element = if self.debug { - element.explain(Color::BLACK) + let content = if self.debug { + content.explain(Color::BLACK) } else { - element + content }; - Column::new() + let scrollable = Scrollable::new(scroll) + .push(Container::new(content).width(Length::Fill).center_x()); + + Container::new(scrollable) .height(Length::Fill) - .justify_content(Justify::Center) - .push( - Scrollable::new(scroll) - .align_items(Align::Center) - .push(element), - ) + .center_y() .into() } } @@ -340,10 +338,7 @@ impl<'a> Step { } fn container(title: &str) -> Column<'a, StepMessage> { - Column::new() - .spacing(20) - .align_items(Align::Stretch) - .push(Text::new(title).size(50)) + Column::new().spacing(20).push(Text::new(title).size(50)) } fn welcome() -> Column<'a, StepMessage> { @@ -646,19 +641,22 @@ impl<'a> Step { } } -fn ferris(width: u16) -> Image { - // This should go away once we unify resource loading on native - // platforms - if cfg!(target_arch = "wasm32") { - Image::new("resources/ferris.png") - } else { - Image::new(format!( - "{}/examples/resources/ferris.png", - env!("CARGO_MANIFEST_DIR") - )) - } - .width(Length::Units(width)) - .align_self(Align::Center) +fn ferris<'a>(width: u16) -> Container<'a, StepMessage> { + Container::new( + // This should go away once we unify resource loading on native + // platforms + if cfg!(target_arch = "wasm32") { + Image::new("resources/ferris.png") + } else { + Image::new(format!( + "{}/examples/resources/ferris.png", + env!("CARGO_MANIFEST_DIR") + )) + } + .width(Length::Units(width)), + ) + .width(Length::Fill) + .center_x() } fn button<'a, Message>( |