mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
refactor: autogenerate the macOS client's Message Log dots (#3224)
* Replaces DotFlat png with generated icons * code review: udating popup item icons * code review: increasing inset
This commit is contained in:
@@ -5,9 +5,35 @@
|
||||
#import "CocoaCompatibility.h"
|
||||
|
||||
#import "NSImageAdditions.h"
|
||||
#import "NSApplicationAdditions.h"
|
||||
|
||||
@implementation NSImage (NSImageAdditions)
|
||||
|
||||
#define ICON_WIDTH 16.0
|
||||
#define BORDER_WIDTH 1.25
|
||||
|
||||
+ (NSImage*)discIconWithColor:(NSColor*)color insetFactor:(CGFloat)insetFactor
|
||||
{
|
||||
return [NSImage imageWithSize:NSMakeSize(ICON_WIDTH, ICON_WIDTH) flipped:NO drawingHandler:^BOOL(NSRect rect) {
|
||||
//shape
|
||||
rect = NSInsetRect(rect, BORDER_WIDTH / 2 + rect.size.width * insetFactor / 2, BORDER_WIDTH / 2 + rect.size.height * insetFactor / 2);
|
||||
NSBezierPath* bp = [NSBezierPath bezierPathWithOvalInRect:rect];
|
||||
bp.lineWidth = BORDER_WIDTH;
|
||||
|
||||
//border
|
||||
CGFloat fractionOfBlendedColor = [NSApp isDarkMode] ? 0.15 : 0.3;
|
||||
NSColor* borderColor = [color blendedColorWithFraction:fractionOfBlendedColor ofColor:NSColor.controlTextColor];
|
||||
[borderColor setStroke];
|
||||
[bp stroke];
|
||||
|
||||
//inside
|
||||
[color setFill];
|
||||
[bp fill];
|
||||
|
||||
return YES;
|
||||
}];
|
||||
}
|
||||
|
||||
- (NSImage*)imageWithColor:(NSColor*)color
|
||||
{
|
||||
NSImage* coloredImage = [self copy];
|
||||
|
||||
Reference in New Issue
Block a user