Skip to content

Instantly share code, notes, and snippets.

@msingleton
Created August 8, 2012 18:44
Show Gist options
  • Save msingleton/3297450 to your computer and use it in GitHub Desktop.
Save msingleton/3297450 to your computer and use it in GitHub Desktop.
- (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;
}
@msingleton
Copy link
Author

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment