From bc32199e39ee3d42b0d71d9082d56b368e401534 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 28 Oct 2021 17:01:33 +0700 Subject: Implement `Widget::mouse_interaction` for `image::Viewer` --- native/src/widget/image/viewer.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'native/src/widget/image/viewer.rs') diff --git a/native/src/widget/image/viewer.rs b/native/src/widget/image/viewer.rs index 3e8430f3..d9eccfad 100644 --- a/native/src/widget/image/viewer.rs +++ b/native/src/widget/image/viewer.rs @@ -281,6 +281,24 @@ where } } + fn mouse_interaction( + &self, + layout: Layout<'_>, + _viewport: &Rectangle, + cursor_position: Point, + ) -> mouse::Interaction { + let bounds = layout.bounds(); + let is_mouse_over = bounds.contains(cursor_position); + + if self.state.is_cursor_grabbed() { + mouse::Interaction::Grabbing + } else if is_mouse_over { + mouse::Interaction::Grab + } else { + mouse::Interaction::Idle + } + } + fn draw( &self, renderer: &mut Renderer, -- cgit