Skip to content

Commit 542c140

Browse files
committed
Add custom menu title color to blend better in high contrast mode
In normal contrast mode the background colors of NSMenuItem with custom view are similar to other menu items. But in high contrast mode the colors are slightly lighter/darker than they should be. To workaround the problem, we're using custom-tailored colors for high contrast mode. For normal one they should not be altered at all not to interfer with transaprency in default UI (however, the colors should still be specified for asset so I simply used purple). See #64 (comment) for more details and screenshots in high contrast mode.
1 parent 47bf443 commit 542c140

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"platform" : "osx",
11+
"reference" : "systemPurpleColor"
12+
}
13+
},
14+
{
15+
"idiom" : "universal",
16+
"appearances" : [
17+
{
18+
"appearance" : "luminosity",
19+
"value" : "dark"
20+
}
21+
],
22+
"color" : {
23+
"platform" : "osx",
24+
"reference" : "systemPurpleColor"
25+
}
26+
},
27+
{
28+
"idiom" : "universal",
29+
"appearances" : [
30+
{
31+
"appearance" : "contrast",
32+
"value" : "high"
33+
}
34+
],
35+
"color" : {
36+
"color-space" : "display-p3",
37+
"components" : {
38+
"red" : "0.965",
39+
"alpha" : "1.000",
40+
"blue" : "0.965",
41+
"green" : "0.965"
42+
}
43+
}
44+
},
45+
{
46+
"idiom" : "universal",
47+
"appearances" : [
48+
{
49+
"appearance" : "luminosity",
50+
"value" : "dark"
51+
},
52+
{
53+
"appearance" : "contrast",
54+
"value" : "high"
55+
}
56+
],
57+
"color" : {
58+
"color-space" : "display-p3",
59+
"components" : {
60+
"red" : "0.216",
61+
"alpha" : "1.000",
62+
"blue" : "0.216",
63+
"green" : "0.216"
64+
}
65+
}
66+
}
67+
]
68+
}

Maccy/FilterMenuItemView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ class FilterMenuItemView: NSView, NSTextFieldDelegate {
121121
}
122122
}
123123

124+
override func draw(_ dirtyRect: NSRect) {
125+
super.draw(dirtyRect)
126+
if NSWorkspace.shared.accessibilityDisplayShouldIncreaseContrast {
127+
NSColor(named: "MenuColor")?.setFill()
128+
dirtyRect.fill()
129+
}
130+
}
131+
124132
// Process query when search field was focused (i.e. user clicked on it).
125133
func controlTextDidChange(_ obj: Notification) {
126134
fireNotification()

0 commit comments

Comments
 (0)