From d247599afeecb17b7e1e31bb39978c4a958b2e6d Mon Sep 17 00:00:00 2001 From: Sanjay Madan Date: Thu, 17 Dec 2020 21:56:06 -0800 Subject: [PATCH] Refine tabline appearance and coloring --- src/MacVim/MMTabline/MMTab.m | 18 ++++++++---------- src/MacVim/MMTabline/MMTabline.h | 2 +- src/MacVim/MMTabline/MMTabline.m | 2 +- src/MacVim/MMVimView.m | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/MacVim/MMTabline/MMTab.m b/src/MacVim/MMTabline/MMTab.m index 5a1afba20c..4fa531c7eb 100644 --- a/src/MacVim/MMTabline/MMTab.m +++ b/src/MacVim/MMTabline/MMTab.m @@ -52,8 +52,8 @@ - (instancetype)initWithFrame:(NSRect)frameRect tabline:(MMTabline *)tabline [self addSubview:_titleLabel]; NSDictionary *viewDict = NSDictionaryOfVariableBindings(_closeButton, _titleLabel); - [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-7-[_closeButton]-(>=5)-[_titleLabel]-(>=8)-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:viewDict]]; - [self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_titleLabel attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]]; + [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-9-[_closeButton]-(>=5)-[_titleLabel]-(>=16)-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:viewDict]]; + [self addConstraint:[NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:_titleLabel attribute:NSLayoutAttributeCenterY multiplier:1 constant:-2]]; NSLayoutConstraint *centerConstraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:_titleLabel attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]; centerConstraint.priority = NSLayoutPriorityFittingSizeCompression+1; [self addConstraint:centerConstraint]; @@ -101,7 +101,6 @@ - (void)setState:(MMTabState)state if (state == MMTabStateSelected) { _closeButton.alphaValue = 1; _titleLabel.textColor = _tabline.tablineSelFgColor ?: NSColor.controlTextColor; - _titleLabel.font = [NSFont systemFontOfSize:11 weight:NSFontWeightMedium]; self.fillColor = _tabline.tablineSelBgColor ?: [NSColor colorNamed:@"TablineSel"]; self.shadow = _shadow; } @@ -115,13 +114,11 @@ - (void)setState:(MMTabState)state _titleLabel.animator.textColor = _tabline.tablineFgColor ?: NSColor.disabledControlTextColor; self.animator.fillColor = _tabline.tablineBgColor ?: [NSColor colorNamed:@"Tabline"]; } - _titleLabel.font = [NSFont systemFontOfSize:11]; self.shadow = nil; } else { // state == MMTabStateUnselectedHover _closeButton.animator.alphaValue = 1; _titleLabel.animator.textColor = _tabline.tablineSelFgColor ?: NSColor.controlTextColor; - _titleLabel.font = [NSFont systemFontOfSize:11]; self.animator.fillColor = self.unselectedHoverColor; self.animator.shadow = _shadow; } @@ -144,13 +141,14 @@ - (NSColor *)unselectedHoverColor - (void)drawRect:(NSRect)dirtyRect { [self.fillColor set]; + CGFloat maxX = NSMaxX(self.bounds); NSBezierPath *p = [NSBezierPath new]; [p moveToPoint:NSZeroPoint]; - [p lineToPoint:NSMakePoint(3.6, NSMaxY(self.bounds) - 2.5)]; - [p curveToPoint:NSMakePoint(6.5, NSMaxY(self.bounds)) controlPoint1:NSMakePoint(3.8, NSMaxY(self.bounds) - 1) controlPoint2:NSMakePoint(5.1, NSMaxY(self.bounds))]; - [p lineToPoint:NSMakePoint(NSMaxX(self.bounds) - 6.5, NSMaxY(self.bounds))]; - [p curveToPoint:NSMakePoint(NSMaxX(self.bounds) - 3.6, NSMaxY(self.bounds) - 2.5) controlPoint1:NSMakePoint(NSMaxX(self.bounds) - 5.1, NSMaxY(self.bounds)) controlPoint2:NSMakePoint(NSMaxX(self.bounds) - 3.8, NSMaxY(self.bounds) - 1)]; - [p lineToPoint:NSMakePoint(NSMaxX(self.bounds), 0)]; + [p lineToPoint:NSMakePoint(5.41, 20.76)]; + [p curveToPoint:NSMakePoint(8.32, 23) controlPoint1: NSMakePoint(5.76, 22.08) controlPoint2: NSMakePoint(6.95, 23)]; + [p lineToPoint:NSMakePoint(maxX - 8.32, 23)]; + [p curveToPoint: NSMakePoint(maxX - 5.41, 20.76) controlPoint1: NSMakePoint(maxX - 6.95, 23) controlPoint2: NSMakePoint(maxX - 5.76, 22.08)]; + [p lineToPoint:NSMakePoint(maxX, 0)]; [p closePath]; [p fill]; } diff --git a/src/MacVim/MMTabline/MMTabline.h b/src/MacVim/MMTabline/MMTabline.h index 240d0ccdb6..0b061d58dd 100644 --- a/src/MacVim/MMTabline/MMTabline.h +++ b/src/MacVim/MMTabline/MMTabline.h @@ -4,7 +4,7 @@ // A tabline containing one or more tabs. -#define MMTablineHeight (23) +#define MMTablineHeight (27) @protocol MMTablineDelegate; diff --git a/src/MacVim/MMTabline/MMTabline.m b/src/MacVim/MMTabline/MMTabline.m index 15a1c53f37..0d5504fbee 100644 --- a/src/MacVim/MMTabline/MMTabline.m +++ b/src/MacVim/MMTabline/MMTabline.m @@ -8,7 +8,7 @@ const CGFloat OptimumTabWidth = 200; const CGFloat MinimumTabWidth = 100; -const CGFloat TabOverlap = 2; +const CGFloat TabOverlap = 4; @implementation MMTabline { diff --git a/src/MacVim/MMVimView.m b/src/MacVim/MMVimView.m index b3bcfafb49..92dd587fa3 100644 --- a/src/MacVim/MMVimView.m +++ b/src/MacVim/MMVimView.m @@ -478,7 +478,7 @@ - (void)setTablineColorsBasedOnBackground:(NSColor *)back foreground:(NSColor *) b2 = (b > 0.5) ? b - 0.15 : b + 0.15; tabline.tablineBgColor = [NSColor colorWithHue:h saturation:s brightness:b2 alpha:a]; - b3 = (b > 0.5) ? b - 0.25 : b + 0.25; + b3 = (b > 0.5) ? b - 0.30 : b + 0.30; tabline.tablineFillFgColor = [NSColor colorWithHue:h saturation:s brightness:b3 alpha:a]; [fore getHue:&h saturation:&s brightness:&b alpha:&a];