Created
August 8, 2012 18:44
-
-
Save msingleton/3297450 to your computer and use it in GitHub Desktop.
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
- (NSRect)statusRectForWindow:(NSWindow *)window | |
{ | |
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame]; | |
NSRect statusRect = NSZeroRect; | |
StatusItemView *statusItemView = nil; | |
if ([self.delegate respondsToSelector:@selector(statusItemViewForPanelController:)]) | |
{ | |
statusItemView = [self.delegate statusItemViewForPanelController:self]; | |
} | |
if (statusItemView) | |
{ | |
statusRect = statusItemView.globalRect; | |
statusRect.origin.y = NSMinY(statusRect) - NSHeight(statusRect); | |
} | |
else | |
{ | |
statusRect.size = NSMakeSize(STATUS_ITEM_VIEW_WIDTH, [[NSStatusBar systemStatusBar] thickness]); | |
statusRect.origin.x = roundf((NSWidth(screenRect) - NSWidth(statusRect)) / 2); | |
statusRect.origin.y = NSHeight(screenRect) - NSHeight(statusRect) * 2; | |
} | |
return statusRect; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NSRect panelRect = [panel frame];
panelRect.size.width = PANEL_WIDTH;
panelRect.origin.x = roundf(NSMidX(statusRect) - NSWidth(panelRect) / 2);
panelRect.origin.y = NSMaxY(statusRect) - NSHeight(panelRect);