From 57ed0982f5b413783069ddadf128357551d956f9 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Sat, 16 Nov 2024 14:30:10 -0800 Subject: [PATCH] Draw focus on transparent buttons with no padding Closes #209 --- src/widgets/button.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/widgets/button.rs b/src/widgets/button.rs index 84e45ee0b..6490085b0 100644 --- a/src/widgets/button.rs +++ b/src/widgets/button.rs @@ -399,8 +399,10 @@ impl Widget for Button { } .with_alpha(128); - let inset = (context.get(&IntrinsicPadding).into_px(context.gfx.scale()) - - outline_options.line_width) + let inset = context + .get(&IntrinsicPadding) + .into_px(context.gfx.scale()) + .min(outline_options.line_width) / 2; let options = outline_options.colored(color); @@ -506,10 +508,16 @@ impl Widget for Button { available_space: Size, context: &mut LayoutContext<'_, '_, '_, '_>, ) -> Size { + let outline_width = context + .get(&OutlineWidth) + .into_upx(context.gfx.scale()) + .ceil(); let padding = context .get(&IntrinsicPadding) .into_upx(context.gfx.scale()) - .round(); + .round() + .max(outline_width); + let double_padding = padding * 2; let mounted = self.content.mounted(context); let available_space = available_space.map(|space| space - double_padding);