summaryrefslogtreecommitdiffstats
path: root/native/src/widget/image
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/widget/image')
-rw-r--r--native/src/widget/image/viewer.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/native/src/widget/image/viewer.rs b/native/src/widget/image/viewer.rs
index b129924b..9544beab 100644
--- a/native/src/widget/image/viewer.rs
+++ b/native/src/widget/image/viewer.rs
@@ -1,7 +1,11 @@
//! Zoom and pan on an image.
+use crate::event::{self, Event};
+use crate::image;
+use crate::layout;
+use crate::mouse;
use crate::{
- image, layout, mouse, Clipboard, Element, Event, Hasher, Layout, Length,
- Point, Rectangle, Size, Vector, Widget,
+ Clipboard, Element, Hasher, Layout, Length, Point, Rectangle, Size, Vector,
+ Widget,
};
use std::{f32, hash::Hash, u32};
@@ -216,7 +220,7 @@ where
_messages: &mut Vec<Message>,
renderer: &Renderer,
_clipboard: Option<&dyn Clipboard>,
- ) {
+ ) -> event::Status {
let bounds = layout.bounds();
let is_mouse_over = bounds.contains(cursor_position);
@@ -290,11 +294,16 @@ where
self.state.starting_cursor_pos = None
}
}
- Event::Mouse(mouse::Event::CursorMoved { x, y }) => {
+ Event::Mouse(mouse::Event::CursorMoved { position }) => {
if self.state.is_cursor_clicked() {
let image_bounds = self.image_bounds(renderer, bounds);
- self.state.pan(x, y, bounds, image_bounds);
+ self.state.pan(
+ position.x,
+ position.y,
+ bounds,
+ image_bounds,
+ );
}
}
_ => {}
@@ -305,6 +314,8 @@ where
self.state.starting_cursor_pos = None;
}
}
+
+ event::Status::Ignored
}
fn draw(
@@ -313,6 +324,7 @@ where
_defaults: &Renderer::Defaults,
layout: Layout<'_>,
cursor_position: Point,
+ _viewport: &Rectangle,
) -> Renderer::Output {
let bounds = layout.bounds();