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:
A Cœur
2022-06-09 05:35:51 +08:00
committed by GitHub
parent 7056765468
commit af5db6e6f2
42 changed files with 99 additions and 210 deletions

View File

@@ -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];