Skip to content

Commit 9bbd6b5

Browse files
committed
Tweak tab drawing
* inset 2pt horizontally so shadow isn't clipped * top margin goes from 4pt->0pt (0.5pt macOS 11)
1 parent ca8f8ac commit 9bbd6b5

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/MacVim/MMTabline/MMTab.m

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ - (instancetype)initWithFrame:(NSRect)frameRect tabline:(MMTabline *)tabline
5353

5454
NSDictionary *viewDict = NSDictionaryOfVariableBindings(_closeButton, _titleLabel);
5555
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-9-[_closeButton]-(>=5)-[_titleLabel]-(>=16)-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:viewDict]];
56-
[self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_titleLabel attribute:NSLayoutAttributeCenterY multiplier:1 constant:-2]];
56+
[self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_titleLabel attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
5757
NSLayoutConstraint *centerConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:_titleLabel attribute:NSLayoutAttributeCenterX multiplier:1 constant:0];
5858
centerConstraint.priority = NSLayoutPriorityFittingSizeCompression+1;
5959
[self addConstraint:centerConstraint];
6060

6161
_shadow = [NSShadow new];
62-
_shadow.shadowColor = [NSColor colorWithWhite:0 alpha:0.4];
62+
_shadow.shadowColor = [NSColor colorWithWhite:0 alpha:0.3];
6363
_shadow.shadowBlurRadius = 2;
6464

6565
self.state = MMTabStateUnselected;
@@ -143,13 +143,22 @@ - (void)drawRect:(NSRect)dirtyRect
143143
[self.fillColor set];
144144
CGFloat maxX = NSMaxX(self.bounds);
145145
NSBezierPath *p = [NSBezierPath new];
146-
[p moveToPoint:NSZeroPoint];
147-
[p lineToPoint:NSMakePoint(5.41, 20.76)];
148-
[p curveToPoint:NSMakePoint(8.32, 23) controlPoint1: NSMakePoint(5.76, 22.08) controlPoint2: NSMakePoint(6.95, 23)];
149-
[p lineToPoint:NSMakePoint(maxX - 8.32, 23)];
150-
[p curveToPoint: NSMakePoint(maxX - 5.41, 20.76) controlPoint1: NSMakePoint(maxX - 6.95, 23) controlPoint2: NSMakePoint(maxX - 5.76, 22.08)];
151-
[p lineToPoint:NSMakePoint(maxX, 0)];
146+
[p moveToPoint:NSMakePoint(2, 0)];
147+
[p lineToPoint:NSMakePoint(5.6, 20.5)];
148+
[p curveToPoint: NSMakePoint(8.5, 23) controlPoint1: NSMakePoint(5.8, 22) controlPoint2: NSMakePoint(7.1, 23)];
149+
[p lineToPoint:NSMakePoint(maxX - 8.5, 23)];
150+
[p curveToPoint:NSMakePoint(maxX - 5.6, 20.5) controlPoint1: NSMakePoint(maxX - 7.1, 23) controlPoint2: NSMakePoint(maxX - 5.8, 22)];
151+
[p lineToPoint:NSMakePoint(maxX - 2, 0)];
152152
[p closePath];
153+
// On macOS 11, translate the tab down 0.5pt to provide a thin
154+
// line between the top of the tab and the window's title bar.
155+
// It looks better given the new way macOS 11 draws title bars.
156+
// Older macOS versions don't need this.
157+
if (@available(macOS 11.0, *)) {
158+
NSAffineTransform *transform = [NSAffineTransform new];
159+
[transform translateXBy:0 yBy:-0.5];
160+
[p transformUsingAffineTransform:transform];
161+
}
153162
[p fill];
154163
}
155164

src/MacVim/MMTabline/MMTabline.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// A tabline containing one or more tabs.
66

7-
#define MMTablineHeight (27)
7+
#define MMTablineHeight (23)
88

99
@protocol MMTablineDelegate;
1010

src/MacVim/MMTabline/MMTabline.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
const CGFloat OptimumTabWidth = 200;
1010
const CGFloat MinimumTabWidth = 100;
11-
const CGFloat TabOverlap = 4;
11+
const CGFloat TabOverlap = 6;
1212

1313
MMHoverButton* MakeHoverButton(MMTabline *tabline, NSString *imageName, SEL action, BOOL continuous) {
1414
MMHoverButton *button = [MMHoverButton new];

0 commit comments

Comments
 (0)