2020-04-23 15:34:55 -07:00
|
|
|
use crate::{Primitive, Renderer};
|
|
|
|
|
use iced_native::{image, image_pane, MouseCursor, Rectangle, Vector};
|
|
|
|
|
|
|
|
|
|
impl image_pane::Renderer for Renderer {
|
|
|
|
|
fn draw(
|
|
|
|
|
&mut self,
|
|
|
|
|
state: &image_pane::State,
|
|
|
|
|
bounds: Rectangle,
|
|
|
|
|
image_bounds: Rectangle,
|
|
|
|
|
offset: (u32, u32),
|
|
|
|
|
handle: image::Handle,
|
|
|
|
|
is_mouse_over: bool,
|
|
|
|
|
) -> Self::Output {
|
|
|
|
|
(
|
|
|
|
|
{
|
|
|
|
|
Primitive::Clip {
|
|
|
|
|
bounds,
|
|
|
|
|
offset: Vector::new(offset.0, offset.1),
|
|
|
|
|
content: Box::new(Primitive::Image {
|
|
|
|
|
handle,
|
|
|
|
|
bounds: image_bounds,
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
if state.is_cursor_clicked() {
|
|
|
|
|
MouseCursor::Grabbing
|
2020-04-23 16:22:53 -07:00
|
|
|
} else if is_mouse_over
|
|
|
|
|
&& (image_bounds.width > bounds.width
|
|
|
|
|
|| image_bounds.height > bounds.height)
|
|
|
|
|
{
|
2020-04-23 15:34:55 -07:00
|
|
|
MouseCursor::Grab
|
|
|
|
|
} else {
|
2020-04-23 16:22:53 -07:00
|
|
|
MouseCursor::Idle
|
2020-04-23 15:34:55 -07:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|