indragiek / INAppStoreWindow

NSWindow subclass with a highly customizable title bar and traffic lights
BSD 2-Clause "Simplified" License
1.06k stars 162 forks source link

Question: How to care about custom traffic lights on retina system? #175

Closed orklann closed 10 years ago

orklann commented 10 years ago

Hi all, I need to setup all three traffic lights button with OS X 10.10's traffic lights style by replacing the images like this code:

INWindowButton *closeButton = [INWindowButton windowButtonWithSize:NSMakeSize(14, 16) groupIdentifier:nil];
closeButton.activeImage = [NSImage imageNamed:@"close-active-color.tiff"];
closeButton.activeNotKeyWindowImage = [NSImage imageNamed:@"close-activenokey-color.tiff"];
closeButton.inactiveImage = [NSImage imageNamed:@"close-inactive-disabled-color.tiff"];
closeButton.pressedImage = [NSImage imageNamed:@"close-pd-color.tiff"];
closeButton.rolloverImage = [NSImage imageNamed:@"close-rollover-color.tiff"];
self.window.closeButton = closeButton;

Do i need to check what system my app is running on and detect if it's a retina display and use 2x size of images for this purpose, or just use the same images.

indragiek commented 10 years ago

When using +[NSImage imageNamed:] you shouldn't specify the filename extension. It will then automatically choose the right image for the screen scale factor assuming you've included both 1x and 2x versions of your assets. For example, for close-active-color.tiff, you should include the images close-active-color.tiff and close-active-color@2x.tiff in your app, then use [NSImage imageNamed:@"close-active-color"] to load the image, which will automatically select the right version.

You're correct in that you would want to check whether your app is running on 10.10 or an older version in order to determine which traffic light images you should use.