rename to image::Viewer
This commit is contained in:
parent
431171f975
commit
5d045c2e9a
9 changed files with 50 additions and 73 deletions
39
wgpu/src/renderer/widget/image/viewer.rs
Normal file
39
wgpu/src/renderer/widget/image/viewer.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use crate::{Primitive, Renderer};
|
||||
use iced_native::{image, mouse, Rectangle, Vector};
|
||||
|
||||
impl image::viewer::Renderer for Renderer {
|
||||
fn draw(
|
||||
&mut self,
|
||||
state: &image::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() {
|
||||
mouse::Interaction::Grabbing
|
||||
} else if is_mouse_over
|
||||
&& (image_bounds.width > bounds.width
|
||||
|| image_bounds.height > bounds.height)
|
||||
{
|
||||
mouse::Interaction::Grab
|
||||
} else {
|
||||
mouse::Interaction::Idle
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue