aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m37
1 files changed, 27 insertions, 10 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index bd4233ae..2931ba9f 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -3943,17 +3943,34 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0;
if (newIsVisible == windowTitleStatusViewIsVisible) return;
if (newIsVisible) {
- NSView *windowFrame = [[parentWindow contentView] superview];
- NSRect av = [titleAccessoryView frame];
- NSRect initialAccessoryViewFrame = NSMakeRect(
- [windowFrame frame].size.width - av.size.width - 30,
- [windowFrame frame].size.height - av.size.height,
- av.size.width,
- av.size.height);
- [titleAccessoryView setFrame:initialAccessoryViewFrame];
- [windowFrame addSubview:titleAccessoryView];
+ if (NSClassFromString(@"NSTitlebarAccessoryViewController")) { // OS X 10.11 and later
+ [titleAccessoryView setFrame:NSMakeRect(0, 0, titleAccessoryView.frame.size.width, 120)]; // make it really tall, so that it's on the top right of the title/toolbar area, instead of the bottom right (AppKit will not prevent it from going behind the toolbar)
+
+ NSTitlebarAccessoryViewController *accessoryViewController = [[[NSTitlebarAccessoryViewController alloc] init] autorelease];
+ accessoryViewController.view = titleAccessoryView;
+ accessoryViewController.layoutAttribute = NSLayoutAttributeRight;
+ [parentWindow addTitlebarAccessoryViewController:accessoryViewController];
+ } else {
+ NSView *windowFrame = [[parentWindow contentView] superview];
+ NSRect av = [titleAccessoryView frame];
+ NSRect initialAccessoryViewFrame = NSMakeRect(
+ [windowFrame frame].size.width - av.size.width - 30,
+ [windowFrame frame].size.height - av.size.height,
+ av.size.width,
+ av.size.height);
+ [titleAccessoryView setFrame:initialAccessoryViewFrame];
+ [windowFrame addSubview:titleAccessoryView];
+ }
} else {
- [titleAccessoryView removeFromSuperview];
+ if (NSClassFromString(@"NSTitlebarAccessoryViewController")) { // OS X 10.11 and later
+ [parentWindow.titlebarAccessoryViewControllers enumerateObjectsUsingBlock:^(__kindof NSTitlebarAccessoryViewController * _Nonnull accessoryViewController, NSUInteger idx, BOOL * _Nonnull stop) {
+ if (accessoryViewController.view == titleAccessoryView) {
+ [parentWindow removeTitlebarAccessoryViewControllerAtIndex:idx];
+ }
+ }];
+ } else {
+ [titleAccessoryView removeFromSuperview];
+ }
}
windowTitleStatusViewIsVisible = newIsVisible;