diff --git a/macosx/InfoWindowController.h b/macosx/InfoWindowController.h index 3298cc882..5c404e166 100644 --- a/macosx/InfoWindowController.h +++ b/macosx/InfoWindowController.h @@ -65,6 +65,7 @@ IBOutlet PiecesView * fPiecesView; IBOutlet NSSegmentedControl * fPiecesControl; float fWebSeedTableHeight, fSpaceBetweenWebSeedAndPeer; + NSViewAnimation * fWebSeedTableAnimation; IBOutlet FileOutlineController * fFileController; diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 29130111f..35ccbd90f 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -635,6 +635,19 @@ typedef enum return windowRect; } +- (NSSize) windowWillResize: (NSWindow *) window toSize: (NSSize) proposedFrameSize +{ + [fWebSeedTableAnimation stopAnimation]; + return proposedFrameSize; +} + +- (void) windowDidResize: (NSNotification *) notification +{ + //this is an edge-case - if it's reached, just safely resize the tables without animation + if (fWebSeedTableAnimation) + [self setWebSeederTableHidden: !fWebSeeds || [fWebSeeds count] == 0 animate: NO]; +} + - (void) setTab: (id) sender { int oldTabTag = fCurrentTabTag; @@ -1441,9 +1454,16 @@ typedef enum - (void) setWebSeederTableHidden: (BOOL) hide animate: (BOOL) animate { - if (/*![NSApp isOnLeopardOrBetter]*/YES) + if (![[self window] isVisible]) animate = NO; + if (fWebSeedTableAnimation) + { + [fWebSeedTableAnimation stopAnimation]; + [fWebSeedTableAnimation release]; + fWebSeedTableAnimation = nil; + } + NSRect webSeedFrame = [[fWebSeedTable enclosingScrollView] frame]; NSRect peerFrame = [[fPeerTable enclosingScrollView] frame]; @@ -1463,17 +1483,27 @@ typedef enum peerFrame.size.height = (webSeedFrame.origin.y - fSpaceBetweenWebSeedAndPeer) - peerFrame.origin.y; } + [[fWebSeedTable enclosingScrollView] setHidden: NO]; //this is needed for some reason + //actually resize tables if (animate) { - [NSAnimationContext beginGrouping]; + NSDictionary * webSeedDict = [NSDictionary dictionaryWithObjectsAndKeys: + [fWebSeedTable enclosingScrollView], NSViewAnimationTargetKey, + [NSValue valueWithRect: [[fWebSeedTable enclosingScrollView] frame]], NSViewAnimationStartFrameKey, + [NSValue valueWithRect: webSeedFrame], NSViewAnimationEndFrameKey, nil], + * peerDict = [NSDictionary dictionaryWithObjectsAndKeys: + [fPeerTable enclosingScrollView], NSViewAnimationTargetKey, + [NSValue valueWithRect: [[fPeerTable enclosingScrollView] frame]], NSViewAnimationStartFrameKey, + [NSValue valueWithRect: peerFrame], NSViewAnimationEndFrameKey, nil]; - [[NSAnimationContext currentContext] setDuration: 0.2]; + fWebSeedTableAnimation = [[NSViewAnimation alloc] initWithViewAnimations: + [NSArray arrayWithObjects: webSeedDict, peerDict, nil]]; + [fWebSeedTableAnimation setDuration: 0.2]; + [fWebSeedTableAnimation setAnimationBlockingMode: NSAnimationNonblockingThreaded]; + [fWebSeedTableAnimation setDelegate: self]; - [[[fWebSeedTable enclosingScrollView] animator] setFrame: webSeedFrame]; - [[[fPeerTable enclosingScrollView] animator] setFrame: peerFrame]; - - [NSAnimationContext endGrouping]; + [fWebSeedTableAnimation startAnimation]; } else { @@ -1482,6 +1512,15 @@ typedef enum } } +- (void) animationDidEnd: (NSAnimation *) animation +{ + if (animation == fWebSeedTableAnimation) + { + [fWebSeedTableAnimation release]; + fWebSeedTableAnimation = nil; + } +} + - (NSArray *) peerSortDescriptors { NSMutableArray * descriptors = [NSMutableArray arrayWithCapacity: 2];