Skip to content

Instantly share code, notes, and snippets.

@jarek-foksa
Last active August 29, 2015 13:59
Show Gist options
  • Save jarek-foksa/10618949 to your computer and use it in GitHub Desktop.
Save jarek-foksa/10618949 to your computer and use it in GitHub Desktop.
#import "BXWindow.h"
#import "INAppStoreWindow.h"
#import "INWindowButton.h"
#import "NSColor+hex.h"
@implementation BXWindow
-(void)awakeFromNib {
self.titleBarHeight = 24.0;
self.trafficLightButtonsLeftMargin = 8.0;
self.centerFullScreenButton = YES;
self.centerTrafficLightButtons = YES;
self.hideTitleBarInFullScreen = NO;
self.showsTitle = YES;
self.titleTextColor = [NSColor whiteColor];
self.inactiveTitleTextColor = [NSColor whiteColor];
self.titleTextShadow = [[NSShadow alloc] init];
self.inactiveTitleTextShadow = [[NSShadow alloc] init];
self.backgroundColor = [NSColor colorWithCalibratedRed:0.176 green:0.176 blue:0.176 alpha:1];
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.closeButton = closeButton;
INWindowButton *minimizeButton = [INWindowButton windowButtonWithSize:NSMakeSize(14, 16) groupIdentifier:nil];
minimizeButton.activeImage = [NSImage imageNamed:@"minimize-active-color.tiff"];
minimizeButton.activeNotKeyWindowImage = [NSImage imageNamed:@"minimize-activenokey-color.tiff"];
minimizeButton.inactiveImage = [NSImage imageNamed:@"minimize-inactive-disabled-color.tiff"];
minimizeButton.pressedImage = [NSImage imageNamed:@"minimize-pd-color.tiff"];
minimizeButton.rolloverImage = [NSImage imageNamed:@"minimize-rollover-color.tiff"];
self.minimizeButton = minimizeButton;
INWindowButton *zoomButton = [INWindowButton windowButtonWithSize:NSMakeSize(14, 16) groupIdentifier:nil];
zoomButton.activeImage = [NSImage imageNamed:@"zoom-active-color.tiff"];
zoomButton.activeNotKeyWindowImage = [NSImage imageNamed:@"zoom-activenokey-color.tiff"];
zoomButton.inactiveImage = [NSImage imageNamed:@"zoom-inactive-disabled-color.tiff"];
zoomButton.pressedImage = [NSImage imageNamed:@"zoom-pd-color.tiff"];
zoomButton.rolloverImage = [NSImage imageNamed:@"zoom-rollover-color.tiff"];
self.zoomButton = zoomButton;
if ([self collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary) {
INWindowButton *fullScreenButton = [INWindowButton windowButtonWithSize:NSMakeSize(22, 22) groupIdentifier:nil];
fullScreenButton.activeImage = [NSImage imageNamed:@"fullscreen-1.tiff"];
fullScreenButton.activeNotKeyWindowImage = [NSImage imageNamed:@"fullscreen-1.tiff"];
fullScreenButton.inactiveImage = [NSImage imageNamed:@"fullscreen-1.tiff"];
fullScreenButton.pressedImage = [NSImage imageNamed:@"fullscreen-2.tiff"];
fullScreenButton.rolloverImage = [NSImage imageNamed:@"fullscreen-2.tiff"];
self.fullScreenButton = fullScreenButton;
}
self.titleBarDrawingBlock = ^(BOOL drawsAsMainWindow, CGRect drawingRect, CGPathRef clippingPath) {
CGContextRef ctx = [[NSGraphicsContext currentContext] graphicsPort];
CGContextAddPath(ctx, clippingPath);
CGContextClip(ctx);
// Draw gradient
NSGradient *gradient = nil;
if (drawsAsMainWindow) {
NSColor *blackColor = [NSColor colorWithCalibratedRed:0.176 green:0.176 blue:0.176 alpha:1];
gradient = [[NSGradient alloc] initWithStartingColor:blackColor endingColor:blackColor];
}
else {
NSColor *grayColor = [NSColor colorWithCalibratedRed:0.276 green:0.276 blue:0.276 alpha:1];
gradient = [[NSGradient alloc] initWithStartingColor:grayColor endingColor:grayColor];
}
[gradient drawInRect:drawingRect angle:90];
// Draw bottom border
if (drawsAsMainWindow) {
[[NSColor colorFromHexString:@"#565656"] setFill];
}
else {
[[NSColor colorWithCalibratedRed:0.276 green:0.276 blue:0.276 alpha:1] setFill];
}
NSRectFill(NSMakeRect(NSMinX(drawingRect), NSMinY(drawingRect), NSWidth(drawingRect), 1));
};
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment