Skip to content

Commit 6e1489e

Browse files
committed
Add Mojave-style tabs, which also supports Dark Mode
Add a new tab style "Mojave". The files were copied from Yosemite-style tabs but with additional improvements. It now reads the colors from an asset catalog with colors for both dark and light modes. The colors and style are also retuned to look more like native Mojave tabs. The new tab and close tab buttons are now using a style much more similar to what native macOS are like, with the close tab button showing up when mouse is hovering over a particular tab. Reason for cloning PSMYosemiteTabStyle is to avoid having too many special cases in a single file and to avoid breaking its behaviors on older systems. Also, PSMTabBarControl is mostly a dead project, so it's wise to modify existing code as little as possible. MacVim will only use this style if it's compiled with Mojave SDKs and it's actually being run in Mojave (10.14) or higher. Fix macvim-dev#775
1 parent 007de99 commit 6e1489e

File tree

17 files changed

+473
-55
lines changed

17 files changed

+473
-55
lines changed

src/MacVim/MMVimView.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,18 @@ - (MMVimView *)initWithFrame:(NSRect)frame
125125
[tabBarControl setDelegate:self];
126126
[tabBarControl setHidden:YES];
127127

128-
if (shouldUseYosemiteTabBarStyle()) {
128+
if (shouldUseYosemiteTabBarStyle() || shouldUseMojaveTabBarStyle()) {
129129
CGFloat screenWidth = [[NSScreen mainScreen] frame].size.width;
130130
int tabMaxWidth = [ud integerForKey:MMTabMaxWidthKey];
131131
if (tabMaxWidth == 0)
132132
tabMaxWidth = screenWidth;
133133
int tabOptimumWidth = [ud integerForKey:MMTabOptimumWidthKey];
134134
if (tabOptimumWidth == 0)
135135
tabOptimumWidth = screenWidth;
136+
137+
NSString* tabStyleName = shouldUseMojaveTabBarStyle() ? @"Mojave" : @"Yosemite";
136138

137-
[tabBarControl setStyleNamed:@"Yosemite"];
139+
[tabBarControl setStyleNamed:tabStyleName];
138140
[tabBarControl setCellMinWidth:[ud integerForKey:MMTabMinWidthKey]];
139141
[tabBarControl setCellMaxWidth:tabMaxWidth];
140142
[tabBarControl setCellOptimumWidth:tabOptimumWidth];

src/MacVim/MacVim.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#ifndef MAC_OS_X_VERSION_10_12_2
3333
# define MAC_OS_X_VERSION_10_12_2 101202
3434
#endif
35+
#ifndef MAC_OS_X_VERSION_10_14
36+
# define MAC_OS_X_VERSION_10_14 101400
37+
#endif
3538

3639
#ifndef NSAppKitVersionNumber10_10
3740
# define NSAppKitVersionNumber10_10 1343

src/MacVim/Miscellaneous.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,4 @@ NSArray *normalizeFilenames(NSArray *filenames);
155155

156156

157157
BOOL shouldUseYosemiteTabBarStyle();
158+
BOOL shouldUseMojaveTabBarStyle();

src/MacVim/Miscellaneous.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,4 +305,14 @@ - (NSInteger)tag
305305
shouldUseYosemiteTabBarStyle()
306306
{
307307
return floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_10;
308+
}
309+
BOOL
310+
shouldUseMojaveTabBarStyle()
311+
{
312+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
313+
if (@available(macos 10.14, *)) {
314+
return true;
315+
}
316+
#endif
317+
return false;
308318
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "189",
13+
"alpha" : "1.000",
14+
"blue" : "188",
15+
"green" : "189"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "40",
31+
"alpha" : "1.000",
32+
"blue" : "42",
33+
"green" : "40"
34+
}
35+
}
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "168",
13+
"alpha" : "1.000",
14+
"blue" : "168",
15+
"green" : "168"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "36",
31+
"alpha" : "1.000",
32+
"blue" : "39",
33+
"green" : "37"
34+
}
35+
}
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "209",
13+
"alpha" : "1.000",
14+
"blue" : "208",
15+
"green" : "209"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "54",
31+
"alpha" : "1.000",
32+
"blue" : "57",
33+
"green" : "55"
34+
}
35+
}
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "221",
13+
"alpha" : "1.000",
14+
"blue" : "221",
15+
"green" : "221"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "30",
31+
"alpha" : "1.000",
32+
"blue" : "33",
33+
"green" : "31"
34+
}
35+
}
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "198",
13+
"alpha" : "1.000",
14+
"blue" : "198",
15+
"green" : "198"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "27",
31+
"alpha" : "1.000",
32+
"blue" : "30",
33+
"green" : "28"
34+
}
35+
}
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "246",
13+
"alpha" : "1.000",
14+
"blue" : "246",
15+
"green" : "246"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "43",
31+
"alpha" : "1.000",
32+
"blue" : "47",
33+
"green" : "45"
34+
}
35+
}
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "169",
13+
"alpha" : "1.000",
14+
"blue" : "169",
15+
"green" : "169"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "96",
31+
"alpha" : "1.000",
32+
"blue" : "99",
33+
"green" : "97"
34+
}
35+
}
36+
}
37+
]
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
},
6+
"colors" : [
7+
{
8+
"idiom" : "universal",
9+
"color" : {
10+
"color-space" : "srgb",
11+
"components" : {
12+
"red" : "210",
13+
"alpha" : "1.000",
14+
"blue" : "210",
15+
"green" : "210"
16+
}
17+
}
18+
},
19+
{
20+
"idiom" : "universal",
21+
"appearances" : [
22+
{
23+
"appearance" : "luminosity",
24+
"value" : "dark"
25+
}
26+
],
27+
"color" : {
28+
"color-space" : "srgb",
29+
"components" : {
30+
"red" : "73",
31+
"alpha" : "1.000",
32+
"blue" : "77",
33+
"green" : "74"
34+
}
35+
}
36+
}
37+
]
38+
}

0 commit comments

Comments
 (0)