summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-12-18 23:29:51 +0100
committerLibravatar GitHub <noreply@github.com>2020-12-18 23:29:51 +0100
commit0e9f649cb741d7f02c4bafe4ea804bd68e0a1b7a (patch)
treeba45c33eb69ce31ec50bd73f99c28e65ee1c9215 /examples
parent07b570036aad3f42578876e1a299a0577e6761ae (diff)
parent10d6df73e34e421cbf96d62b26c0c0701d9096ef (diff)
downloadiced-0e9f649cb741d7f02c4bafe4ea804bd68e0a1b7a.tar.gz
iced-0e9f649cb741d7f02c4bafe4ea804bd68e0a1b7a.tar.bz2
iced-0e9f649cb741d7f02c4bafe4ea804bd68e0a1b7a.zip
Merge pull request #319 from tarkah/image-pane
Add `ImagePane` widget
Diffstat (limited to 'examples')
-rw-r--r--examples/pokedex/src/main.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/examples/pokedex/src/main.rs b/examples/pokedex/src/main.rs
index 187e5dee..f432f0fc 100644
--- a/examples/pokedex/src/main.rs
+++ b/examples/pokedex/src/main.rs
@@ -1,6 +1,6 @@
use iced::{
button, futures, image, Align, Application, Button, Column, Command,
- Container, Element, Image, Length, Row, Settings, Text,
+ Container, Element, Length, Row, Settings, Text,
};
pub fn main() -> iced::Result {
@@ -112,16 +112,20 @@ struct Pokemon {
name: String,
description: String,
image: image::Handle,
+ image_viewer: image::viewer::State,
}
impl Pokemon {
const TOTAL: u16 = 807;
- fn view(&self) -> Element<Message> {
+ fn view(&mut self) -> Element<Message> {
Row::new()
.spacing(20)
.align_items(Align::Center)
- .push(Image::new(self.image.clone()))
+ .push(image::Viewer::new(
+ &mut self.image_viewer,
+ self.image.clone(),
+ ))
.push(
Column::new()
.spacing(20)
@@ -200,6 +204,7 @@ impl Pokemon {
.map(|c| if c.is_control() { ' ' } else { c })
.collect(),
image,
+ image_viewer: image::viewer::State::new(),
})
}