From c2d76ae4a48ea319f88ee98cf01dfa111dbd3e78 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 20 Mar 2019 15:15:59 +0000 Subject: Fix text layout issue for ttk::button by setting minWidth to 0. Button text was not being centered as requested by -anchor center. --- library/ttk/aquaTheme.tcl | 3 +-- macosx/ttkMacOSXTheme.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl index 182af76..f83a710 100644 --- a/library/ttk/aquaTheme.tcl +++ b/library/ttk/aquaTheme.tcl @@ -26,8 +26,7 @@ namespace eval ttk::theme::aqua { !focus systemDialogActiveText} # Buttons -# ttk::style configure TButton -anchor center -width -6 \ - ttk::style configure TButton -anchor center \ + ttk::style configure TButton -anchor center -width -6 \ -foreground systemControlTextColor ttk::style map TButton \ -foreground { diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index f1281c2..4fd506b 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -814,12 +814,19 @@ static void ButtonElementMinSize( /* * The theme height does not include the 1-pixel border around * the button, although it does include the 1-pixel shadow at - * the bottom. The corner radius is 4, so 8 is a reasonable - * minimum width. + * the bottom. */ *minHeight += 2; - *minWidth = 8; + + /* + * The minwidth must be 0 to force the generic ttk code to compute + * the correct text layout. For example, a non-zero value will cause the + * text to be left justified, no matter what -anchor setting is used + * in the style. + */ + + *minWidth = 0; } } -- cgit v0.12