From 8412dd593913b85618ec30e8b92a58aaa0ad6bb8 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Wed, 13 Aug 2025 21:39:29 +0200 Subject: [PATCH] fix(image_button): improve rendering of selected image buttons --- src/widget/button/widget.rs | 42 +++---------------------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/src/widget/button/widget.rs b/src/widget/button/widget.rs index da8612f7..3f5a1fdf 100644 --- a/src/widget/button/widget.rs +++ b/src/widget/button/widget.rs @@ -521,27 +521,6 @@ impl<'a, Message: 'a + Clone> Widget let c_rad = THEME.lock().unwrap().cosmic().corner_radii; - // NOTE: Workaround to round the border of the unselected, unhovered image. - if !self.selected && !is_mouse_over { - let mut bounds = bounds; - bounds.x -= 2.0; - bounds.y -= 2.0; - bounds.width += 4.0; - bounds.height += 4.0; - renderer.fill_quad( - renderer::Quad { - bounds, - border: Border { - width: 2.0, - color: crate::theme::active().current_container().base.into(), - radius: 9.0.into(), - }, - shadow: Shadow::default(), - }, - Color::TRANSPARENT, - ); - } - if self.selected { renderer.fill_quad( Quad { @@ -961,25 +940,10 @@ pub fn draw( let mut clipped_bounds = viewport_bounds.intersection(&bounds).unwrap_or_default(); clipped_bounds.height += styling.border_width; + clipped_bounds.width += 1.0; + // Finish by drawing the border above the contents. renderer.with_layer(clipped_bounds, |renderer| { - // NOTE: Workaround to round the border of the hovered/selected image. - 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(), - }, - Color::TRANSPARENT, - ); - } - - // Finish by drawing the border above the contents. renderer.fill_quad( renderer::Quad { bounds, @@ -992,7 +956,7 @@ pub fn draw( }, Color::TRANSPARENT, ); - }); + }) } else { draw_contents(renderer, styling); }