Skip to content

Commit 7cdd910

Browse files
committed
Merge pull request #193 from macvim-dev/feature/yosemite-tab-style
Yosemite Tab Style based of b4winckler/macvim#45
2 parents 2791ea7 + 24d55e3 commit 7cdd910

13 files changed

+596
-48
lines changed

src/MacVim/MMFullScreenWindow.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ - (void)enterFullScreen
155155
[[target windowController] setWindow:self];
156156

157157
oldTabBarStyle = [[view tabBarControl] styleName];
158-
[[view tabBarControl] setStyleNamed:@"Unified"];
158+
159+
NSString *style;
160+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
161+
style = @"Yosemite";
162+
#else
163+
style = @"Unified";
164+
#endif
165+
[[view tabBarControl] setStyleNamed:style];
159166

160167
// add text view
161168
oldPosition = [view frame].origin;

src/MacVim/MMVimView.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ - (MMVimView *)initWithFrame:(NSRect)frame
115115

116116
// Create the tab bar control (which is responsible for actually
117117
// drawing the tabline and tabs).
118-
NSRect tabFrame = { { 0, frame.size.height - 22 },
119-
{ frame.size.width, 22 } };
118+
NSRect tabFrame = { { 0, frame.size.height - kPSMTabBarControlHeight },
119+
{ frame.size.width, kPSMTabBarControlHeight } };
120120
tabBarControl = [[PSMTabBarControl alloc] initWithFrame:tabFrame];
121121

122122
[tabView setDelegate:tabBarControl];
@@ -125,10 +125,18 @@ - (MMVimView *)initWithFrame:(NSRect)frame
125125
[tabBarControl setDelegate:self];
126126
[tabBarControl setHidden:YES];
127127

128+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
129+
CGFloat screenWidth = [[NSScreen mainScreen] frame].size.width;
130+
[tabBarControl setStyleNamed:@"Yosemite"];
131+
[tabBarControl setCellMinWidth:120];
132+
[tabBarControl setCellMaxWidth:screenWidth];
133+
[tabBarControl setCellOptimumWidth:screenWidth];
134+
#else
128135
[tabBarControl setCellMinWidth:[ud integerForKey:MMTabMinWidthKey]];
129136
[tabBarControl setCellMaxWidth:[ud integerForKey:MMTabMaxWidthKey]];
130137
[tabBarControl setCellOptimumWidth:
131138
[ud integerForKey:MMTabOptimumWidthKey]];
139+
#endif
132140

133141
[tabBarControl setShowAddTabButton:[ud boolForKey:MMShowAddTabButtonKey]];
134142
[[tabBarControl addTabButton] setTarget:self];

src/MacVim/MMWindowController.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@
8080
#define FUOPT_BGCOLOR_HLGROUP 0x004
8181

8282

83+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
84+
# define TABBAR_STYLE_UNIFINED @"Yosemite"
85+
# define TABBAR_STYLE_METAL @"Yosemite"
86+
#else
87+
# define TABBAR_STYLE_UNIFINED @"Unified"
88+
# define TABBAR_STYLE_METAL @"Metal"
89+
#endif
90+
8391

