diff options
author | culler <culler> | 2019-04-14 20:01:55 (GMT) |
---|---|---|
committer | culler <culler> | 2019-04-14 20:01:55 (GMT) |
commit | 8eec3e9e63a26229b33ad826f232a3a0cceb9851 (patch) | |
tree | 30d2fc2fe8019073873fb3304480fa9fc951faeb | |
parent | a231332e57a1d87c18d3e76889cc32749851f591 (diff) | |
download | tk-8eec3e9e63a26229b33ad826f232a3a0cceb9851.zip tk-8eec3e9e63a26229b33ad826f232a3a0cceb9851.tar.gz tk-8eec3e9e63a26229b33ad826f232a3a0cceb9851.tar.bz2 |
For Aqua, add systemControlAccentColor; simulate the color for older systems.
-rw-r--r-- | doc/colors.n | 1 | ||||
-rw-r--r-- | macosx/README | 29 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.c | 33 |
3 files changed, 48 insertions, 15 deletions
diff --git a/doc/colors.n b/doc/colors.n index 18f73b7..41d6ed0 100644 --- a/doc/colors.n +++ b/doc/colors.n @@ -939,6 +939,7 @@ contrasting background. Each numbered color constrasts with its predecessor. .RS .DS +systemControlAccentColor systemControlTextColor systemDisabledControlTextColor systemLabelColor diff --git a/macosx/README b/macosx/README index 12a7117..fd54c2d 100644 --- a/macosx/README +++ b/macosx/README @@ -289,19 +289,22 @@ window. --------------------------------------- With the release of OSX 10.14 (Mojave), Apple introduced the DarkAqua -appearance. Part of the implementation of the Dark Mode was to make some of -the named NSColors have dynamic values. Apple calls these "semantic colors" -because the name does not specify a specific color, but rather refers to the -context in which the color should be used. Tk now provides the following -semantic colors as system colors: systemTextColor, systemTextBackgroundColor, -systemSelectedTextColor, systemSelectedTextBackgroundColor, -systemControlTextColor, systemDisabledControlTextColor, and systemLabelColor. -All of these except systemLabelColor, which was introduced in 10.10, were -present in OSX 10.0. The change in 10.14 was that the RGB color value of these -colors became dynamic, meaning that the color value can change when the -application appearance changes. In particular, when a user selects Dark Mode -in the system preferences these colors change appearance. For example -systemTextColor is dark in Aqua and light in DarkAqua. +appearance. Part of the implementation of the Dark Mode was to make +some of the named NSColors have dynamic values. Apple calls these +"semantic colors" because the name does not specify a specific color, +but rather refers to the context in which the color should be used. +Tk now provides the following semantic colors as system colors: +systemTextColor, systemTextBackgroundColor, systemSelectedTextColor, +systemSelectedTextBackgroundColor, systemControlTextColor, +systemDisabledControlTextColor, systemLabelColor and +systemControlAccentColor. All of these except the last two were +present in OSX 10.0 (and those two are simulated in systems where they +do not exist). The change in 10.14 was that the RGB color value of +these colors became dynamic, meaning that the color value can change +when the application appearance changes. In particular, when a user +selects Dark Mode in the system preferences these colors change +appearance. For example systemTextColor is dark in Aqua and light in +DarkAqua. The default background and foreground colors of most of the Tk widgets have been set to semantic colors, which means that the widgets will change diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index a368e8c..3885a77 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -189,6 +189,11 @@ static const struct SystemColorMapEntry systemColorMap[] = { { "ListViewWindowHeaderBackground", HIBackground, kThemeBackgroundListViewWindowHeader }, /* 163 */ { "SecondaryGroupBoxBackground", HIBackground, kThemeBackgroundSecondaryGroupBox }, /* 164 */ { "MetalBackground", HIBackground, kThemeBackgroundMetal }, /* 165 */ + + /* + * Colors based on "semantic" NSColors. + */ + { "WindowBackgroundColor", ttkBackground, 0 }, /* 166 */ { "WindowBackgroundColor1", ttkBackground, 1 }, /* 167 */ { "WindowBackgroundColor2", ttkBackground, 2 }, /* 168 */ @@ -204,10 +209,11 @@ static const struct SystemColorMapEntry systemColorMap[] = { { "DisabledControlTextColor", semantic, 4 }, /* 178 */ { "TextBackgroundColor", semantic, 5 }, /* 179 */ { "SelectedTextBackgroundColor", semantic, 6 }, /* 180 */ + { "ControlAccentColor", semantic, 7 }, /* 181 */ { NULL, 0, 0 } }; #define FIRST_SEMANTIC_COLOR 166 -#define MAX_PIXELCODE 180 +#define MAX_PIXELCODE 181 /* *---------------------------------------------------------------------- @@ -258,6 +264,8 @@ GetEntryFromPixelCode( */ static NSColorSpace* deviceRGB = NULL; +static CGFloat blueAccentRGBA[4] = {0, 122.0/255, 1.0, 1.0}; +static CGFloat graphiteAccentRGBA[4] = {152.0/255, 152.0/255, 152.0/255, 1.0}; static OSStatus SetCGColorComponents( @@ -268,6 +276,7 @@ SetCGColorComponents( OSStatus err = noErr; NSColor *bgColor, *color; CGFloat rgba[4] = {0, 0, 0, 1}; + NSInteger colorVariant = 1; if (!deviceRGB) { deviceRGB = [NSColorSpace deviceRGBColorSpace]; } @@ -337,12 +346,32 @@ SetCGColorComponents( color = [[NSColor selectedTextBackgroundColor] colorUsingColorSpace: deviceRGB]; break; + case 7: + if ([NSApp macMinorVersion] < 14) { + colorVariant = [[NSUserDefaults standardUserDefaults] + integerForKey:@"AppleAquaColorVariant"]; + if (colorVariant == 6) { + color = [NSColor colorWithColorSpace: deviceRGB + components: graphiteAccentRGBA + count: 4]; + } else { + color = [NSColor colorWithColorSpace: deviceRGB + components: blueAccentRGBA + count: 4]; + } + } else { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 + color = [[NSColor controlAccentColor] colorUsingColorSpace: + deviceRGB]; +#endif + } + break; default: if ([NSApp macMinorVersion] < 10) { color = [[NSColor textColor] colorUsingColorSpace: deviceRGB]; } else { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 color = [[NSColor labelColor] colorUsingColorSpace: deviceRGB]; #endif |