aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPConnectionController.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-09-09 01:29:35 +0000
committerrowanbeentje <rowan@beent.je>2010-09-09 01:29:35 +0000
commitcc99469638a22d68a01650bf36adc3b99ae817d1 (patch)
treef1e37f683ad530f725bda1bdab8617c19681b52b /Source/SPConnectionController.m
parenta52f4ee50f43aa8d269326dac045809cd873547d (diff)
downloadsequelpro-cc99469638a22d68a01650bf36adc3b99ae817d1.tar.gz
sequelpro-cc99469638a22d68a01650bf36adc3b99ae817d1.tar.bz2
sequelpro-cc99469638a22d68a01650bf36adc3b99ae817d1.zip
- Alter the connection view layout, moving the connection details forms into a scrollview. Switch to centering the form in code, which allows better control and automatic scrollview triggering if the window is too small.
- Reduce the minimum window size to 700x400, addressing Issue #788, now the connection view is no longer the constraining factor.
Diffstat (limited to 'Source/SPConnectionController.m')
-rw-r--r--Source/SPConnectionController.m33
1 files changed, 32 insertions, 1 deletions
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index a0ee7786..258a0b0f 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -102,7 +102,8 @@
[databaseConnectionSuperview addSubview:connectionView];
[connectionSplitView setPosition:[[tableDocument valueForKey:@"dbTablesTableView"] frame].size.width-6 ofDividerAtIndex:0];
[connectionSplitViewButtonBar setSplitViewDelegate:self];
-
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scrollViewFrameChanged:) name:NSViewFrameDidChangeNotification object:nil];
+
// Set up a keychain instance and preferences reference, and create the initial favorites list
keychain = [[SPKeychain alloc] init];
prefs = [[NSUserDefaults standardUserDefaults] retain];
@@ -143,6 +144,7 @@
- (void) dealloc
{
[prefs removeObserver:self forKeyPath:SPFavorites];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
[keychain release];
[prefs release];
@@ -573,6 +575,35 @@
}
/**
+ * As the scrollview resizes, keep the details centered within it if
+ * the detail frame is larger than the scrollview size; otherwise, pin
+ * the detail frame to the top of the scrollview.
+ */
+- (void)scrollViewFrameChanged:(NSNotification *)aNotification
+{
+ NSRect scrollViewFrame = [connectionDetailsScrollView frame];
+ NSRect scrollDocumentFrame = [[connectionDetailsScrollView documentView] frame];
+ NSRect connectionDetailsFrame = [connectionResizeContainer frame];
+
+ // Scroll view is smaller than contents - keep positioned at top.
+ if (scrollViewFrame.size.height < connectionDetailsFrame.size.height + 10) {
+ if (connectionDetailsFrame.origin.y != 0) {
+ connectionDetailsFrame.origin.y = 0;
+ [connectionResizeContainer setFrame:connectionDetailsFrame];
+ scrollDocumentFrame.size.height = connectionDetailsFrame.size.height + 10;
+ [[connectionDetailsScrollView documentView] setFrame:scrollDocumentFrame];
+ }
+
+ // Otherwise, center.
+ } else {
+ connectionDetailsFrame.origin.y = (scrollViewFrame.size.height - connectionDetailsFrame.size.height)/3;
+ [connectionResizeContainer setFrame:connectionDetailsFrame];
+ scrollDocumentFrame.size.height = scrollViewFrame.size.height;
+ [[connectionDetailsScrollView documentView] setFrame:scrollDocumentFrame];
+ }
+}
+
+/**
* When a favorite is selected, and the connection details are edited, deselect the favorite;
* this is clearer and also prevents a failed connection from being repopulated with the
* favorite's details instead of the last used details.