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,7 +388,11 @@ 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>(
renderer,
bounds,
&styling,
|renderer, _styling| {
self.content.as_widget().draw( self.content.as_widget().draw(
&tree.children[0], &tree.children[0],
renderer, renderer,
@ -402,7 +406,9 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
cursor, cursor,
&bounds, &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,6 +821,7 @@ 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.
if is_image {
renderer.fill_quad( renderer.fill_quad(
renderer::Quad { renderer::Quad {
bounds, bounds,
@ -826,6 +834,7 @@ pub fn draw<Renderer: iced_core::Renderer, Theme>(
}, },
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()
}, },