aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPConstants.h1
-rw-r--r--Source/SPConstants.m1
-rw-r--r--Source/SPWindow.m14
-rw-r--r--Source/SPWindowController.h5
-rw-r--r--Source/SPWindowController.m54
-rw-r--r--Source/SPWindowControllerDelegate.m23
6 files changed, 94 insertions, 4 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 81a7310e..a744188a 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -397,6 +397,7 @@ extern NSString *SPDocumentTaskEndNotification;
extern NSString *SPDocumentTaskStartNotification;
extern NSString *SPDocumentWillCloseNotification;
extern NSString *SPActivitiesUpdateNotification;
+extern NSString *SPWindowToolbarDidToggleNotification;
extern NSString *SPFieldEditorSheetFont;
extern NSString *SPLastSQLFileEncoding;
extern NSString *SPPrintBackground;
diff --git a/Source/SPConstants.m b/Source/SPConstants.m
index 7dae561c..2bc3f39d 100644
--- a/Source/SPConstants.m
+++ b/Source/SPConstants.m
@@ -203,6 +203,7 @@ NSString *SPDocumentTaskEndNotification = @"DocumentTaskEnded";
NSString *SPDocumentTaskStartNotification = @"DocumentTaskStarted";
NSString *SPDocumentWillCloseNotification = @"DocumentWillClose";
NSString *SPActivitiesUpdateNotification = @"ActivitiesUpdateNotification";
+NSString *SPWindowToolbarDidToggleNotification = @"WindowToolbarWasToggledNotification";
NSString *SPFieldEditorSheetFont = @"FieldEditorSheetFont";
NSString *SPLastSQLFileEncoding = @"lastSqlFileEncoding";
NSString *SPPrintBackground = @"PrintBackground";
diff --git a/Source/SPWindow.m b/Source/SPWindow.m
index 5563235f..f4164ef2 100644
--- a/Source/SPWindow.m
+++ b/Source/SPWindow.m
@@ -170,6 +170,17 @@
}
/**
+ * Override the standard toolbar show/hide, adding a notification that can be
+ * used to update state.
+ */
+- (void)toggleToolbarShown:(id)sender
+{
+ [super toggleToolbarShown:sender];
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:SPWindowToolbarDidToggleNotification object:nil];
+}
+
+/**
* On 10.7+, allow the window to go fullscreen; do nothing on <10.7.
*/
- (void)toggleFullScreen:(id)sender
@@ -185,6 +196,9 @@
if ([menuItem action] == @selector(toggleFullScreen:)) {
return ([super respondsToSelector:@selector(toggleFullScreen:)]);
}
+ if ([super respondsToSelector:@selector(validateMenuItem:)]) {
+ return [super validateMenuItem:menuItem];
+ }
return YES;
}
diff --git a/Source/SPWindowController.h b/Source/SPWindowController.h
index 5cc84330..964cedd5 100644
--- a/Source/SPWindowController.h
+++ b/Source/SPWindowController.h
@@ -37,7 +37,10 @@
{
IBOutlet PSMTabBarControl *tabBar;
IBOutlet NSTabView *tabView;
-
+
+ NSClipView *titleBarLineHidingView;
+ SInt32 systemVersion;
+
NSMenuItem *closeWindowMenuItem;
NSMenuItem *closeTabMenuItem;
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
diff --git a/Source/SPWindowControllerDelegate.m b/Source/SPWindowControllerDelegate.m
index b4be90b5..ef52d4ef 100644
--- a/Source/SPWindowControllerDelegate.m
+++ b/Source/SPWindowControllerDelegate.m
@@ -42,6 +42,7 @@
@interface SPWindowController (SPDeclaredAPI)
- (void)_updateProgressIndicatorForItem:(NSTabViewItem *)theItem;
+- (void)_updateLineHidingViewState;
@end
@@ -113,6 +114,7 @@
*/
- (void)windowDidResignKey:(NSNotification *)notification
{
+
// Disable the "Close tab" menu item
[closeTabMenuItem setEnabled:NO];
[closeTabMenuItem setKeyEquivalent:@""];
@@ -123,6 +125,21 @@
}
/**
+ * Observe changes in main window status to update drawing state to match
+ */
+- (void)windowDidBecomeMain:(NSNotification *)notification
+{
+ [self _updateLineHidingViewState];
+}
+- (void)windowDidResignMain:(NSNotification *)notification
+{
+ [self _updateLineHidingViewState];
+
+ // Update the state again after a short delay to catch attached sheets being main
+ [self performSelector:@selector(_updateLineHidingViewState) withObject:nil afterDelay:0.1];
+}
+
+/**
* If the window is resized, notify all the tabs.
*/
- (void)windowDidResize:(NSNotification *)notification
@@ -141,6 +158,7 @@
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
[selectedTableDocument updateTitlebarStatusVisibilityForcingHide:YES];
+ [self _updateLineHidingViewState];
}
/**
@@ -149,6 +167,7 @@
- (void)windowDidExitFullScreen:(NSNotification *)notification
{
[selectedTableDocument updateTitlebarStatusVisibilityForcingHide:NO];
+ [self _updateLineHidingViewState];
}
#pragma mark -
@@ -171,9 +190,9 @@
selectedTableDocument = [tabViewItem identifier];
[selectedTableDocument didBecomeActiveTabInWindow];
-
+
if ([[self window] isKeyWindow]) [selectedTableDocument tabDidBecomeKey];
-
+
[self updateAllTabTitles:self];
}