Not changing default icons
Closed this issue · 9 comments
Is it possible that colorfulSiderbar_9
doesn't change other icons than the ones specified in icons10.plist
? I just want to set an icon for a folder but I don't wanna change other icons.
Never mind, I needed so much modifications that I ended up opening the project in XCode and doing lots of modifications to get my desired icons. I had to comment lots of lines so that it doesn't change other icons (mostly if (!image)
lines), I had to convert NSImage to CIImage and adjust brightness because icons in /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ are too sharp. and then convert it back to NSImage + some other minor modifications. Eventually I got my desired download icon (exactly looks like the native one 😄 ) thank you so much for this plugin, it couldn't be done without mySIMBL and colorfulSidebar.
Can you submit your modified config? I'd like to change some icons but not the defaults, too.
@whoaitsaimz take a look at my fork and this commit: https://github.com/sassanh/colorfulSidebar_9/commit/8c01e785f2a9cffdf4a79d6fc6853ced67950529
Note that on 10.9 I ran into this issue due to the use of TiffRepresentation. This is fixed by creating the CIImage from a CGImage directly instead of converting to the tiff intermediary:
NSImage * image = [[NSImage alloc] initWithContentsOfFile:key];
NSRect imageRect = NSMakeRect(0, 0, image.size.width, image.size.height);
CGImageRef cgImage = [image CGImageForProposedRect:&imageRect context:NULL hints:nil];
CIImage *ciImage = [[CIImage alloc] initWithCGImage:cgImage];
Also it seems native icons (in 10.9 at least) have a gradient applied to them. @sassanh How did you arrive at the filter you used? Was it just trial and error or did you reverse engineer the one used by the finder?
Well I'm on Sierra. Can't remember how I found that filter. I guess it should've been trial and error but I somehow feel I got certain that this is what Finder does itself.
Interesting. I took a look into how dropbox does its code injection for the sidebar icon on mavericks (which looks and feels exactly like native) and it turns out that if you do [image setTemplate:true];
after the addRepresentation
then the OS automatically applies the appropriate shading and highlight.
After I did this the black->white invert when the sidebar item is selected worked (exactly like it does on native icons). I recommend you add this to your fork so it is even closer to native behavior.
The only odd/interesting thing is that even with [image setTemplate:true];
you still need to apply the lightening CIFilter, albeit not as much as before. With [image setTemplate:true];
I found via experimentation that [ciFilter setValue:[NSNumber numberWithFloat:.04] forKey:@"inputBrightness"];
closely matched native icons (on mavericks at least). I'm not sure why lightening is necessary even with the system template applied, but it might be due to a difference in how the image is loaded (the dropbox bundle did some weird thing creating a CGImage from a PNG CGDataProvider that allowed for playing around with some color space/upscaling options).
For further investigation might be the NSSidebarImage class in appkit that Finder (and many other cocoa apps leverage).
Can you prepare a pull request for setTemplate: treu
?
Alright done. See https://github.com/sassanh/colorfulSidebar_9/pull/1