Skip to content

Commit

Permalink
Merge pull request #70 from nivekkagicom/master
Browse files Browse the repository at this point in the history
clearer labels for macOS 10.14 Mojave DarkAqua and adjust Mojave drawing issues with NSCell
  • Loading branch information
MiMo42 committed Nov 27, 2018
2 parents 172a9d4 + 318b3e4 commit 2280a6a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 15 additions & 6 deletions MMTabBarView/MMTabBarView/MMTabBarButtonCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -1036,17 +1036,26 @@ - (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 setShadowBlurRadius:1.0];
[shadow setShadowOffset:NSMakeSize(0.0, -1.0)];
[shadow set];
}

// draw title
[self.attributedStringValue drawInRect:rect];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit 2280a6a

Please sign in to comment.