summaryrefslogtreecommitdiffstats
path: root/native/src/widget
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-28 17:01:33 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-10-28 17:01:33 +0700
commitbc32199e39ee3d42b0d71d9082d56b368e401534 (patch)
tree4bbfdc583f615ff97f5fe030d205c88c56533fb0 /native/src/widget
parent8b1587421822d9a0e7fa1c2224447da7007dbd30 (diff)
downloadiced-bc32199e39ee3d42b0d71d9082d56b368e401534.tar.gz
iced-bc32199e39ee3d42b0d71d9082d56b368e401534.tar.bz2
iced-bc32199e39ee3d42b0d71d9082d56b368e401534.zip
Implement `Widget::mouse_interaction` for `image::Viewer`
Diffstat (limited to 'native/src/widget')
-rw-r--r--native/src/widget/image/viewer.rs18
1 files changed, 18 insertions, 0 deletions
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,