diff options
author | 2019-10-27 02:29:23 +0100 | |
---|---|---|
committer | 2019-10-27 02:29:23 +0100 | |
commit | 0a0aa3edd9c5185551040c75a934f12d3bce7618 (patch) | |
tree | f158003fb4e4316a318453ddd53f2cd3357474e4 /examples | |
parent | 63c10b67ab213c5971313743fde566bd5c0f0c15 (diff) | |
download | iced-0a0aa3edd9c5185551040c75a934f12d3bce7618.tar.gz iced-0a0aa3edd9c5185551040c75a934f12d3bce7618.tar.bz2 iced-0a0aa3edd9c5185551040c75a934f12d3bce7618.zip |
Implement clipping for images
Diffstat (limited to 'examples')
-rw-r--r-- | examples/scroll.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/examples/scroll.rs b/examples/scroll.rs index 2f250ff8..450dae11 100644 --- a/examples/scroll.rs +++ b/examples/scroll.rs @@ -32,7 +32,19 @@ impl Application for Example { } fn view(&mut self) -> Element<Message> { - let content = Scrollable::new(&mut self.scroll).spacing(20).padding(20); + let content = (0..3).fold( + Scrollable::new(&mut self.scroll).spacing(20).padding(20), + |content, _| { + content.push( + Image::new(format!( + "{}/examples/resources/ferris.png", + env!("CARGO_MANIFEST_DIR") + )) + .width(Length::Units(400)) + .align_self(Align::Center), + ) + }, + ); //let content = (0..self.paragraph_count) // .fold(content, |column, _| column.push(lorem_ipsum())) @@ -46,19 +58,9 @@ impl Application for Example { Column::new() .height(Length::Fill) - .max_width(Length::Units(600)) - .align_self(Align::Center) .justify_content(Justify::Center) - .push((0..3).fold(content, |content, _| { - content.push( - Image::new(format!( - "{}/examples/resources/ferris.png", - env!("CARGO_MANIFEST_DIR") - )) - .width(Length::Units(400)) - .align_self(Align::Center), - ) - })) + .padding(20) + .push(content) .into() } } |