WIP: Attempt to actually use the custom icons
Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
55c2ff0322
commit
f4cdfb6cbc
2 changed files with 54 additions and 19 deletions
|
@ -28,6 +28,8 @@
|
|||
|
||||
NSImageView *imageView;
|
||||
NSProgressIndicator *progressIndicator;
|
||||
|
||||
NSGlassEffectContainerView *glassView API_AVAILABLE(macosx(26.0));
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -43,12 +43,20 @@ static NSString *CogCustomDockIconsReloadNotification = @"CogCustomDockIconsRelo
|
|||
}
|
||||
|
||||
static NSString *getBadgeName(NSString *baseName, BOOL colorfulIcons) {
|
||||
if(@available(macOS 26.0, *)) {
|
||||
if(colorfulIcons) {
|
||||
return [@"Cog26" stringByAppendingString:[baseName stringByAppendingString:@"Colorful"]];
|
||||
} else {
|
||||
return [@"Cog26" stringByAppendingString:baseName];
|
||||
}
|
||||
} else {
|
||||
if(colorfulIcons) {
|
||||
return [baseName stringByAppendingString:@"Colorful"];
|
||||
} else {
|
||||
return [baseName stringByAppendingString:@"Normal"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static NSString *getCustomIconName(NSString *baseName) {
|
||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
|
||||
|
@ -137,6 +145,11 @@ static NSString *getCustomIconName(NSString *baseName) {
|
|||
drawIcon = YES;
|
||||
}
|
||||
|
||||
BOOL glassIcons = NO;
|
||||
if(@available(macOS 26.0, *)) {
|
||||
glassIcons = YES;
|
||||
}
|
||||
|
||||
NSDockTile *dockTile = [NSApp dockTile];
|
||||
|
||||
if(drawIcon) {
|
||||
|
@ -155,10 +168,11 @@ static NSString *getCustomIconName(NSString *baseName) {
|
|||
|
||||
NSSize badgeSize = [badgeImage size];
|
||||
|
||||
NSImage *newDockImage = (useCustomDockIcons && !useCustomDockIconsPlaque) ? [[NSImage alloc] initWithSize:NSMakeSize(1024, 1024)] : [dockImage copy];
|
||||
if(!glassIcons || useCustomDockIcons) {
|
||||
NSImage *newDockImage = (useCustomDockIcons && !useCustomDockIconsPlaque) ? [[NSImage alloc] initWithSize:NSMakeSize(2048, 2048)] : [dockImage copy];
|
||||
[newDockImage lockFocus];
|
||||
|
||||
[badgeImage drawInRect:NSMakeRect(0, 0, 1024, 1024)
|
||||
[badgeImage drawInRect:NSMakeRect(0, 0, 2048, 2048)
|
||||
fromRect:NSMakeRect(0, 0, badgeSize.width, badgeSize.height)
|
||||
operation:NSCompositingOperationSourceOver
|
||||
fraction:1.0];
|
||||
|
@ -168,6 +182,15 @@ static NSString *getCustomIconName(NSString *baseName) {
|
|||
imageView = [[NSImageView alloc] init];
|
||||
[imageView setImage:newDockImage];
|
||||
[dockTile setContentView:imageView];
|
||||
} else {
|
||||
if (@available(macOS 26.0, *)) {
|
||||
glassView = [[NSGlassEffectContainerView alloc] initWithFrame:NSMakeRect(0, 0, badgeSize.width, badgeSize.height)];
|
||||
}
|
||||
imageView = [[NSImageView alloc] init];
|
||||
[imageView setImage:badgeImage];
|
||||
[glassView setContentView:imageView];
|
||||
[dockTile setContentView:glassView];
|
||||
}
|
||||
|
||||
progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0, 0.0, dockTile.size.width, 10.0)];
|
||||
[progressIndicator setStyle:NSProgressIndicatorStyleBar];
|
||||
|
@ -184,10 +207,20 @@ static NSString *getCustomIconName(NSString *baseName) {
|
|||
|
||||
if(displayProgress) {
|
||||
if(!imageView) {
|
||||
NSImage *dockImage = [NSApp applicationIconImage];
|
||||
NSSize size = [dockImage size];
|
||||
if(@available(macOS 26.0, *)) {
|
||||
glassView = [[NSGlassEffectContainerView alloc] initWithFrame:NSMakeRect(0, 0, size.width, size.height)];
|
||||
}
|
||||
imageView = [[NSImageView alloc] init];
|
||||
[imageView setImage:[NSApp applicationIconImage]];
|
||||
[imageView setImage:dockImage];
|
||||
if(@available(macOS 26.0, *)) {
|
||||
[glassView setContentView:imageView];
|
||||
[dockTile setContentView:glassView];
|
||||
} else {
|
||||
[dockTile setContentView:imageView];
|
||||
}
|
||||
}
|
||||
|
||||
if(!progressIndicator) {
|
||||
progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0, 0.0, dockTile.size.width, 10.0)];
|
||||
|
|
Loading…
Reference in a new issue