Changeset 6081


Ignore:
Timestamp:
Jun 8, 2008, 4:11:29 AM (14 years ago)
Author:
livings124
Message:

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

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.h

    r6079 r6081  
    6666    IBOutlet NSSegmentedControl * fPiecesControl;
    6767    float fWebSeedTableHeight, fSpaceBetweenWebSeedAndPeer;
     68    NSViewAnimation * fWebSeedTableAnimation;
    6869   
    6970    IBOutlet FileOutlineController * fFileController;
  • trunk/macosx/InfoWindowController.m

    r6080 r6081  
    636636}
    637637
     638- (NSSize) windowWillResize: (NSWindow *) window toSize: (NSSize) proposedFrameSize
     639{
     640    [fWebSeedTableAnimation stopAnimation];
     641    return proposedFrameSize;
     642}
     643
     644- (void) windowDidResize: (NSNotification *) notification
     645{
     646    //this is an edge-case - if it's reached, just safely resize the tables without animation
     647    if (fWebSeedTableAnimation)
     648        [self setWebSeederTableHidden: !fWebSeeds || [fWebSeeds count] == 0 animate: NO];
     649}
     650
    638651- (void) setTab: (id) sender
    639652{
     
    14421455- (void) setWebSeederTableHidden: (BOOL) hide animate: (BOOL) animate
    14431456{
    1444     if (/*![NSApp isOnLeopardOrBetter]*/YES)
     1457    if (![[self window] isVisible])
    14451458        animate = NO;
     1459   
     1460    if (fWebSeedTableAnimation)
     1461    {
     1462        [fWebSeedTableAnimation stopAnimation];
     1463        [fWebSeedTableAnimation release];
     1464        fWebSeedTableAnimation = nil;
     1465    }
    14461466   
    14471467    NSRect webSeedFrame = [[fWebSeedTable enclosingScrollView] frame];
     
    14641484    }
    14651485   
     1486    [[fWebSeedTable enclosingScrollView] setHidden: NO]; //this is needed for some reason
     1487   
    14661488    //actually resize tables
    14671489    if (animate)
    14681490    {
    1469         [NSAnimationContext beginGrouping];
    1470        
    1471         [[NSAnimationContext currentContext] setDuration: 0.2];
    1472        
    1473         [[[fWebSeedTable enclosingScrollView] animator] setFrame: webSeedFrame];
    1474         [[[fPeerTable enclosingScrollView] animator] setFrame: peerFrame];
    1475        
    1476         [NSAnimationContext endGrouping];
     1491        NSDictionary * webSeedDict = [NSDictionary dictionaryWithObjectsAndKeys:
     1492                        [fWebSeedTable enclosingScrollView], NSViewAnimationTargetKey,
     1493                        [NSValue valueWithRect: [[fWebSeedTable enclosingScrollView] frame]], NSViewAnimationStartFrameKey,
     1494                        [NSValue valueWithRect: webSeedFrame], NSViewAnimationEndFrameKey, nil],
     1495                    * peerDict = [NSDictionary dictionaryWithObjectsAndKeys:
     1496                        [fPeerTable enclosingScrollView], NSViewAnimationTargetKey,
     1497                        [NSValue valueWithRect: [[fPeerTable enclosingScrollView] frame]], NSViewAnimationStartFrameKey,
     1498                        [NSValue valueWithRect: peerFrame], NSViewAnimationEndFrameKey, nil];
     1499       
     1500        fWebSeedTableAnimation = [[NSViewAnimation alloc] initWithViewAnimations:
     1501                                        [NSArray arrayWithObjects: webSeedDict, peerDict, nil]];
     1502        [fWebSeedTableAnimation setDuration: 0.2];
     1503        [fWebSeedTableAnimation setAnimationBlockingMode: NSAnimationNonblockingThreaded];
     1504        [fWebSeedTableAnimation setDelegate: self];
     1505       
     1506        [fWebSeedTableAnimation startAnimation];
    14771507    }
    14781508    else
     
    14801510        [[fWebSeedTable enclosingScrollView] setFrame: webSeedFrame];
    14811511        [[fPeerTable enclosingScrollView] setFrame: peerFrame];
     1512    }
     1513}
     1514
     1515- (void) animationDidEnd: (NSAnimation *) animation
     1516{
     1517    if (animation == fWebSeedTableAnimation)
     1518    {
     1519        [fWebSeedTableAnimation release];
     1520        fWebSeedTableAnimation = nil;
    14821521    }
    14831522}
Note: See TracChangeset for help on using the changeset viewer.