Implement Widget::draw for image::Viewer
This commit is contained in:
parent
1ec667920a
commit
8b15874218
3 changed files with 20 additions and 12 deletions
|
|
@ -284,9 +284,9 @@ where
|
|||
fn draw(
|
||||
&self,
|
||||
renderer: &mut Renderer,
|
||||
style: &renderer::Style,
|
||||
_style: &renderer::Style,
|
||||
layout: Layout<'_>,
|
||||
cursor_position: Point,
|
||||
_cursor_position: Point,
|
||||
_viewport: &Rectangle,
|
||||
) {
|
||||
let bounds = layout.bounds();
|
||||
|
|
@ -302,7 +302,19 @@ where
|
|||
image_top_left - self.state.offset(bounds, image_size)
|
||||
};
|
||||
|
||||
let is_mouse_over = bounds.contains(cursor_position);
|
||||
renderer.with_layer(bounds, |renderer| {
|
||||
renderer.with_translation(translation, |renderer| {
|
||||
image::Renderer::draw(
|
||||
renderer,
|
||||
self.handle.clone(),
|
||||
Rectangle {
|
||||
x: bounds.x,
|
||||
y: bounds.y,
|
||||
..Rectangle::with_size(image_size)
|
||||
},
|
||||
)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn hash_layout(&self, state: &mut Hasher) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue