1212
1313@implementation MMTabline
1414{
15- NSBox *_background;
1615 NSView *_tabsContainer;
1716 NSScrollView *_scrollView;
1817 NSMutableArray <MMTab *> *_tabs;
@@ -30,18 +29,11 @@ - (instancetype)initWithFrame:(NSRect)frameRect
3029{
3130 self = [super initWithFrame: frameRect];
3231 if (self) {
32+ self.wantsLayer = YES ; // we use -updateLayer to fill background
33+
3334 _tabs = [NSMutableArray new ];
3435 _showsAddTabButton = YES ; // get from NSUserDefaults
3536
36- // Add background first so it's at the bottom of view hierarchy
37- _background = [NSBox new ];
38- _background.boxType = NSBoxCustom;
39- _background.borderWidth = 0 ;
40- _background.fillColor = [NSColor colorNamed: @" TablineFill" ];
41- _background.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
42- _background.frame = self.bounds ;
43- [self addSubview: _background];
44-
4537 // This view holds the tab views.
4638 _tabsContainer = [NSView new ];
4739 _tabsContainer.frame = (NSRect ){{0 , 0 }, frameRect.size };
@@ -80,6 +72,13 @@ - (void)layout
8072 [self fixupLayoutWithAnimation: NO ];
8173}
8274
75+ - (BOOL )wantsUpdateLayer { return YES ; }
76+
77+ - (void )updateLayer
78+ {
79+ self.layer .backgroundColor = (self.tablineFillFgColor ?: [NSColor colorNamed: @" TablineFill" ]).CGColor ;
80+ }
81+
8382#pragma mark - Accessors
8483
8584- (NSUInteger )numberOfTabs
@@ -133,7 +132,7 @@ - (void)setTablineSelFgColor:(NSColor *)color
133132- (void )setTablineFillFgColor : (NSColor *)color
134133{
135134 _tablineFillFgColor = color;
136- _background. fillColor = color ?: [ NSColor colorNamed: @" TablineFill " ] ;
135+ self. needsDisplay = YES ;
137136}
138137
139138- (NSUInteger )addTabAtEnd
0 commit comments