Browse Source

Full screen mode Now Playing Bar now has more appropriate colors in Dark Mode

master
Christopher Snowhill 2 months ago
parent
commit
fc2e6df38f
2 changed files with 28 additions and 6 deletions
  1. +1
    -1
      Window/NowPlayingBarView.h
  2. +27
    -5
      Window/NowPlayingBarView.m

+ 1
- 1
Window/NowPlayingBarView.h View File

@@ -10,7 +10,7 @@

@interface NowPlayingBarView : NSView
{
NSGradient *gradient;
NSGradient *gradient_light, *gradient_dark;
}
@end


+ 27
- 5
Window/NowPlayingBarView.m View File

@@ -16,7 +16,11 @@
{
NSColor *lightColor = [NSColor colorWithCalibratedRed: 160.0/255.0 green: 160.0/255.0 blue: 160.0/255.0 alpha: 1.0];
NSColor *darkColor = [NSColor colorWithCalibratedRed: 155.0/255.0 green: 155.0/255.0 blue: 155.0/255.0 alpha: 1.0];
gradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
gradient_light = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
lightColor = [NSColor colorWithCalibratedRed: 56.0/255.0 green: 56.0/255.0 blue: 56.0/255.0 alpha: 1.0];
darkColor = [NSColor colorWithCalibratedRed: 64.0/255.0 green: 64.0/255.0 blue: 64.0/255.0 alpha: 1.0];
gradient_dark = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
}
return self;
}
@@ -31,10 +35,22 @@
NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
Boolean isDarkMode = NO;
if (@available(macOS 10.14, *)) {
NSAppearance * appearance = [[NSApplication sharedApplication] effectiveAppearance];
NSAppearanceName basicAppearance = [appearance bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
if ([basicAppearance isEqualToString:NSAppearanceNameDarkAqua]) {
isDarkMode = YES;
}
}
if (NSIntersectsRect(lineBorderRect, rect))
{
gridRects[count] = lineBorderRect;
colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0];
if (isDarkMode)
colorRects[count] = [NSColor colorWithCalibratedWhite: 0.40 alpha: 1.0];
else
colorRects[count] = [NSColor colorWithCalibratedWhite: 0.75 alpha: 1.0];
++count;
rect.size.height -= 1.0;
@@ -44,8 +60,11 @@
if (NSIntersectsRect(lineBorderRect, rect))
{
gridRects[count] = lineBorderRect;
colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0]
: [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0];
if (isDarkMode)
colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.60 alpha: 1.0] : [NSColor colorWithCalibratedWhite: 0.4 alpha: 1.0];
else
colorRects[count] = active ? [NSColor colorWithCalibratedWhite: 0.25 alpha: 1.0]
: [NSColor colorWithCalibratedWhite: 0.5 alpha: 1.0];
++count;
rect.origin.y += 1.0;
@@ -55,7 +74,10 @@
if (!NSIsEmptyRect(rect))
{
const NSRect gradientRect = NSMakeRect(NSMinX(rect), 1.0, NSWidth(rect), NSHeight([self bounds]) - 1.0 - 1.0); //proper gradient requires the full height of the bar
[gradient drawInRect: gradientRect angle: 270.0];
if (isDarkMode)
[gradient_dark drawInRect: gradientRect angle: 270.0];
else
[gradient_light drawInRect: gradientRect angle: 270.0];
}
NSRectFillListWithColors(gridRects, colorRects, count);


Loading…
Cancel
Save