fix: border artifacts in button and input

This commit is contained in:
Ashley Wulber 2024-06-15 16:04:42 -04:00 committed by GitHub
parent 80b7049584
commit 33eec39268
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 26 deletions

View file

@ -388,21 +388,27 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
text_color.a = alpha;
}
draw::<_, crate::Theme>(renderer, bounds, &styling, |renderer, _styling| {
self.content.as_widget().draw(
&tree.children[0],
renderer,
theme,
&renderer::Style {
icon_color,
text_color,
scale_factor: renderer_style.scale_factor,
},
content_layout,
cursor,
&bounds,
);
});
draw::<_, crate::Theme>(
renderer,
bounds,
&styling,
|renderer, _styling| {
self.content.as_widget().draw(
&tree.children[0],
renderer,
theme,
&renderer::Style {
icon_color,
text_color,
scale_factor: renderer_style.scale_factor,
},
content_layout,
cursor,
&bounds,
);
},
matches!(self.variant, Variant::Image { .. }),
);
if let Variant::Image {
close_icon,
@ -744,6 +750,7 @@ pub fn draw<Renderer: iced_core::Renderer, Theme>(
bounds: Rectangle,
styling: &super::style::Appearance,
draw_contents: impl FnOnce(&mut Renderer, &Appearance),
is_image: bool,
) where
Theme: super::style::StyleSheet,
{
@ -814,18 +821,20 @@ pub fn draw<Renderer: iced_core::Renderer, Theme>(
renderer.with_layer(clipped_bounds, |renderer| {
// NOTE: Workaround to round the border of the hovered/selected image.
renderer.fill_quad(
renderer::Quad {
bounds,
border: Border {
width: styling.border_width,
color: crate::theme::active().current_container().base.into(),
radius: 0.0.into(),
if is_image {
renderer.fill_quad(
renderer::Quad {
bounds,
border: Border {
width: styling.border_width,
color: crate::theme::active().current_container().base.into(),
radius: 0.0.into(),
},
shadow: Shadow::default(),
},
shadow: Shadow::default(),
},
Color::TRANSPARENT,
);
Color::TRANSPARENT,
);
}
// Finish by drawing the border above the contents.
renderer.fill_quad(

View file

@ -2071,6 +2071,7 @@ pub fn draw<'a, Message>(
renderer::Quad {
bounds,
border: Border {
radius: appearance.border_radius,
width: appearance.border_width,
..Default::default()
},