WIP: Attempt to actually use the custom icons

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-06-11 04:17:00 -07:00
parent bfd2aee33c
commit cc2641f1f7
2 changed files with 54 additions and 19 deletions

View file

@ -28,6 +28,8 @@
NSImageView *imageView; NSImageView *imageView;
NSProgressIndicator *progressIndicator; NSProgressIndicator *progressIndicator;
NSGlassEffectContainerView *glassView API_AVAILABLE(macosx(26.0));
} }
@end @end

View file

@ -43,10 +43,18 @@ static NSString *CogCustomDockIconsReloadNotification = @"CogCustomDockIconsRelo
} }
static NSString *getBadgeName(NSString *baseName, BOOL colorfulIcons) { static NSString *getBadgeName(NSString *baseName, BOOL colorfulIcons) {
if(colorfulIcons) { if(@available(macOS 26.0, *)) {
return [baseName stringByAppendingString:@"Colorful"]; if(colorfulIcons) {
return [@"Cog26" stringByAppendingString:[baseName stringByAppendingString:@"Colorful"]];
} else {
return [@"Cog26" stringByAppendingString:baseName];
}
} else { } else {
return [baseName stringByAppendingString:@"Normal"]; if(colorfulIcons) {
return [baseName stringByAppendingString:@"Colorful"];
} else {
return [baseName stringByAppendingString:@"Normal"];
}
} }
} }
@ -137,6 +145,11 @@ static NSString *getCustomIconName(NSString *baseName) {
drawIcon = YES; drawIcon = YES;
} }
BOOL glassIcons = NO;
if(@available(macOS 26.0, *)) {
glassIcons = YES;
}
NSDockTile *dockTile = [NSApp dockTile]; NSDockTile *dockTile = [NSApp dockTile];
if(drawIcon) { if(drawIcon) {
@ -155,19 +168,29 @@ static NSString *getCustomIconName(NSString *baseName) {
NSSize badgeSize = [badgeImage size]; NSSize badgeSize = [badgeImage size];
NSImage *newDockImage = (useCustomDockIcons && !useCustomDockIconsPlaque) ? [[NSImage alloc] initWithSize:NSMakeSize(1024, 1024)] : [dockImage copy]; if(!glassIcons || useCustomDockIcons) {
[newDockImage lockFocus]; 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) fromRect:NSMakeRect(0, 0, badgeSize.width, badgeSize.height)
operation:NSCompositingOperationSourceOver operation:NSCompositingOperationSourceOver
fraction:1.0]; fraction:1.0];
[newDockImage unlockFocus]; [newDockImage unlockFocus];
imageView = [[NSImageView alloc] init]; imageView = [[NSImageView alloc] init];
[imageView setImage:newDockImage]; [imageView setImage:newDockImage];
[dockTile setContentView:imageView]; [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 = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0, 0.0, dockTile.size.width, 10.0)];
[progressIndicator setStyle:NSProgressIndicatorStyleBar]; [progressIndicator setStyle:NSProgressIndicatorStyleBar];
@ -184,9 +207,19 @@ static NSString *getCustomIconName(NSString *baseName) {
if(displayProgress) { if(displayProgress) {
if(!imageView) { 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 = [[NSImageView alloc] init];
[imageView setImage:[NSApp applicationIconImage]]; [imageView setImage:dockImage];
[dockTile setContentView:imageView]; if(@available(macOS 26.0, *)) {
[glassView setContentView:imageView];
[dockTile setContentView:glassView];
} else {
[dockTile setContentView:imageView];
}
} }
if(!progressIndicator) { if(!progressIndicator) {