summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2019-04-14 20:03:41 (GMT)
committerculler <culler>2019-04-14 20:03:41 (GMT)
commitf3e5e6b4890075ebe0e19bc7c0ac0d1c4d822e05 (patch)
tree846eeea585a4c73a2ea9b1d8589476ff206aea48
parent26dbe257fa762b649f168a10e5c949b1d185a1f7 (diff)
parent8eec3e9e63a26229b33ad826f232a3a0cceb9851 (diff)
downloadtk-f3e5e6b4890075ebe0e19bc7c0ac0d1c4d822e05.zip
tk-f3e5e6b4890075ebe0e19bc7c0ac0d1c4d822e05.tar.gz
tk-f3e5e6b4890075ebe0e19bc7c0ac0d1c4d822e05.tar.bz2
For Aqua, add systemControlAccentColor; simulate the color for older systems.
-rw-r--r--doc/colors.n1
-rw-r--r--macosx/README29
-rw-r--r--macosx/tkMacOSXColor.c33
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 dd3ab54..7e015b7 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