From 0ce7f983fad694c57aff9217666435685dea5e05 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 10 Nov 2009 00:22:43 +0000 Subject: - 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 --- .../English.lproj/ProgressIndicatorLayer.xib | 401 ++++++++++++--------- Source/TableDocument.h | 5 +- Source/TableDocument.m | 83 ++++- Source/TablesList.m | 5 + Source/YRKSpinningProgressIndicator.m | 1 + 5 files changed, 313 insertions(+), 182 deletions(-) diff --git a/Interfaces/English.lproj/ProgressIndicatorLayer.xib b/Interfaces/English.lproj/ProgressIndicatorLayer.xib index c63e9c95..33adda95 100644 --- a/Interfaces/English.lproj/ProgressIndicatorLayer.xib +++ b/Interfaces/English.lproj/ProgressIndicatorLayer.xib @@ -53,174 +53,130 @@ 301 YES - + - 18 + 45 YES - - + + 256 YES - - - 45 - - YES - - - 256 - - YES - - - 274 - {{50, 84}, {160, 160}} - - YES - - 1 - -1 - 1 - - 3 - MAA - - - 2 - YRKSpinningProgressIndicator - - - - 290 - {{13, 34}, {234, 42}} - - YES - - 1 - -1 - 2 - - - 2 - YES - - 67239424 - 138678272 - Multiline Label - - LucidaGrande-Bold - 13 - 16 - - - - 1 - MCAwIDAAA - - - 3 - MQA - - - - - - -2147483358 - {{89, 4}, {81, 28}} - - YES - - 67239424 - 134348800 - Cancel - - LucidaGrande - 11 - 3100 - - - -2038284033 - 268435585 - - . - 200 - 25 - - - - {260, 260} - + + + 274 + {{50, 84}, {160, 160}} + + YES + + 1 + -1 + 1 + + 3 + MAA - {{70, 48}, {260, 260}} - - {0, 0} - + 2 + YRKSpinningProgressIndicator + + + + 290 + {{13, 34}, {234, 42}} + + YES + + 1 + -1 + 2 + + + 2 + YES + 67239424 - 0 - Box - - - 6 - System - textBackgroundColor - + 138678272 + Multiline Label + + LucidaGrande-Bold + 13 + 16 - + + + 1 + MCAwIDAAA + + 3 - MCAwLjgwMDAwMDAxMTkAA + MQA - - 0 - 4 - 0 - NO - - 15 - - 3 - MCAwLjUAA + + + + -2147483358 + {{89, 4}, {81, 28}} + + YES + + 67239424 + 134348800 + Cancel + + LucidaGrande + 11 + 3100 + + + -2038284033 + 268435585 + + . + 200 + 25 - {400, 349} - + {260, 260} + - {400, 349} + {260, 260} {0, 0} 67239424 0 - Background + Box - + + 6 + System + textBackgroundColor + + 3 MCAwLjgwMDAwMDAxMTkAA - - 1 + + 0 4 0 NO - - 3 - MCAwAA - + 15 - 1 - MSAxIDEgMAA + 3 + MCAwLjUAA - {400, 349} + {260, 260} 2 NSView @@ -237,14 +193,6 @@ 23 - - - taskProgressLayer - - - - 24 - taskProgressIndicator @@ -261,6 +209,14 @@ 33 + + + taskProgressLayer + + + + 34 + @@ -292,20 +248,11 @@ 1 - - YES - - - - - - 19 - YES - + 10 @@ -316,7 +263,7 @@ - + 17 @@ -339,9 +286,6 @@ 11 - - YES - @@ -381,7 +325,6 @@ 16.IBPluginDependency 17.IBPluginDependency 18.IBPluginDependency - 19.IBPluginDependency YES @@ -395,7 +338,7 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{309, 442}, {400, 349}} + {{393, 332}, {260, 260}} com.apple.InterfaceBuilder.CocoaPlugin {628, 654} {{357, 416}, {480, 272}} @@ -412,7 +355,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.brandonwalkin.BWToolkit com.brandonwalkin.BWToolkit - com.apple.InterfaceBuilder.CocoaPlugin @@ -431,11 +373,18 @@ - 33 + 34 YES + + NSDictionary + + IBProjectSource + Source/NSDictionary_DeepMutableCopy.h + + NSObject @@ -545,6 +494,56 @@ Source/SPWindowAdditions.h + + SPUserManager + NSWindowController + + YES + + YES + addHost: + addUser: + checkAllPrivileges: + doApply: + doCancel: + removeHost: + removeUser: + uncheckAllPrivileges: + + + YES + id + id + id + id + id + id + id + id + + + + YES + + YES + outlineView + privsSupportedByServer + tabView + treeController + + + YES + NSOutlineView + NSMutableDictionary + NSTabView + NSTreeController + + + + IBProjectSource + Source/SPUserManager.h + + TableDocument NSDocument @@ -560,7 +559,6 @@ checksumTable: chooseDatabase: chooseEncoding: - closeDatabaseSheet: closeErrorConnectionSheet: closePanelSheet: closePasswordSheet: @@ -638,7 +636,6 @@ id id id - id @@ -699,6 +696,7 @@ titleAccessoryView titleImageView titleStringView + userManagerInstance variablesCountTextField variablesSearchField variablesSheet @@ -760,6 +758,7 @@ id id id + SPUserManager NSTextField NSSearchField id @@ -888,6 +887,36 @@ AppKit.framework/Headers/NSControl.h + + NSController + NSObject + + IBFrameworkSource + AppKit.framework/Headers/NSController.h + + + + NSDictionary + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSDictionary.h + + + + NSDictionary + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSDictionary + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + NSDocument NSObject @@ -940,6 +969,15 @@ AppKit.framework/Headers/NSMenu.h + + NSMutableDictionary + NSDictionary + + + + NSMutableDictionary + + NSObject @@ -1011,7 +1049,7 @@ NSObject - + IBFrameworkSource AppKit.framework/Headers/NSOutlineView.h @@ -1074,17 +1112,11 @@ NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - + NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - + NSObject @@ -1275,6 +1307,19 @@ WebKit.framework/Headers/WebUIDelegate.h + + NSObjectController + NSController + + IBFrameworkSource + AppKit.framework/Headers/NSObjectController.h + + + + NSOutlineView + NSTableView + + NSPopUpButton NSButton @@ -1367,6 +1412,14 @@ AppKit.framework/Headers/NSTextView.h + + NSTreeController + NSObjectController + + IBFrameworkSource + AppKit.framework/Headers/NSTreeController.h + + NSView @@ -1415,6 +1468,18 @@ AppKit.framework/Headers/NSWindowScripting.h + + NSWindowController + NSResponder + + showWindow: + id + + + IBFrameworkSource + AppKit.framework/Headers/NSWindowController.h + + 0 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]; -- cgit v1.2.3