summaryrefslogtreecommitdiffstats
path: root/examples/tour.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-02 02:44:57 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-02 02:44:57 +0100
commit022dc0139b7437f167a8d3ae483bf8e83f1dab04 (patch)
tree6c6dbad5ae16a8065ab922c605c32d1d276c2b52 /examples/tour.rs
parent85dab04965940f15cf0e9879e296f67235a3775c (diff)
downloadiced-022dc0139b7437f167a8d3ae483bf8e83f1dab04.tar.gz
iced-022dc0139b7437f167a8d3ae483bf8e83f1dab04.tar.bz2
iced-022dc0139b7437f167a8d3ae483bf8e83f1dab04.zip
Show Ferris at the end of the scrollable section
Diffstat (limited to 'examples/tour.rs')
-rw-r--r--examples/tour.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/examples/tour.rs b/examples/tour.rs
index 7d8e4e3e..f63b4cfe 100644
--- a/examples/tour.rs
+++ b/examples/tour.rs
@@ -510,20 +510,7 @@ impl<'a> Step {
) -> Column<'a, StepMessage> {
Self::container("Image")
.push(Text::new("An image that tries to keep its aspect ratio."))
- .push(
- // 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),
- )
+ .push(ferris(width))
.push(Slider::new(
slider,
100.0..=500.0,
@@ -555,6 +542,7 @@ impl<'a> Step {
.horizontal_alignment(HorizontalAlignment::Center),
)
.push(Column::new().height(Length::Units(4096)))
+ .push(ferris(300))
.push(
Text::new("You made it!")
.size(50)
@@ -589,6 +577,21 @@ 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 button<'a, Message>(
state: &'a mut button::State,
label: &str,