If you have an issue with any of our projects. feel free to register.

Commit fc2e6df3 authored by Christopher Snowhill's avatar Christopher Snowhill

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

parent e44aad71
......@@ -10,7 +10,7 @@
@interface NowPlayingBarView : NSView
{
NSGradient *gradient;
NSGradient *gradient_light, *gradient_dark;
}
@end
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment