Tk Source Code

Check-in [990a4e5d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Adapt systemSelectedTabTextColor to Big Sur.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-6-branch
Files: files | file ages | folders
SHA3-256: 990a4e5dc1517c663c8a6e9ae9c5f1c986e3a77951c21cc556dec59c756d0f88
User & Date: culler 2020-08-19 13:56:47
References
2021-03-19
14:02 Ticket [37de44d7] macOS background color ttk::notebook status still Open with 3 other changes artifact: 08ddfc0e user: chrstphrchvz
2020-09-06
18:00 New ticket [4e1e2907] Aqua: ttk::notebook yellow selected tab text. artifact: 2d6222c9 user: chrstphrchvz
Context
2020-08-19
20:24
Fix [031dfcf1dd]: ttk::treeview -anchor does not work with column #0. The focus ring of selected items of ttk::treeview disappears in the process. Also, clarify the layout (pack-like) algorithm, and simplify the code by not specifying option values that are anyway the default. Finally, remove documentation of the non-implemented TTK_STICK_ALL flag. check-in: 8e52d751 user: fvogel tags: core-8-6-branch
15:34
Merge 8.6 check-in: 78da20aa user: jan.nijtmans tags: tip-581
13:56
Adapt systemSelectedTabTextColor to Big Sur. check-in: 990a4e5d user: culler tags: core-8-6-branch
2020-08-18
09:33
Merge 8.5 check-in: 1eda8ea7 user: jan.nijtmans tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to macosx/tkMacOSXColor.c.

19
20
21
22
23
24
25

26
27
28
29
30
31
32
#include "tkColor.h"
#include "tkMacOSXColor.h"

static Tcl_HashTable systemColors;
static int numSystemColors;
static int rgbColorIndex;
static int controlAccentIndex;

static Bool useFakeAccentColor = NO;
static SystemColorDatum **systemColorIndex;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
static NSAppearance *lightAqua = nil;
static NSAppearance *darkAqua = nil;
#endif
static NSColorSpace* sRGB = NULL;







>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "tkColor.h"
#include "tkMacOSXColor.h"

static Tcl_HashTable systemColors;
static int numSystemColors;
static int rgbColorIndex;
static int controlAccentIndex;
static int selectedTabTextIndex;
static Bool useFakeAccentColor = NO;
static SystemColorDatum **systemColorIndex;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400
static NSAppearance *lightAqua = nil;
static NSAppearance *darkAqua = nil;
#endif
static NSColorSpace* sRGB = NULL;
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
	    NSString *colorName = [[NSString alloc]
				   initWithCString:entry->macName
					  encoding:NSUTF8StringEncoding];
	    SEL colorSelector = NSSelectorFromString(colorName);
	    if (![NSColor respondsToSelector:colorSelector]) {
		if ([colorName isEqualToString:@"controlAccentColor"]) {
		    useFakeAccentColor = YES;
		} else {
		    /* Uncomment to print all unsupported colors:              */
		    /* printf("Unsupported color %s\n", colorName.UTF8String); */
		    continue;
		}
	    }
	    entry->selector = [colorName retain];
	}







|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	    NSString *colorName = [[NSString alloc]
				   initWithCString:entry->macName
					  encoding:NSUTF8StringEncoding];
	    SEL colorSelector = NSSelectorFromString(colorName);
	    if (![NSColor respondsToSelector:colorSelector]) {
		if ([colorName isEqualToString:@"controlAccentColor"]) {
		    useFakeAccentColor = YES;
		} else if (![colorName isEqualToString:@"selectedTabTextColor"]) {
		    /* Uncomment to print all unsupported colors:              */
		    /* printf("Unsupported color %s\n", colorName.UTF8String); */
		    continue;
		}
	    }
	    entry->selector = [colorName retain];
	}
139
140
141
142
143
144
145



146
147
148
149
150
151
152

    hPtr = Tcl_FindHashEntry(&systemColors, "Pixel");
    entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
    rgbColorIndex = entry->index;
    hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor");
    entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
    controlAccentIndex = entry->index;



    [pool drain];
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXRGBPixel --







>
>
>







140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

    hPtr = Tcl_FindHashEntry(&systemColors, "Pixel");
    entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
    rgbColorIndex = entry->index;
    hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor");
    entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
    controlAccentIndex = entry->index;
    hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor");
    entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr);
    selectedTabTextIndex = entry->index;
    [pool drain];
}

