From 37bb1ca906e8d0e3bccadcc5aa71067ae6aa7633 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 10 Jul 2023 14:32:30 +0000 Subject: Update to striped background on Aqua with semantic colors - patch from Christopher Chavez --- library/ttk/aquaTheme.tcl | 8 ++------ macosx/tkMacOSXColor.c | 14 ++++++++++++++ macosx/tkMacOSXColor.h | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl index 5674d39..06b8769 100644 --- a/library/ttk/aquaTheme.tcl +++ b/library/ttk/aquaTheme.tcl @@ -151,8 +151,8 @@ namespace eval ttk::theme::aqua { -foreground systemTextColor \ -background systemWindowBackgroundColor ttk::style configure Treeview -rowheight 18 \ - -background systemTextBackgroundColor \ - -stripedbackground #F5F5F6 \ + -background systemControlBackgroundColor \ + -stripedbackground systemControlAlternatingRowColor \ -foreground systemTextColor \ -fieldbackground systemTextBackgroundColor ttk::style map Treeview \ @@ -160,10 +160,6 @@ namespace eval ttk::theme::aqua { selected systemSelectedTextBackgroundColor } - #improved appearance for stripebackground - bind all <> {+ ttk::style configure Treeview -stripedbackground black} - bind all <> {+ ttk::style configure Treeview -stripedbackground #F5F5F6} - # Enable animation for ttk::progressbar widget: ttk::style configure TProgressbar -period 100 -maxphase 120 diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 2d481f9..e383a94 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -23,6 +23,7 @@ static Tcl_HashTable systemColors; static size_t numSystemColors; static size_t rgbColorIndex; static size_t controlAccentIndex; +static size_t controlAlternatingRowIndex; static size_t selectedTabTextIndex; static size_t pressedButtonTextIndex; static Bool useFakeAccentColor = NO; @@ -71,6 +72,7 @@ void initColorTable() if ([colorName isEqualToString:@"controlAccentColor"]) { useFakeAccentColor = YES; } else if ( ![colorName isEqualToString:@"selectedTabTextColor"] + && ![colorName isEqualToString:@"controlAlternatingRowColor"] && ![colorName isEqualToString:@"pressedButtonTextColor"]) { /* Uncomment to print all unsupported colors: */ /* printf("Unsupported color %s\n", colorName.UTF8String); */ @@ -148,6 +150,9 @@ void initColorTable() hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); controlAccentIndex = entry->index; + hPtr = Tcl_FindHashEntry(&systemColors, "ControlAlternatingRowColor"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + controlAlternatingRowIndex = entry->index; hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); selectedTabTextIndex = entry->index; @@ -332,6 +337,15 @@ GetRGBA( color = [[NSColor colorForControlTint: [NSColor currentControlTint]] colorUsingColorSpace:sRGB]; #endif + } else if (entry->index == controlAlternatingRowIndex) { + /* + * Color which is now called alternatingContentBackgroundColor on 10.14. + * Taken from NSColor.controlAlternatingRowBackgroundColors (which was + * replaced by NSColor.alternatingContentBackgroundColors on 10.14). + */ + color = [[NSColor colorWithCatalogName:@"System" + colorName:@"controlAlternatingRowColor"] + colorUsingColorSpace:sRGB]; } else if (entry->index == selectedTabTextIndex) { if (OSVersion > 100600 && OSVersion < 110000) { color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index 77f1558..ab5a3b4 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -187,6 +187,8 @@ static SystemColorDatum systemColorData[] = { {"PlaceholderTextColor", semantic, 0, "grayColor", 0, NULL }, {"SeparatorColor", semantic, 0, "grayColor", 0, NULL }, {"UnemphasizedSelectedTextBackgroundColor", semantic, 0, "grayColor", 0, NULL }, +/* This color is available since 10.3, so the fallback is unused */ +{"ControlAlternatingRowColor", semantic, 0, "grayColor" , 0, NULL }, {NULL, rgbColor, 0, NULL, 0, NULL } }; -- cgit v0.12