8492
@interface MMWindowController (Private)
8593
- (NSSize)contentSize;
@@ -1173,7 +1181,7 @@ - (void)window:(NSWindow *)window
11731181
[[window animator] setAlphaValue:0];
11741182
} completionHandler:^{
11751183
[window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
1176-
[[vimView tabBarControl] setStyleNamed:@"Unified"];
1184+
[[vimView tabBarControl] setStyleNamed:TABBAR_STYLE_UNIFINED];
11771185
[self updateTablineSeparator];
11781186

11791187
// Stay dark for some time to wait for things to sync, then do the full screen operation
@@ -1234,7 +1242,7 @@ - (void)windowDidFailToEnterFullScreen:(NSWindow *)window
12341242
fullScreenEnabled = NO;
12351243
[window setAlphaValue:1];
12361244
[window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
1237-
[[vimView tabBarControl] setStyleNamed:@"Metal"];
1245+
[[vimView tabBarControl] setStyleNamed:TABBAR_STYLE_METAL];
12381246
[self updateTablineSeparator];
12391247
[window setFrame:preFullScreenFrame display:YES];
12401248
}
@@ -1264,7 +1272,7 @@ - (void)window:(NSWindow *)window
12641272
[[window animator] setAlphaValue:0];
12651273
} completionHandler:^{
12661274
[window setStyleMask:([window styleMask] & ~NSFullScreenWindowMask)];
1267-
[[vimView tabBarControl] setStyleNamed:@"Metal"];
1275+
[[vimView tabBarControl] setStyleNamed:TABBAR_STYLE_METAL];
12681276
[self updateTablineSeparator];
12691277
[window setFrame:preFullScreenFrame display:YES];
12701278

@@ -1309,7 +1317,7 @@ - (void)windowDidFailToExitFullScreen:(NSWindow *)window
13091317
fullScreenEnabled = YES;
13101318
[window setAlphaValue:1];
13111319
[window setStyleMask:([window styleMask] | NSFullScreenWindowMask)];
1312-
[[vimView tabBarControl] setStyleNamed:@"Unified"];
1320+
[[vimView tabBarControl] setStyleNamed:TABBAR_STYLE_UNIFINED];
13131321
[self updateTablineSeparator];
13141322
[self maximizeWindow:fullScreenOptions];
13151323
}

src/MacVim/PSMTabBarControl/PSMTabBarControl.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
52C0B9B515BDB7A9000C268F /* overflowImagePressed@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 52C0B9B315BDB7A9000C268F /* overflowImagePressed@2x.png */; };
3636
52C268D015BDB72B0012FECA /* overflowImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 52C268CE15BDB72B0012FECA /* overflowImage.png */; };
3737
52C268D115BDB72B0012FECA /* overflowImagePressed.png in Resources */ = {isa = PBXBuildFile; fileRef = 52C268CF15BDB72B0012FECA /* overflowImagePressed.png */; };
38+
52FAFCCF1C30F4B500C6E613 /* TabNewYosemite.png in Resources */ = {isa = PBXBuildFile; fileRef = 52FAFCCD1C30F4B500C6E613 /* TabNewYosemite.png */; };
39+
52FAFCD01C30F4B500C6E613 /* TabNewYosemite@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 52FAFCCE1C30F4B500C6E613 /* TabNewYosemite@2x.png */; };
40+
52FAFCD31C30F4DF00C6E613 /* PSMYosemiteTabStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 52FAFCD11C30F4DF00C6E613 /* PSMYosemiteTabStyle.h */; };
41+
52FAFCD41C30F4DF00C6E613 /* PSMYosemiteTabStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 52FAFCD21C30F4DF00C6E613 /* PSMYosemiteTabStyle.m */; };
3842
546DEAF1067F63070098DCC4 /* PSMTabBarControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0259C576FE90428111CA0C5A /* PSMTabBarControl.m */; };
3943
546DEAF2067F630E0098DCC4 /* PSMTabBarControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0259C57AFE90428111CA0C5A /* PSMTabBarControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
4044
A2082A9009EAEB34009AC8BE /* PSMTabDragAssistant.h in Headers */ = {isa = PBXBuildFile; fileRef = A2082A8D09EAEB33009AC8BE /* PSMTabDragAssistant.h */; };
@@ -111,6 +115,10 @@
111115
52C0B9B315BDB7A9000C268F /* overflowImagePressed@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "overflowImagePressed@2x.png"; path = "images/overflowImagePressed@2x.png"; sourceTree = "<group>"; };
112116
52C268CE15BDB72B0012FECA /* overflowImage.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = overflowImage.png; path = images/overflowImage.png; sourceTree = "<group>"; };
113117
52C268CF15BDB72B0012FECA /* overflowImagePressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = overflowImagePressed.png; path = images/overflowImagePressed.png; sourceTree = "<group>"; };
118+
52FAFCCD1C30F4B500C6E613 /* TabNewYosemite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TabNewYosemite.png; path = images/TabNewYosemite.png; sourceTree = "<group>"; };
119+
52FAFCCE1C30F4B500C6E613 /* TabNewYosemite@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "TabNewYosemite@2x.png"; path = "images/TabNewYosemite@2x.png"; sourceTree = "<group>"; };
120+
52FAFCD11C30F4DF00C6E613 /* PSMYosemiteTabStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSMYosemiteTabStyle.h; path = source/PSMYosemiteTabStyle.h; sourceTree = "<group>"; };
121+
52FAFCD21C30F4DF00C6E613 /* PSMYosemiteTabStyle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSMYosemiteTabStyle.m; path = source/PSMYosemiteTabStyle.m; sourceTree = "<group>"; };
114122
53DF68FD067E5B5A0090B5B0 /* PSMTabBarControl.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PSMTabBarControl.framework; sourceTree = BUILT_PRODUCTS_DIR; };
115123
53DF68FE067E5B5A0090B5B0 /* PSMTabBarControlFramework-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PSMTabBarControlFramework-Info.plist"; sourceTree = "<group>"; };
116124
54D33B2806778E3300C9C163 /* PSMTabBarControl.ibclassdescription */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PSMTabBarControl.ibclassdescription; sourceTree = "<group>"; };
@@ -309,6 +317,8 @@
309317
A2D32EFF09A63D7A00EC8662 /* PSMMetalTabStyle.m */,
310318
A2D98B070A2B432C0064C6F8 /* PSMUnifiedTabStyle.h */,
311319
A2D98B080A2B432C0064C6F8 /* PSMUnifiedTabStyle.m */,
320+
52FAFCD11C30F4DF00C6E613 /* PSMYosemiteTabStyle.h */,
321+
52FAFCD21C30F4DF00C6E613 /* PSMYosemiteTabStyle.m */,
312322
A268EA5F09A9831800E082AA /* PSMRolloverButton.h */,
313323
A268EA6009A9831800E082AA /* PSMRolloverButton.m */,
314324
A251BE810959A1B90058BC7F /* PSMOverflowPopUpButton.h */,
@@ -382,6 +392,8 @@
382392
523897EE15BDA9AC00498A53 /* TabClose_Front_Pressed@2x.png */,
383393
52A57C0E15BBA230003EC59C /* TabClose_Front_Rollover.png */,
384394
523897EF15BDA9AC00498A53 /* TabClose_Front_Rollover@2x.png */,
395+
52FAFCCD1C30F4B500C6E613 /* TabNewYosemite.png */,
396+
52FAFCCE1C30F4B500C6E613 /* TabNewYosemite@2x.png */,
385397
);
386398
name = Images;
387399
sourceTree = "<group>";
@@ -396,6 +408,7 @@
396408
546DEAF2067F630E0098DCC4 /* PSMTabBarControl.h in Headers */,
397409
A251BE850959A1B90058BC7F /* PSMOverflowPopUpButton.h in Headers */,
398410
A251BE870959A1B90058BC7F /* PSMTabBarCell.h in Headers */,
411+
52FAFCD31C30F4DF00C6E613 /* PSMYosemiteTabStyle.h in Headers */,
399412
A2D32EDC09A634C900EC8662 /* PSMTabStyle.h in Headers */,
400413
A2D32F0009A63D7A00EC8662 /* PSMMetalTabStyle.h in Headers */,
401414
A268EA6209A9831800E082AA /* PSMRolloverButton.h in Headers */,
@@ -478,8 +491,10 @@
478491
52A57C0F15BBA230003EC59C /* TabClose_Front.png in Resources */,
479492
52A57C1015BBA230003EC59C /* TabClose_Front_Pressed.png in Resources */,
480493
52A57C1115BBA230003EC59C /* TabClose_Front_Rollover.png in Resources */,
494+
52FAFCCF1C30F4B500C6E613 /* TabNewYosemite.png in Resources */,
481495
523897F415BDA9AC00498A53 /* TabClose_Front_Pressed@2x.png in Resources */,
482496
523897F515BDA9AC00498A53 /* TabClose_Front_Rollover@2x.png in Resources */,
497+
52FAFCD01C30F4B500C6E613 /* TabNewYosemite@2x.png in Resources */,
483498
523897F615BDA9AC00498A53 /* TabClose_Front@2x.png in Resources */,
484499
523897F715BDA9AC00498A53 /* TabNewMetal@2x.png in Resources */,
485500
523897F815BDA9AC00498A53 /* TabNewMetalPressed@2x.png in Resources */,
@@ -505,6 +520,7 @@
505520
A268EA6309A9831800E082AA /* PSMRolloverButton.m in Sources */,
506521
A2129BB309AEB58F00724E6C /* PSMProgressIndicator.m in Sources */,
507522
A2082A9109EAEB34009AC8BE /* PSMTabDragAssistant.m in Sources */,
523+
52FAFCD41C30F4DF00C6E613 /* PSMYosemiteTabStyle.m in Sources */,
508524
A2D98B0B0A2B432C0064C6F8 /* PSMUnifiedTabStyle.m in Sources */,
509525
A2D98B130A2B43FA0064C6F8 /* NSBezierPath_AMShading.m in Sources */,
510526
);
1.42 KB
Loading
4.24 KB
Loading

