Skip to content

Commit

Permalink
Tabline background uses -updateLayer instead of NSBox
Browse files Browse the repository at this point in the history
  • Loading branch information
sfsam committed Nov 21, 2020
1 parent c3a6fb7 commit edfa886
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/MacVim/MMTabline/MMTabline.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

@implementation MMTabline
{
NSBox *_background;
NSView *_tabsContainer;
NSScrollView *_scrollView;
NSMutableArray <MMTab *> *_tabs;
Expand All @@ -30,18 +29,11 @@ - (instancetype)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
if (self) {
self.wantsLayer = YES; // we use -updateLayer to fill background

_tabs = [NSMutableArray new];
_showsAddTabButton = YES; // get from NSUserDefaults

// Add background first so it's at the bottom of view hierarchy
_background = [NSBox new];
_background.boxType = NSBoxCustom;
_background.borderWidth = 0;
_background.fillColor = [NSColor colorNamed:@"TablineFill"];
_background.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
_background.frame = self.bounds;
[self addSubview:_background];

// This view holds the tab views.
_tabsContainer = [NSView new];
_tabsContainer.frame = (NSRect){{0, 0}, frameRect.size};
Expand Down Expand Up @@ -80,6 +72,13 @@ - (void)layout
[self fixupLayoutWithAnimation:NO];
}

- (BOOL)wantsUpdateLayer { return YES; }

- (void)updateLayer
{
self.layer.backgroundColor = (self.tablineFillFgColor ?: [NSColor colorNamed:@"TablineFill"]).CGColor;
}

#pragma mark - Accessors

- (NSUInteger)numberOfTabs
Expand Down Expand Up @@ -133,7 +132,7 @@ - (void)setTablineSelFgColor:(NSColor *)color
- (void)setTablineFillFgColor:(NSColor *)color
{
_tablineFillFgColor = color;
_background.fillColor = color ?: [NSColor colorNamed:@"TablineFill"];
self.needsDisplay = YES;
}

- (NSUInteger)addTabAtEnd
Expand Down

0 comments on commit edfa886

Please sign in to comment.