aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-11-10 00:22:43 +0000
committerrowanbeentje <rowan@beent.je>2009-11-10 00:22:43 +0000
commit0ce7f983fad694c57aff9217666435685dea5e05 (patch)
tree281d98e3572d4127b1150703cc03c1fdc393f1a6 /Source
parentf04ce0c7a9266238d3391f03c9193ca92071812e (diff)
downloadsequelpro-0ce7f983fad694c57aff9217666435685dea5e05.tar.gz
sequelpro-0ce7f983fad694c57aff9217666435685dea5e05.tar.bz2
sequelpro-0ce7f983fad694c57aff9217666435685dea5e05.zip
- Fix an issue when switching databases - allow the table selection to be cleared/reset as necessary
- Move the task progress layer to a child window, which can then be faded in - smooths the visual appearance and fixes drawing artifacts
Diffstat (limited to 'Source')
-rw-r--r--Source/TableDocument.h5
-rw-r--r--Source/TableDocument.m83
-rw-r--r--Source/TablesList.m5
-rw-r--r--Source/YRKSpinningProgressIndicator.m1
4 files changed, 80 insertions, 14 deletions
diff --git a/Source/TableDocument.h b/Source/TableDocument.h
index 34df12f8..843bb9c3 100644
--- a/Source/TableDocument.h
+++ b/Source/TableDocument.h
@@ -139,11 +139,13 @@ enum sp_current_query_mode
BOOL databaseListIsSelectable;
int _queryMode;
+ NSWindow *taskProgressWindow;
BOOL taskDisplayIsIndeterminate;
float taskProgressValue;
float taskDisplayLastValue;
float taskProgressValueDisplayInterval;
NSTimer *taskDrawTimer;
+ NSViewAnimation *taskFadeAnimator;
NSToolbar *mainToolbar;
NSToolbarItem *chooseDatabaseToolbarItem;
@@ -186,13 +188,14 @@ enum sp_current_query_mode
// Task progress and notification methods
- (void) startTaskWithDescription:(NSString *)description;
-- (void) showTaskProgressLayer:(NSTimer *)theTimer;
+- (void) showTaskProgressWindow:(NSTimer *)theTimer;
- (void) setTaskDescription:(NSString *)description;
- (void) setTaskPercentage:(float)taskPercentage;
- (void) setTaskProgressToIndeterminate;
- (void) endTask;
- (BOOL) isWorking;
- (void) setDatabaseListIsSelectable:(BOOL)isSelectable;
+- (void) centerTaskWindow;
// Encoding methods
- (void)setConnectionEncoding:(NSString *)mysqlEncoding reloadingViews:(BOOL)reloadViews;
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index b0f11df2..11a2c102 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -96,11 +96,13 @@
spfPreferences = [[NSMutableDictionary alloc] init];
spfDocData = [[NSMutableDictionary alloc] init];
+ taskProgressWindow = nil;
taskDisplayIsIndeterminate = YES;
taskDisplayLastValue = 0;
taskProgressValue = 0;
taskProgressValueDisplayInterval = 1;
taskDrawTimer = nil;
+ taskFadeAnimator = nil;
keyChainID = nil;
@@ -211,10 +213,14 @@
NSLog(@"Progress indicator layer could not be loaded; progress display will not function correctly.");
}
- // Set up the progress indicator layer - add to main window, change indicator color and size
- [taskProgressLayer setHidden:YES];
- [taskProgressLayer setFrame:[contentViewSplitter frame]];
- [[tableWindow contentView] addSubview:taskProgressLayer positioned:NSWindowAbove relativeTo:contentViewSplitter];
+ // Set up the progress indicator child window and later - add to main window, change indicator color and size
+ taskProgressWindow = [[NSWindow alloc] initWithContentRect:[taskProgressLayer bounds] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
+ [taskProgressWindow setOpaque:NO];
+ [taskProgressWindow setIgnoresMouseEvents:YES];
+ [taskProgressWindow setBackgroundColor:[NSColor clearColor]];
+ [taskProgressWindow setAlphaValue:0.0];
+ [[taskProgressWindow contentView] addSubview:taskProgressLayer];
+ [tableWindow addChildWindow:taskProgressWindow ordered:NSWindowAbove];
[taskProgressIndicator setForeColor:[NSColor whiteColor]];
}
@@ -1183,9 +1189,18 @@
- (void) startTaskWithDescription:(NSString *)description
{
- // Increment the working level and set the task text
+ // Set the task text. If a nil string was supplied, a generic query notification is occurring -
+ // if a task is not already active, use default text.
+ if (!description) {
+ if (!_isWorkingLevel) [taskDescriptionText setStringValue:NSLocalizedString(@"Working...", @"Generic working description")];
+
+ // Otherwise display the supplied string
+ } else {
+ [taskDescriptionText setStringValue:description];
+ }
+
+ // Increment the task level
_isWorkingLevel++;
- [taskDescriptionText setStringValue:description];
// Reset the progress indicator if necessary
if (_isWorkingLevel == 1 || !taskDisplayIsIndeterminate) {
@@ -1204,21 +1219,30 @@
databaseListIsSelectable = NO;
[[NSNotificationCenter defaultCenter] postNotificationName:SPDocumentTaskStartNotification object:self];
- // Set the descriptive label and schedule appearance in the near future
- taskDrawTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(showTaskProgressLayer:) userInfo:nil repeats:NO] retain];
+ // Schedule appearance of the task window in the near future
+ taskDrawTimer = [[NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(showTaskProgressWindow:) userInfo:nil repeats:NO] retain];
}
}
/**
- * Show the task progress layer - after a small delay to minimise flicker.
+ * Show the task progress window, after a small delay to minimise flicker.
*/
-- (void) showTaskProgressLayer:(NSTimer *)theTimer
+- (void) showTaskProgressWindow:(NSTimer *)theTimer
{
- [taskProgressLayer setHidden:NO];
- [taskProgressLayer display];
[taskDrawTimer release], taskDrawTimer = nil;
+
+ // Center the task window and fade it in
+ [self centerTaskWindow];
+ NSDictionary *animationDetails = [NSDictionary dictionaryWithObjectsAndKeys:
+ NSViewAnimationFadeInEffect, NSViewAnimationEffectKey,
+ taskProgressWindow, NSViewAnimationTargetKey,
+ nil];
+ taskFadeAnimator = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:animationDetails]];
+ [taskFadeAnimator setDuration:0.6];
+ [taskFadeAnimator startAnimation];
}
+
/**
* Updates the task description shown to the user.
*/
@@ -1275,9 +1299,15 @@
// Cancel the draw timer if it exists
if (taskDrawTimer) [taskDrawTimer invalidate], [taskDrawTimer release], taskDrawTimer = nil;
+ // Cancel the fade-in animator if it exists
+ if (taskFadeAnimator) {
+ if ([taskFadeAnimator isAnimating]) [taskFadeAnimator stopAnimation];
+ [taskFadeAnimator release], taskFadeAnimator = nil;
+ }
+
// Hide the task interface
if (taskDisplayIsIndeterminate) [taskProgressIndicator stopAnimation:self];
- [taskProgressLayer setHidden:YES];
+ [taskProgressWindow setAlphaValue:0.0];
// Re-enable window interface
[historyControl setEnabled:YES];
@@ -1304,6 +1334,21 @@
databaseListIsSelectable = isSelectable;
}
+/**
+ * Reposition the task window within the main window.
+ */
+- (void) centerTaskWindow
+{
+ NSPoint newBottomLeftPoint;
+ NSRect mainWindowRect = [tableWindow frame];
+ NSRect taskWindowRect = [taskProgressWindow frame];
+
+ newBottomLeftPoint.x = round(mainWindowRect.origin.x + mainWindowRect.size.width/2 - taskWindowRect.size.width/2);
+ newBottomLeftPoint.y = round(mainWindowRect.origin.y + mainWindowRect.size.height/2 - taskWindowRect.size.height/2);
+
+ [taskProgressWindow setFrameOrigin:newBottomLeftPoint];
+}
+
#pragma mark -
#pragma mark Encoding Methods
@@ -3391,6 +3436,16 @@
return YES;
}
+/**
+ * Invoked when the document window is resized
+ */
+- (void)windowDidResize:(NSNotification *)notification
+{
+
+ // If the task interface is visible, re-center the task child window
+ if (_isWorkingLevel) [self centerTaskWindow];
+}
+
/*
* Invoked if user chose "Save" from 'Do you want save changes you made...' sheet
* which is called automatically if [self isDocumentEdited] == YES and user wanted to close an Untitled doc.
@@ -3638,10 +3693,12 @@
if (mySQLVersion) [mySQLVersion release];
[allDatabases release];
if (taskDrawTimer) [taskDrawTimer release];
+ if (taskFadeAnimator) [taskFadeAnimator release];
if(queryEditorInitString) [queryEditorInitString release];
if(spfSession) [spfSession release];
if(spfDocData) [spfDocData release];
if(keyChainID) [keyChainID release];
+ if (taskProgressWindow) [taskProgressWindow release];
[super dealloc];
}
diff --git a/Source/TablesList.m b/Source/TablesList.m
index fbbd412c..5bba8be5 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -63,6 +63,7 @@
int i;
NSString *previousSelectedTable = nil;
NSInteger selectedRowIndex;
+ BOOL previousTableListIsSelectable = tableListIsSelectable;
selectedRowIndex = [tablesListView selectedRow];
@@ -76,7 +77,9 @@
}
tableListContainsViews = NO;
+ tableListIsSelectable = YES;
[tablesListView deselectAll:self];
+ tableListIsSelectable = previousTableListIsSelectable;
[tables removeAllObjects];
[tableTypes removeAllObjects];
@@ -216,7 +219,9 @@
// if the previous selected table still exists, select it
if( previousSelectedTable != nil && [tables indexOfObject:previousSelectedTable] < [tables count]) {
int itemToReselect = [tables indexOfObject:previousSelectedTable];
+ tableListIsSelectable = YES;
[tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:itemToReselect] byExtendingSelection:NO];
+ tableListIsSelectable = previousTableListIsSelectable;
if (selectedTableName) [selectedTableName release];
selectedTableName = [[NSString alloc] initWithString:[tables objectAtIndex:itemToReselect]];
selectedTableType = [[tableTypes objectAtIndex:itemToReselect] intValue];
diff --git a/Source/YRKSpinningProgressIndicator.m b/Source/YRKSpinningProgressIndicator.m
index 935d613c..4d211be3 100644
--- a/Source/YRKSpinningProgressIndicator.m
+++ b/Source/YRKSpinningProgressIndicator.m
@@ -192,6 +192,7 @@
- (void)startAnimation:(id)sender
{
+ if (_isAnimating) return;
_isAnimating = YES;
_animationThread = [[NSThread alloc] initWithTarget:self selector:@selector(animateInBackgroundThread) object:nil];