src/MacVim/PSMTabBarControl/source/PSMMetalTabStyle.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,7 @@ - (void)drawInteriorWithTabCell:(PSMTabBarCell *)cell inView:(NSView*)controlVie
393393
if ([cell closeButtonPressed]) closeButton = metalCloseButtonDown;
394394

395395
closeButtonSize = [closeButton size];
396-
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
397396
[closeButton drawInRect:closeButtonRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];
398-
#else
399-
[closeButton setFlipped:YES];
400-
[closeButton drawAtPoint:closeButtonRect.origin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
401-
#endif
402397

403398
// scoot label over
404399
labelPosition += closeButtonSize.width + kPSMTabBarCellPadding;

src/MacVim/PSMTabBarControl/source/PSMOverflowPopUpButton.m

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ - (void)drawRect:(NSRect)rect
4040
}
4141

4242
NSImage *image = (_down) ? _PSMTabBarOverflowDownPopUpImage : _PSMTabBarOverflowPopUpImage;
43-
NSSize imageSize = [image size];
44-
rect.origin.x = NSMidX(rect) - (imageSize.width * 0.5);
45-
rect.origin.y = NSMidY(rect) - (imageSize.height * 0.5);
46-
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
47-
[image drawInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil];
48-
#else
49-
[image setFlipped:YES];
50-
[image drawAtPoint:rect.origin fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
51-
#endif
43+
NSSize imageSize = [image size];
44+
NSRect bounds = [self bounds];
45+
NSPoint drawPoint = NSMakePoint(NSMidX(bounds) - (imageSize.width * 0.5f),
46+
NSMidY(bounds) - (imageSize.height * 0.5f));
47+
[image drawAtPoint:drawPoint
48+
fromRect:NSZeroRect
49+
operation:NSCompositeSourceOver
50+
fraction:1.0f];
5251
}
5352

