diff options
author | 2022-02-16 18:16:22 +0700 | |
---|---|---|
committer | 2022-02-16 18:19:37 +0700 | |
commit | 6f6ce15a2055ddbc15dbe71bc811dbe1c8f42068 (patch) | |
tree | a3e03b65244d62676d77d1b0439c4998b444e9fd /examples/tour/src | |
parent | 15b4bbd49dfb4f70e1e73699958a764c0568b452 (diff) | |
download | iced-6f6ce15a2055ddbc15dbe71bc811dbe1c8f42068.tar.gz iced-6f6ce15a2055ddbc15dbe71bc811dbe1c8f42068.tar.bz2 iced-6f6ce15a2055ddbc15dbe71bc811dbe1c8f42068.zip |
Keep using Ferris in the image section of the `tour`
Wide ferris is cute :3
Diffstat (limited to 'examples/tour/src')
-rw-r--r-- | examples/tour/src/main.rs | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs index 9a675168..a4863724 100644 --- a/examples/tour/src/main.rs +++ b/examples/tour/src/main.rs @@ -612,7 +612,7 @@ impl<'a> Step { Self::container("Image") .push(Text::new("Pictures of things in all shapes and sizes!")) - .push(logo(height, current_fit)) + .push(ferris(height, current_fit)) .push(Slider::new( slider, 50..=500, @@ -647,7 +647,7 @@ impl<'a> Step { .horizontal_alignment(alignment::Horizontal::Center), ) .push(Column::new().height(Length::Units(4096))) - .push(ferris(200)) + .push(ferris(200, ContentFit::Contain)) .push( Text::new("You made it!") .width(Length::Fill) @@ -733,8 +733,10 @@ impl<'a> Step { } } -/// Passing fit=None defaults to ContentFit::Contain -fn ferris<'a>(width: u16) -> Container<'a, StepMessage> { +fn ferris<'a>( + height: u16, + content_fit: ContentFit, +) -> Container<'a, StepMessage> { Container::new( // This should go away once we unify resource loading on native // platforms @@ -746,29 +748,8 @@ fn ferris<'a>(width: u16) -> Container<'a, StepMessage> { env!("CARGO_MANIFEST_DIR"), )) } - .width(Length::Units(width)) - .content_fit(ContentFit::Contain), - ) - .width(Length::Fill) - .center_x() -} - -/// Passing fit=None defaults to ContentFit::Contain -fn logo<'a>(height: u16, fit: ContentFit) -> Container<'a, StepMessage> { - Container::new( - // This should go away once we unify resource loading on native - // platforms - if cfg!(target_arch = "wasm32") { - Image::new("tour/images/logo.png") - } else { - Image::new(format!( - "{}/images/logo.png", - env!("CARGO_MANIFEST_DIR"), - )) - } - .width(Length::Fill) .height(Length::Units(height)) - .content_fit(fit), + .content_fit(content_fit), ) .width(Length::Fill) .center_x() |