Move core::Image::clip_bounds to graphics::Image

This commit is contained in:
Héctor Ramón Jiménez 2025-10-28 19:44:46 +01:00
parent 3cc5bd5dbc
commit 7c11ccb046
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
16 changed files with 189 additions and 88 deletions

View file

@ -337,7 +337,6 @@ pub fn draw<Renderer, Handle>(
renderer.draw_image(
image::Image {
handle: handle.clone(),
clip_bounds: bounds,
border_radius,
filter_method,
rotation: rotation.radians(),
@ -345,6 +344,7 @@ pub fn draw<Renderer, Handle>(
snap: true,
},
drawing_bounds,
bounds,
);
}

View file

@ -314,7 +314,7 @@ where
_style: &renderer::Style,
layout: Layout<'_>,
_cursor: mouse::Cursor,
_viewport: &Rectangle,
viewport: &Rectangle,
) {
let state = tree.state.downcast_ref::<State>();
let bounds = layout.bounds();
@ -348,7 +348,6 @@ where
renderer.draw_image(
Image {
handle: self.handle.clone(),
clip_bounds: Rectangle::INFINITE,
border_radius: border::Radius::default(),
filter_method: self.filter_method,
rotation: Radians(0.0),
@ -356,6 +355,7 @@ where
snap: true,
},
drawing_bounds,
*viewport,
);
});
};

View file

@ -240,25 +240,16 @@ where
let style = theme.style(&self.class, status);
let render = |renderer: &mut Renderer| {
renderer.draw_svg(
svg::Svg {
handle: self.handle.clone(),
color: style.color,
rotation: self.rotation.radians(),
opacity: self.opacity,
},
drawing_bounds,
);
};
if adjusted_fit.width > bounds.width
|| adjusted_fit.height > bounds.height
{
renderer.with_layer(bounds, render);
} else {
render(renderer);
}
renderer.draw_svg(
svg::Svg {
handle: self.handle.clone(),
color: style.color,
rotation: self.rotation.radians(),
opacity: self.opacity,
},
drawing_bounds,
bounds,
);
}
}