Skip to content

Commit

Permalink
attempting to adjust to displays with different resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Coeur committed May 15, 2022
1 parent ce985ac commit 98be9c0
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions macosx/GroupsController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,22 @@ - (NSImage*)imageForGroupNone
return image;
}

NSRect rect = NSMakeRect(0.0, 0.0, ICON_WIDTH * 2, ICON_WIDTH * 2);
CGFloat imageWidth = ICON_WIDTH;
CGFloat borderInset = 1;
// increasing the resolution without increasing the size
if (NSApplication.sharedApplication.mainWindow.backingScaleFactor == 1)
{
imageWidth *= 2;
borderInset -= 1;
}
NSRect rect = NSMakeRect(0.0, 0.0, imageWidth, imageWidth);

NSImage* icon = [[NSImage alloc] initWithSize:rect.size];

[icon lockFocus];

//border
rect = NSInsetRect(rect, borderInset, borderInset);
NSBezierPath* bp = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:rect.size.width / 2 yRadius:rect.size.width / 2];
bp.lineWidth = 2;
CGFloat dashAndGapLength = M_PI * rect.size.width / 10;
Expand All @@ -409,14 +418,22 @@ - (NSImage*)imageForGroup:(NSMutableDictionary*)dict

NSColor* color = dict[@"Color"];

NSRect rect = NSMakeRect(0.0, 0.0, ICON_WIDTH * 2, ICON_WIDTH * 2);
CGFloat imageWidth = ICON_WIDTH;
CGFloat borderInset = 0;
// increasing the resolution without increasing the size
if (NSApplication.sharedApplication.mainWindow.backingScaleFactor == 1)
{
imageWidth *= 2;
borderInset -= 1;
}
NSRect rect = NSMakeRect(0.0, 0.0, imageWidth, imageWidth);

NSImage* icon = [[NSImage alloc] initWithSize:rect.size];

[icon lockFocus];

//border
rect = NSInsetRect(rect, -1.0, -1.0);
rect = NSInsetRect(rect, borderInset, borderInset);
NSBezierPath* bp = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:rect.size.width / 2 yRadius:rect.size.width / 2];
bp.lineWidth = 0;
NSGradient* gradient = [[NSGradient alloc] initWithStartingColor:[color blendedColorWithFraction:0.45 ofColor:NSColor.whiteColor]
Expand Down

0 comments on commit 98be9c0

Please sign in to comment.