2023-02-11 20:49:42 +00:00
|
|
|
// This file Copyright © 2007-2023 Transmission authors and contributors.
|
2022-01-20 18:27:56 +00:00
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2008-10-31 00:13:50 +00:00
|
|
|
#import "ProgressGradients.h"
|
2020-04-19 13:40:20 +00:00
|
|
|
#import "NSApplicationAdditions.h"
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2010-03-20 03:27:17 +00:00
|
|
|
@implementation ProgressGradients
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressWhiteGradient
|
2008-06-24 03:59:34 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2008-06-24 03:59:34 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressGrayGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressLightGrayGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressBlueGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressDarkBlueGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressGreenGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressLightGreenGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressDarkGreenGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressRedGradient
|
2007-11-11 21:45:27 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-11-11 21:45:27 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSGradient*)progressYellowGradient
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-06-29 04:20:42 +00:00
|
|
|
if (NSApp.darkMode)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
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];
|
2020-04-19 13:40:20 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
#pragma mark - Private
|
|
|
|
|
|
|
|
+ (NSGradient*)progressGradientForRed:(CGFloat)redComponent green:(CGFloat)greenComponent blue:(CGFloat)blueComponent
|
|
|
|
{
|
|
|
|
CGFloat const alpha = [NSUserDefaults.standardUserDefaults boolForKey:@"SmallView"] ? 0.27 : 1.0;
|
|
|
|
|
|
|
|
NSColor* baseColor = [NSColor colorWithCalibratedRed:redComponent green:greenComponent blue:blueComponent alpha:alpha];
|
|
|
|
|
|
|
|
NSColor* color2 = [NSColor colorWithCalibratedRed:redComponent * 0.95 green:greenComponent * 0.95 blue:blueComponent * 0.95
|
|
|
|
alpha:alpha];
|
|
|
|
|
|
|
|
NSColor* color3 = [NSColor colorWithCalibratedRed:redComponent * 0.85 green:greenComponent * 0.85 blue:blueComponent * 0.85
|
|
|
|
alpha:alpha];
|
|
|
|
|
|
|
|
return [[NSGradient alloc] initWithColorsAndLocations:baseColor, 0.0, color2, 0.5, color3, 0.5, baseColor, 1.0, nil];
|
|
|
|
}
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
@end
|