Skip to content

Commit

Permalink
Refine tabline appearance and coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
sfsam committed Dec 20, 2020
1 parent edfa886 commit da2a243
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/MacVim/MMTabline/MMHoverButton.m
Expand Up @@ -18,7 +18,7 @@ - (instancetype)initWithFrame:(NSRect)frameRect
_circle = [NSBox new];
_circle.boxType = NSBoxCustom;
_circle.borderWidth = 0;
_circle.alphaValue = 0.12;
_circle.alphaValue = 0.16;
_circle.fillColor = NSColor.clearColor;
_circle.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
_circle.frame = self.bounds;
Expand All @@ -44,7 +44,7 @@ - (void)setImage:(NSImage *)image
return YES;
}];
self.alternateImage = [NSImage imageWithSize:image.size flipped:NO drawingHandler:^BOOL(NSRect dstRect) {
[[fillColor colorWithAlphaComponent:0.15] set];
[[fillColor colorWithAlphaComponent:0.2] set];
[[NSBezierPath bezierPathWithOvalInRect:dstRect] fill];
[super.image drawInRect:dstRect];
return YES;
Expand Down
18 changes: 8 additions & 10 deletions src/MacVim/MMTabline/MMTab.m
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion src/MacVim/MMTabline/MMTabline.h
Expand Up @@ -4,7 +4,7 @@

// A tabline containing one or more tabs.

#define MMTablineHeight (23)
#define MMTablineHeight (27)

@protocol MMTablineDelegate;

Expand Down
2 changes: 1 addition & 1 deletion src/MacVim/MMTabline/MMTabline.m
Expand Up @@ -8,7 +8,7 @@

const CGFloat OptimumTabWidth = 200;
const CGFloat MinimumTabWidth = 100;
const CGFloat TabOverlap = 2;
const CGFloat TabOverlap = 4;

@implementation MMTabline
{
Expand Down
2 changes: 1 addition & 1 deletion src/MacVim/MMVimView.m
Expand Up @@ -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];
Expand Down

0 comments on commit da2a243

Please sign in to comment.