From bf2b4d227ea86d06bd506ac41b23e35e723a0b64 Mon Sep 17 00:00:00 2001 From: "B. Kevin Hardman" Date: Tue, 27 Nov 2018 10:38:50 -0500 Subject: [PATCH 1/3] macOS 10.14 Mojave changes the way NSCell works and thus drawBezelOfTabCell:withFrame:inView: is doing the wrong thing (not sure why the view and cell both implement drawing) --- .../MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m b/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m index 0cd54ece..043234fd 100644 --- a/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m +++ b/MMTabBarView/MMTabBarView/Styles/Safari Tab Style/MMSafariTabStyle.m @@ -367,6 +367,9 @@ -(void)drawBezelOfOverflowButton:(MMOverflowPopUpButton *)overflowButton ofTabBa -(void)drawBezelOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inView:(NSView *)controlView { + if (@available(macos 10.14, *)) { + return; + } if (cell.controlView.frame.size.height < 2) return; @@ -376,9 +379,6 @@ -(void)drawBezelOfTabCell:(MMTabBarButtonCell *)cell withFrame:(NSRect)frame inV NSRect cellFrame = frame; cellFrame = NSInsetRect(cellFrame, -5.0, 0); - - if (cell.controlView.frame.size.height < 2) - return; NSImage *left = nil; NSImage *center = nil; From ddee10acbed5e8be0899e346f600c2a3b5eac71d Mon Sep 17 00:00:00 2001 From: "B. Kevin Hardman" Date: Tue, 27 Nov 2018 10:39:08 -0500 Subject: [PATCH 2/3] the drop shadow on the labels looks OK in Aqua but not so OK in DarkAqua so disable the shadow for DarkAqua --- .../MMTabBarView/MMTabBarButtonCell.m | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m index 90438c61..e11f0291 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m +++ b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m @@ -1063,17 +1063,27 @@ - (void)_drawIconWithFrame:(NSRect)frame inView:(NSView *)controlView { [icon drawInRect:iconRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0 respectFlipped:YES hints:nil]; } +inline static bool useShadow(NSView* const inView) { + if (@available(macOS 10.14, *)) { + return ![[inView.effectiveAppearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]] isEqualToString:NSAppearanceNameDarkAqua]; + } + return true; +} + - (void)_drawTitleWithFrame:(NSRect)frame inView:(NSView *)controlView { NSRect rect = [self titleRectForBounds:frame]; [NSGraphicsContext saveGraphicsState]; - - NSShadow *shadow = [[NSShadow alloc] init]; - [shadow setShadowColor:[NSColor.whiteColor colorWithAlphaComponent:0.4]]; - [shadow setShadowBlurRadius:1.0]; - [shadow setShadowOffset:NSMakeSize(0.0, -1.0)]; - [shadow set]; + + if (useShadow(controlView)) { + NSShadow *shadow = [[NSShadow alloc] init]; + [shadow setShadowColor:[NSColor.whiteColor colorWithAlphaComponent:0.4]]; + [shadow setShadowColor:[NSColor.whiteColor colorWithAlphaComponent:0.6]]; + [shadow setShadowBlurRadius:1.0]; + [shadow setShadowOffset:NSMakeSize(0.0, -1.0)]; + [shadow set]; + } // draw title [self.attributedStringValue drawInRect:rect]; From ec578570cd772657eb58ba2df8c93ec069d3b82f Mon Sep 17 00:00:00 2001 From: "B. Kevin Hardman" Date: Tue, 27 Nov 2018 10:45:05 -0500 Subject: [PATCH 3/3] remove duplicate set of drop shadow color --- MMTabBarView/MMTabBarView/MMTabBarButtonCell.m | 1 - 1 file changed, 1 deletion(-) diff --git a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m index e11f0291..cc365e9d 100644 --- a/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m +++ b/MMTabBarView/MMTabBarView/MMTabBarButtonCell.m @@ -1079,7 +1079,6 @@ - (void)_drawTitleWithFrame:(NSRect)frame inView:(NSView *)controlView { if (useShadow(controlView)) { NSShadow *shadow = [[NSShadow alloc] init]; [shadow setShadowColor:[NSColor.whiteColor colorWithAlphaComponent:0.4]]; - [shadow setShadowColor:[NSColor.whiteColor colorWithAlphaComponent:0.6]]; [shadow setShadowBlurRadius:1.0]; [shadow setShadowOffset:NSMakeSize(0.0, -1.0)]; [shadow set];