Implement Widget::mouse_interaction for image::Viewer
This commit is contained in:
parent
8b15874218
commit
bc32199e39
1 changed files with 18 additions and 0 deletions
|
|
@ -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(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
renderer: &mut Renderer,
|
renderer: &mut Renderer,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue