aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAbhi Beckert <me@abhibeckert.com>2016-06-05 12:07:41 +1000
committerAbhi Beckert <me@abhibeckert.com>2016-06-05 12:07:41 +1000
commit50a0f185400bb4dd315000e3e7488798f0c48b23 (patch)
tree864ba8218866af449f1be0636810c57fc5291063 /Source
parent7bdd7a0a30db584c1818b34cca18ad5269b57268 (diff)
downloadsequelpro-50a0f185400bb4dd315000e3e7488798f0c48b23.tar.gz
sequelpro-50a0f185400bb4dd315000e3e7488798f0c48b23.tar.bz2
sequelpro-50a0f185400bb4dd315000e3e7488798f0c48b23.zip
#2434 now use NSTitlebarAccessoryViewController if available
Diffstat (limited to 'Source')
-rw-r--r--Source/SPDatabaseDocument.h2
-rw-r--r--Source/SPDatabaseDocument.m37
2 files changed, 28 insertions, 11 deletions
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h
index c708cd9f..6596ca8c 100644
--- a/Source/SPDatabaseDocument.h
+++ b/Source/SPDatabaseDocument.h
@@ -106,7 +106,7 @@
IBOutlet NSView *parentView;
- IBOutlet id titleAccessoryView;
+ IBOutlet NSView *titleAccessoryView;
IBOutlet id titleImageView;
IBOutlet id titleStringView;
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;