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

View file

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