/*
 *----------------------------------------------------------------------
 *
 * TkMacOSXRGBPixel --
310
311
312
313
314
315
316

317
318




319


320


321
322
323
324
325
326
327
	}
	break;
    case semantic:
	if (entry->index == controlAccentIndex && useFakeAccentColor) {
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101500
	    color = [[NSColor colorForControlTint: [NSColor currentControlTint]]
			      colorUsingColorSpace:sRGB];

#endif
	} else {




	    color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB];


	}


	[color getComponents: rgba];
	break;
    case clearColor:
	rgba[3] = 0;
    case HIText:
#ifdef __LP64__
	color = [[NSColor textColor] colorUsingColorSpace:sRGB];







>

|
>
>
>
>
|
>
>
|
>
>







314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
	}
	break;
    case semantic:
	if (entry->index == controlAccentIndex && useFakeAccentColor) {
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101500
	    color = [[NSColor colorForControlTint: [NSColor currentControlTint]]
			      colorUsingColorSpace:sRGB];
	    [color getComponents: rgba];
#endif
	    break;
	}
	if (entry->index == selectedTabTextIndex) {
	    int OSVersion = [NSApp macOSVersion];
	    if (OSVersion > 100600 && OSVersion < 110000) {
		color = [NSColor whiteColor];
		[color getComponents: rgba];
		break;
	    }
	}
	color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB];
	[color getComponents: rgba];
	break;
    case clearColor:
	rgba[3] = 0;
    case HIText:
#ifdef __LP64__
	color = [[NSColor textColor] colorUsingColorSpace:sRGB];

Changes to macosx/tkMacOSXColor.h.

237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{"WindowBackgroundColor3",	    ttkBackground, 3, NULL, 0, NULL },
{"WindowBackgroundColor4",	    ttkBackground, 4, NULL, 0, NULL },
{"WindowBackgroundColor5",	    ttkBackground, 5, NULL, 0, NULL },
{"WindowBackgroundColor6",	    ttkBackground, 6, NULL, 0, NULL },
{"WindowBackgroundColor7",	    ttkBackground, 7, NULL, 0, NULL },
/* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */
{"SecondaryLabelColor",		    ttkBackground, 14, NULL, 0, NULL },
/* Color to use for notebook tab labels. */
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1060
{"SelectedTabTextColor",	    semantic, 0, "whiteColor", 0, NULL },
#else
{"SelectedTabTextColor",	    semantic, 0, "blackColor", 0, NULL },
#endif
/* Semantic colors that we simulate on older systems which don't supoort them. */
{"ControlAccentColor",		    semantic, 0, "controlAccentColor", 0, NULL },
{"LabelColor",                      semantic, 0, "blackColor", 0, NULL },
{"LinkColor",			    semantic, 0, "blueColor", 0, NULL },
{"PlaceholderTextColor",	    semantic, 0, "grayColor", 0, NULL },
{"SeparatorColor",		    semantic, 0, "grayColor", 0, NULL },
{NULL,				    0, 0, NULL, 0, NULL }







|
<
|
<
<
<







237
238
239
240
241
242
243
244

245



246
247
248
249
250
251
252
{"WindowBackgroundColor3",	    ttkBackground, 3, NULL, 0, NULL },
{"WindowBackgroundColor4",	    ttkBackground, 4, NULL, 0, NULL },
{"WindowBackgroundColor5",	    ttkBackground, 5, NULL, 0, NULL },
{"WindowBackgroundColor6",	    ttkBackground, 6, NULL, 0, NULL },
{"WindowBackgroundColor7",	    ttkBackground, 7, NULL, 0, NULL },
/* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */
{"SecondaryLabelColor",		    ttkBackground, 14, NULL, 0, NULL },
/* Color to use for notebook tab labels -- depends on OS version. */

{"SelectedTabTextColor",	    semantic, 0, "textColor", 0, NULL },



/* Semantic colors that we simulate on older systems which don't supoort them. */
{"ControlAccentColor",		    semantic, 0, "controlAccentColor", 0, NULL },
{"LabelColor",                      semantic, 0, "blackColor", 0, NULL },
{"LinkColor",			    semantic, 0, "blueColor", 0, NULL },
{"PlaceholderTextColor",	    semantic, 0, "grayColor", 0, NULL },
{"SeparatorColor",		    semantic, 0, "grayColor", 0, NULL },
{NULL,				    0, 0, NULL, 0, NULL }