From b1bdf8e54aeb05bf41aa996bdac8e17fdb0243e5 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 19 Apr 2020 09:40:20 -0400 Subject: [PATCH] Update the progress bar colors in dark mode --- macosx/ProgressGradients.m | 61 +++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/macosx/ProgressGradients.m b/macosx/ProgressGradients.m index ffe17e984..7926bd2fe 100644 --- a/macosx/ProgressGradients.m +++ b/macosx/ProgressGradients.m @@ -21,6 +21,7 @@ *****************************************************************************/ #import "ProgressGradients.h" +#import "NSApplicationAdditions.h" @implementation ProgressGradients (Private) @@ -45,52 +46,92 @@ + (NSGradient *) progressWhiteGradient { - return [[self class] progressGradientForRed: 0.95 green: 0.95 blue: 0.95]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.1 green: 0.1 blue: 0.1]; + } else { + return [[self class] progressGradientForRed: 0.95 green: 0.95 blue: 0.95]; + } } + (NSGradient *) progressGrayGradient { - return [[self class] progressGradientForRed: 0.7 green: 0.7 blue: 0.7]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.35 green: 0.35 blue: 0.35]; + } else { + return [[self class] progressGradientForRed: 0.7 green: 0.7 blue: 0.7]; + } } + (NSGradient *) progressLightGrayGradient { - return [[self class] progressGradientForRed: 0.87 green: 0.87 blue: 0.87]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.2 green: 0.2 blue: 0.2]; + } else { + return [[self class] progressGradientForRed: 0.87 green: 0.87 blue: 0.87]; + } } + (NSGradient *) progressBlueGradient { - return [[self class] progressGradientForRed: 0.35 green: 0.67 blue: 0.98]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.35 * 2.0/3.0 green: 0.67 * 2.0/3.0 blue: 0.98 * 2.0/3.0]; + } else { + return [[self class] progressGradientForRed: 0.35 green: 0.67 blue: 0.98]; + } } + (NSGradient *) progressDarkBlueGradient { - return [[self class] progressGradientForRed: 0.616 green: 0.722 blue: 0.776]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.616 * 2.0/3.0 green: 0.722 * 2.0/3.0 blue: 0.776 * 2.0/3.0]; + } else { + return [[self class] progressGradientForRed: 0.616 green: 0.722 blue: 0.776]; + } } + (NSGradient *) progressGreenGradient { - return [[self class] progressGradientForRed: 0.44 green: 0.89 blue: 0.40]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.44 * 2.0/3.0 green: 0.89 * 2.0/3.0 blue: 0.40 * 2.0/3.0]; + } else { + return [[self class] progressGradientForRed: 0.44 green: 0.89 blue: 0.40]; + } } + (NSGradient *) progressLightGreenGradient { - return [[self class] progressGradientForRed: 0.62 green: 0.99 blue: 0.58]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.62 * 3.0/4.0 green: 0.99 * 3.0/4.0 blue: 0.58 * 3.0/4.0]; + } else { + return [[self class] progressGradientForRed: 0.62 green: 0.99 blue: 0.58]; + } } + (NSGradient *) progressDarkGreenGradient { - return [[self class] progressGradientForRed: 0.627 green: 0.714 blue: 0.639]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.627 * 2.0/3.0 green: 0.714 * 2.0/3.0 blue: 0.639 * 2.0/3.0]; + } else { + return [[self class] progressGradientForRed: 0.627 green: 0.714 blue: 0.639]; + } } + (NSGradient *) progressRedGradient { - return [[self class] progressGradientForRed: 0.902 green: 0.439 blue: 0.451]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.902 * 2.0/3.0 green: 0.439 * 2.0/3.0 blue: 0.451 * 2.0/3.0]; + } else { + return [[self class] progressGradientForRed: 0.902 green: 0.439 blue: 0.451]; + } } + (NSGradient *) progressYellowGradient { - return [[self class] progressGradientForRed: 0.933 green: 0.890 blue: 0.243]; + if ([NSApp isDarkMode]) { + return [[self class] progressGradientForRed: 0.933 * 0.8 green: 0.890 * 0.8 blue: 0.243 * 0.8]; + } else { + return [[self class] progressGradientForRed: 0.933 green: 0.890 blue: 0.243]; + } } @end