1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-10 06:02:57 +00:00

re-implement animated resizing of the web seed table, this time in a safer and 10.4-compatable way

This commit is contained in:
Mitchell Livingston 2008-06-08 04:11:29 +00:00
parent 7012831928
commit af27086420
2 changed files with 47 additions and 7 deletions

View file

@ -65,6 +65,7 @@
IBOutlet PiecesView * fPiecesView;
IBOutlet NSSegmentedControl * fPiecesControl;
float fWebSeedTableHeight, fSpaceBetweenWebSeedAndPeer;
NSViewAnimation * fWebSeedTableAnimation;
IBOutlet FileOutlineController * fFileController;

View file

@ -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];