diff options
author | 2020-12-18 10:44:24 +0100 | |
---|---|---|
committer | 2020-12-18 10:44:24 +0100 | |
commit | 21b10dc103638ead2a567b3426c937f39e9addbd (patch) | |
tree | 237a79644c81afb199e28e772c6e723ad22983f4 /graphics | |
parent | 0cdf8d56ee515fb56b08ee149683a2216a535950 (diff) | |
download | iced-21b10dc103638ead2a567b3426c937f39e9addbd.tar.gz iced-21b10dc103638ead2a567b3426c937f39e9addbd.tar.bz2 iced-21b10dc103638ead2a567b3426c937f39e9addbd.zip |
Fix `layout` of `image::Viewer`
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/src/widget/image/viewer.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/graphics/src/widget/image/viewer.rs b/graphics/src/widget/image/viewer.rs index 0bcd09fc..804f2be6 100644 --- a/graphics/src/widget/image/viewer.rs +++ b/graphics/src/widget/image/viewer.rs @@ -5,7 +5,7 @@ use crate::{Primitive, Renderer}; use iced_native::image; use iced_native::image::viewer; use iced_native::mouse; -use iced_native::{Rectangle, Vector}; +use iced_native::{Rectangle, Size, Vector}; impl<B> viewer::Renderer for Renderer<B> where @@ -15,7 +15,7 @@ where &mut self, state: &viewer::State, bounds: Rectangle, - image_bounds: Rectangle, + image_size: Size, translation: Vector, handle: image::Handle, is_mouse_over: bool, @@ -28,7 +28,11 @@ where translation, content: Box::new(Primitive::Image { handle, - bounds: image_bounds, + bounds: Rectangle { + x: bounds.x, + y: bounds.y, + ..Rectangle::with_size(image_size) + }, }), }), offset: Vector::new(0, 0), @@ -38,8 +42,8 @@ where if state.is_cursor_clicked() { mouse::Interaction::Grabbing } else if is_mouse_over - && (image_bounds.width > bounds.width - || image_bounds.height > bounds.height) + && (image_size.width > bounds.width + || image_size.height > bounds.height) { mouse::Interaction::Grab } else { |