12
12
13
13
@implementation MMTabline
14
14
{
15
- NSBox *_background;
16
15
NSView *_tabsContainer;
17
16
NSScrollView *_scrollView;
18
17
NSMutableArray <MMTab *> *_tabs;
@@ -30,18 +29,11 @@ - (instancetype)initWithFrame:(NSRect)frameRect
30
29
{
31
30
self = [super initWithFrame: frameRect];
32
31
if (self) {
32
+ self.wantsLayer = YES ; // we use -updateLayer to fill background
33
+
33
34
_tabs = [NSMutableArray new ];
34
35
_showsAddTabButton = YES ; // get from NSUserDefaults
35
36
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
-
45
37
// This view holds the tab views.
46
38
_tabsContainer = [NSView new ];
47
39
_tabsContainer.frame = (NSRect ){{0 , 0 }, frameRect.size };
@@ -80,6 +72,13 @@ - (void)layout
80
72
[self fixupLayoutWithAnimation: NO ];
81
73
}
82
74
75
+ - (BOOL )wantsUpdateLayer { return YES ; }
76
+
77
+ - (void )updateLayer
78
+ {
79
+ self.layer .backgroundColor = (self.tablineFillFgColor ?: [NSColor colorNamed: @" TablineFill" ]).CGColor ;
80
+ }
81
+
83
82
#pragma mark - Accessors
84
83
85
84
- (NSUInteger )numberOfTabs
@@ -133,7 +132,7 @@ - (void)setTablineSelFgColor:(NSColor *)color
133
132
- (void )setTablineFillFgColor : (NSColor *)color
134
133
{
135
134
_tablineFillFgColor = color;
136
- _background. fillColor = color ?: [ NSColor colorNamed: @" TablineFill " ] ;
135
+ self. needsDisplay = YES ;
137
136
}
138
137
139
138
- (NSUInteger )addTabAtEnd
0 commit comments