diff options
author | rowanbeentje <rowan@beent.je> | 2013-01-05 21:59:32 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2013-01-05 21:59:32 +0000 |
commit | a3a738ea230ead792aa747e4a66ced6e8bea8562 (patch) | |
tree | 3fb47c41a7594fac74ff6e1c77158df4f334ab4f /Source/SPWindowController.m | |
parent | 8d397ab95afd68d5f9d7ecf5267c9a11a72d04c6 (diff) | |
download | sequelpro-a3a738ea230ead792aa747e4a66ced6e8bea8562.tar.gz sequelpro-a3a738ea230ead792aa747e4a66ced6e8bea8562.tar.bz2 sequelpro-a3a738ea230ead792aa747e4a66ced6e8bea8562.zip |
- Call the NSWindow super implementation of validateMenuItem: in SPWindow, fixing Show Toolbar/Hide Toolbar menu item title not being updated correctly - addresses Issue #1521
- When the toolbar is hidden, draw a line in the window to cover up the bottom border of the window's title bar, improving appearance
- Improve tab appearance when toolbar is hidden
Diffstat (limited to 'Source/SPWindowController.m')
-rw-r--r-- | Source/SPWindowController.m | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index 8bb908e2..cb7f0573 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -34,7 +34,8 @@ #if !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 enum { NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7, - NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8 + NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8, + NSFullScreenWindowMask = 1 << 14 }; #endif @@ -50,6 +51,8 @@ enum { @interface SPWindowController () - (void)_updateProgressIndicatorForItem:(NSTabViewItem *)theItem; +- (void)_createTitleBarLineHidingView; +- (void)_updateLineHidingViewState; @end @@ -61,9 +64,14 @@ enum { - (void)awakeFromNib { selectedTableDocument = nil; + systemVersion = 0; + Gestalt(gestaltSystemVersion, &systemVersion); [[self window] setCollectionBehavior:[[self window] collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary]; + // Add a line to the window to hide the line below the title bar when the toolbar is collapsed + [self _createTitleBarLineHidingView]; + // Disable automatic cascading - this occurs before the size is set, so let the app // controller apply cascading after frame autosaving. [self setShouldCascadeWindows:NO]; @@ -100,6 +108,7 @@ enum { // Register for drag start and stop notifications - used to show/hide tab bars [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabDragStarted:) name:PSMTabDragDidBeginNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabDragStopped:) name:PSMTabDragDidEndNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateLineHidingViewState) name:SPWindowToolbarDidToggleNotification object:nil]; } /** @@ -108,6 +117,7 @@ enum { - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSObject cancelPreviousPerformRequestsWithTarget:self]; // Tear down the animations on the tab bar to stop redraws [tabBar destroyAnimations]; @@ -450,4 +460,46 @@ enum { [theDocument addObserver:self forKeyPath:@"isProcessing" options:0 context:nil]; } +/** + * Create a view which is used to hide the line underneath the window title bar when the + * toolbar is hidden, improving appearance when tabs are visible (or collapsed!) + */ +- (void)_createTitleBarLineHidingView +{ + float titleBarHeight = 21.f; + NSSize windowSize = [self window].frame.size; + + titleBarLineHidingView = [[[NSClipView alloc] init] autorelease]; + + // Set the original size and the autosizing mask to preserve it + [titleBarLineHidingView setFrame:NSMakeRect(0, windowSize.height - titleBarHeight - 1, windowSize.width, 1)]; + [titleBarLineHidingView setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; + + [self _updateLineHidingViewState]; + + // Add the view to the window + [[[[self window] contentView] superview] addSubview:titleBarLineHidingView]; +} + +/** + * Update the visibility and colour of the title bar line hiding view + */ +- (void)_updateLineHidingViewState +{ + + // Set the background colour to match the titlebar window state + if ((([[self window] isMainWindow] || [[[self window] attachedSheet] isMainWindow]) && [NSApp isActive])) { + [titleBarLineHidingView setBackgroundColor:[NSColor colorWithCalibratedWhite:(systemVersion >= 0x1070)?0.66f:0.63f alpha:1.0]]; + } else { + [titleBarLineHidingView setBackgroundColor:[NSColor colorWithCalibratedWhite:(systemVersion >= 0x1070)?0.87f:0.84f alpha:1.0]]; + } + + // If the window is fullscreen or the toolbar is showing, hide the view; otherwise show it + if (([[self window] styleMask] & NSFullScreenWindowMask) || [[[self window] toolbar] isVisible] || ![[self window] toolbar]) { + [titleBarLineHidingView setHidden:YES]; + } else { + [titleBarLineHidingView setHidden:NO]; + } +} + @end |