Implement Widget::mouse_interaction for image::Viewer

This commit is contained in:
Héctor Ramón Jiménez 2021-10-28 17:01:33 +07:00
parent 8b15874218
commit bc32199e39
No known key found for this signature in database
GPG key ID: 140CC052C94F138E

View file

@ -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,