diff options
-rw-r--r-- | native/src/widget/image_pane.rs | 55 | ||||
-rw-r--r-- | wgpu/src/renderer/widget/image_pane.rs | 8 |
2 files changed, 20 insertions, 43 deletions
diff --git a/native/src/widget/image_pane.rs b/native/src/widget/image_pane.rs index 4d07f228..4f3d4877 100644 --- a/native/src/widget/image_pane.rs +++ b/native/src/widget/image_pane.rs @@ -1,9 +1,7 @@ //! Zoom and pan on an image. use crate::{ - image, - input::{self, mouse}, - layout, Clipboard, Element, Event, Hasher, Layout, Length, Point, - Rectangle, Size, Widget, + image, layout, mouse, Clipboard, Element, Event, Hasher, Layout, Length, + Point, Rectangle, Size, Widget, }; use std::{f32, hash::Hash, u32}; @@ -154,21 +152,8 @@ where match event { Event::Mouse(mouse::Event::WheelScrolled { delta }) => { match delta { - mouse::ScrollDelta::Lines { y, .. } => { - // TODO: Configurable step and limits - if y > 0.0 { - self.state.scale = Some( - (self.state.scale.unwrap_or(1.0) + 0.25) - .min(10.0), - ); - } else { - self.state.scale = Some( - (self.state.scale.unwrap_or(1.0) - 0.25) - .max(0.25), - ); - } - } - mouse::ScrollDelta::Pixels { y, .. } => { + mouse::ScrollDelta::Lines { y, .. } + | mouse::ScrollDelta::Pixels { y, .. } => { // TODO: Configurable step and limits if y > 0.0 { self.state.scale = Some( @@ -184,22 +169,17 @@ where } } } - Event::Mouse(mouse::Event::Input { button, state }) => { + Event::Mouse(mouse::Event::ButtonPressed(button)) => { if button == mouse::Button::Left { - match state { - input::ButtonState::Pressed => { - self.state.starting_cursor_pos = Some(( - cursor_position.x, - cursor_position.y, - )); - - self.state.starting_offset = - self.state.current_offset; - } - input::ButtonState::Released => { - self.state.starting_cursor_pos = None - } - } + self.state.starting_cursor_pos = + Some((cursor_position.x, cursor_position.y)); + + self.state.starting_offset = self.state.current_offset; + } + } + Event::Mouse(mouse::Event::ButtonReleased(button)) => { + if button == mouse::Button::Left { + self.state.starting_cursor_pos = None } } Event::Mouse(mouse::Event::CursorMoved { x, y }) => { @@ -209,12 +189,9 @@ where } _ => {} } - } else if let Event::Mouse(mouse::Event::Input { button, state }) = - event + } else if let Event::Mouse(mouse::Event::ButtonReleased(button)) = event { - if button == mouse::Button::Left - && state == input::ButtonState::Released - { + if button == mouse::Button::Left { self.state.starting_cursor_pos = None; } } diff --git a/wgpu/src/renderer/widget/image_pane.rs b/wgpu/src/renderer/widget/image_pane.rs index a7cee6ac..b5e86913 100644 --- a/wgpu/src/renderer/widget/image_pane.rs +++ b/wgpu/src/renderer/widget/image_pane.rs @@ -1,5 +1,5 @@ use crate::{Primitive, Renderer}; -use iced_native::{image, image_pane, MouseCursor, Rectangle, Vector}; +use iced_native::{image, image_pane, mouse, Rectangle, Vector}; impl image_pane::Renderer for Renderer { fn draw( @@ -24,14 +24,14 @@ impl image_pane::Renderer for Renderer { }, { if state.is_cursor_clicked() { - MouseCursor::Grabbing + mouse::Interaction::Grabbing } else if is_mouse_over && (image_bounds.width > bounds.width || image_bounds.height > bounds.height) { - MouseCursor::Grab + mouse::Interaction::Grab } else { - MouseCursor::Idle + mouse::Interaction::Idle } }, ) |