5453
- (void)mouseDown:(NSEvent *)event

src/MacVim/PSMTabBarControl/source/PSMTabBarControl.h

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,18 @@
1212

1313
#import <Cocoa/Cocoa.h>
1414

15-
#ifndef NSINTEGER_DEFINED
16-
// NSInteger was introduced in 10.5
17-
# if __LP64__ || NS_BUILD_32_LIKE_64
18-
typedef long NSInteger;
19-
typedef unsigned long NSUInteger;
20-
# else
21-
typedef int NSInteger;
22-
typedef unsigned int NSUInteger;
23-
# endif
24-
# define NSINTEGER_DEFINED 1
15+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
16+
# define kPSMTabBarControlHeight 25
17+
#else
18+
# define kPSMTabBarControlHeight 22
2519
#endif
26-
27-
#ifndef MAC_OS_X_VERSION_10_6
28-
# define MAC_OS_X_VERSION_10_6 1060
29-
#endif
30-
31-
#define kPSMTabBarControlHeight 22
3220
// internal cell border
3321
#define MARGIN_X 6
34-
#define MARGIN_Y 3
22+
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_10
23+
# define MARGIN_Y 5
24+
#else
25+
# define MARGIN_Y 3
26+
#endif
3527
// padding between objects
3628
#define kPSMTabBarCellPadding 4
3729
// fixed size objects

src/MacVim/PSMTabBarControl/source/PSMTabBarControl.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "PSMTabStyle.h"
1414
#import "PSMMetalTabStyle.h"
1515
#import "PSMUnifiedTabStyle.h"
16+
#import "PSMYosemiteTabStyle.h"
1617
#import "PSMTabDragAssistant.h"
1718

1819
@interface PSMTabBarControl (Private)
@@ -254,10 +255,11 @@ - (NSString *)styleName
254255
- (void)setStyleNamed:(NSString *)name
255256
{
256257
[style release];
257-
if ([name isEqualToString:@"Unified"]){
258-
style = [[PSMUnifiedTabStyle alloc] init];
259-
}
260-
else {
258+
if([name isEqualToString:@"Unified"]){
259+
style = [[PSMUnifiedTabStyle alloc] init];
260+
} else if([name isEqualToString:@"Yosemite"]){
261+
style = [[PSMYosemiteTabStyle alloc] init];
262+
} else {
261263
style = [[PSMMetalTabStyle alloc] init];
262264
}
263265

0 commit comments

Comments
 (0)