This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 611
Dark Mac #380
Merged
Merged
Dark Mac #380
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
976d45a
fixes dark shell on mac going full screen
JeffryBooher bc51315
First pass at creating a custom title bar without swizzling
bobeast 4205088
various fixes and optimizations
JeffryBooher e2c36ca
fix issue with app disappearing after going full screen
JeffryBooher dbf717f
Merge branch 'master' into jeff/rework-dark-mac-from-bobeast
JeffryBooher dd08f7a
hopefully this fixes it...
JeffryBooher 59ac8f0
isolate hacks to >= 10.9
JeffryBooher 2d4b38c
update titlebar font
JeffryBooher e85b04a
update copyright thx @jasonsanjose
JeffryBooher 24cd050
fix double up on the fs button
JeffryBooher ede5832
code cleanup and fixes
JeffryBooher 10e3626
fudge
JeffryBooher 182fa08
code cleanup after refactoring
JeffryBooher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface CustomTitlebarView : NSView | ||
{ | ||
NSString *titleString; | ||
} | ||
|
||
@property (nonatomic, strong) NSString *titleString; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
#import "CustomTitlebarView.h" | ||
#import "client_colors_mac.h" | ||
|
||
#define titleTextHeight 13 | ||
|
||
@implementation CustomTitlebarView | ||
|
||
@synthesize titleString; | ||
|
||
- (void)drawRect:(NSRect)dirtyRect | ||
{ | ||
NSColorSpace *sRGB = [NSColorSpace sRGBColorSpace]; | ||
NSColor *fillColor = [NSColor colorWithColorSpace:sRGB components:fillComp count:4]; | ||
NSRect windowFrame = [NSWindow frameRectForContentRect:[[[self window] contentView] bounds] styleMask:[[self window] styleMask]]; | ||
NSRect contentBounds = [[[self window] contentView] bounds]; | ||
|
||
NSRect titlebarRect = NSMakeRect(0, 0, self.bounds.size.width, windowFrame.size.height - contentBounds.size.height); | ||
titlebarRect.origin.y = self.bounds.size.height - titlebarRect.size.height; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix indenting |
||
|
||
[[NSColor clearColor] set]; | ||
NSRectFill( titlebarRect ); | ||
|
||
[fillColor set]; | ||
|
||
[NSGraphicsContext saveGraphicsState]; | ||
//This constant matches the radius for other macosx apps. | ||
//For some reason if we use the default value it is double that of safari etc. | ||
float cornerRadius = 4.0f; | ||
|
||
// make a clip mask that is rounded on top and square on the bottom... | ||
NSBezierPath* clipPath = [NSBezierPath bezierPath]; | ||
[clipPath appendBezierPathWithRoundedRect:titlebarRect xRadius:cornerRadius yRadius:cornerRadius]; | ||
[clipPath moveToPoint: NSMakePoint(titlebarRect.origin.x, titlebarRect.origin.y)]; | ||
[clipPath appendBezierPathWithRect: NSMakeRect(titlebarRect.origin.x, titlebarRect.origin.y, titlebarRect.size.width, titlebarRect.size.height / 2)]; | ||
[clipPath addClip]; | ||
|
||
// Fill in with the Dark UI color | ||
NSRectFill(titlebarRect); | ||
|
||
|
||
NSFont *titleFont = [NSFont titleBarFontOfSize:titleTextHeight]; | ||
CGFloat stringWidth = [self widthOfString:titleString withFont:titleFont]; | ||
NSColor *activeColor = [NSColor colorWithColorSpace:sRGB components:activeComp count:4]; | ||
NSColor *inactiveColor = [NSColor colorWithColorSpace:sRGB components:inactiveComp count:4]; | ||
|
||
NSLayoutManager *lm = [[NSLayoutManager alloc] init]; | ||
int height = [lm defaultLineHeightForFont:titleFont]; | ||
|
||
// Draw the title text | ||
if (stringWidth) | ||
{ | ||
NSRect textRect = NSMakeRect(titlebarRect.origin.x + ((titlebarRect.size.width / 2) - (stringWidth / 2)), | ||
titlebarRect.origin.y + ((titlebarRect.size.height / 2) - (height / 2)) - 4, | ||
titlebarRect.size.width, | ||
titlebarRect.size.height); | ||
|
||
[titleString drawInRect:textRect withAttributes:[NSDictionary dictionaryWithObjectsAndKeys: | ||
titleFont, NSFontAttributeName, | ||
[NSApp isActive] ? activeColor : inactiveColor, | ||
NSForegroundColorAttributeName, | ||
nil]]; | ||
} | ||
|
||
[NSGraphicsContext restoreGraphicsState]; | ||
} | ||
|
||
- (CGFloat)widthOfString:(NSString *)string withFont:(NSFont *)font | ||
{ | ||
if (string == nil || [string length] == 0) | ||
return 0.0f; | ||
|
||
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]; | ||
return [[[NSAttributedString alloc] initWithString:string attributes:attributes] size].width; | ||
} | ||
|
||
#pragma mark Property accessors | ||
|
||
- (NSString *)titleString | ||
{ | ||
return titleString; | ||
} | ||
|
||
- (void)setTitleString:(NSString *)aString | ||
{ | ||
if ((!titleString && !aString) || (titleString && aString && [titleString isEqualToString:aString])) | ||
return; | ||
titleString = [aString copy]; | ||
[self setNeedsDisplay:YES]; | ||
} | ||
|
||
|
||
@end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this file extension .m and all the other Cocoa files seem to be .mm ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking, only files which contain both Objective-C AND c++ should use the .mm extension. Purely Obj-C files should use .m. It really doesn't cause runtime issues either way, but over use of .mm does slow down compile times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobeast Thanks for the explanation. Now I know which files I shouldn't touch :) .