Changeset 5466

Show
Ignore:
Timestamp:
04/21/08 17:28:53 (4 weeks ago)
Author:
morris
Message:

Animate transitions in drill view

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Spiral/trunk/English.lproj/Drill.nib/info.nib

    r5461 r5466  
    55        <key>IBFramework Version</key> 
    66        <string>629</string> 
     7        <key>IBLastKnownRelativeProjectPath</key> 
     8        <string>../../Spiral.xcodeproj</string> 
    79        <key>IBOldestOS</key> 
    810        <integer>5</integer> 
    911        <key>IBOpenObjects</key> 
    10         <array> 
    11                 <integer>2</integer> 
    12         </array> 
     12        <array/> 
    1313        <key>IBSystem Version</key> 
    1414        <string>9C7010</string> 
  • Spiral/trunk/SPDrillListView.h

    r5461 r5466  
    22 
    33/* 
    4  *  Copyright (c) 2007 Axel Andersson 
     4 *  Copyright (c) 2008 Axel Andersson 
    55 *  All rights reserved. 
    66 *  
  • Spiral/trunk/SPDrillListView.m

    r5465 r5466  
    22 
    33/* 
    4  *  Copyright (c) 2007 Axel Andersson 
     4 *  Copyright (c) 2008 Axel Andersson 
    55 *  All rights reserved. 
    66 *  
  • Spiral/trunk/SPDrillView.h

    r5461 r5466  
    22 
    33/* 
    4  *  Copyright (c) 2007 Axel Andersson 
     4 *  Copyright (c) 2007-2008 Axel Andersson 
    55 *  All rights reserved. 
    66 *  
  • Spiral/trunk/SPDrillView.m

    r5461 r5466  
    22 
    33/* 
    4  *  Copyright (c) 2007 Axel Andersson 
     4 *  Copyright (c) 2007-2008 Axel Andersson 
    55 *  All rights reserved. 
    66 *  
     
    3636@interface SPDrillView(Private) 
    3737 
    38 - (void)_addListViewWithItem:(id)item selectCurrentItem:(BOOL)selectCurrentItem; 
     38- (void)_addListViewWithItem:(id)item transitionIn:(BOOL)transitionIn selectCurrentItem:(BOOL)selectCurrentItem; 
     39- (void)_transitionInListViewFromView:(NSView *)view; 
     40- (void)_transitionOutListViewFromView:(NSView *)view; 
     41- (void)_transitionListViewFromView:(NSView *)view frame:(NSRect)frame; 
    3942 
    4043@end 
     
    4346@implementation SPDrillView(Private) 
    4447 
    45 - (void)_addListViewWithItem:(id)item selectCurrentItem:(BOOL)selectCurrentItem { 
     48- (void)_addListViewWithItem:(id)item transitionIn:(BOOL)transitionIn selectCurrentItem:(BOOL)selectCurrentItem { 
     49        NSImageView                     *imageView; 
     50        NSImage                         *image; 
     51        NSBitmapImageRep        *imageRep; 
    4652        NSMutableArray          *drillItems; 
    4753        SPDrillItem                     *drillItem, *selectItem = NULL; 
     
    5258         
    5359        _currentListView = [[SPDrillListView alloc] initWithFrame:[SPDrillListView frameSizedToFitFromFrame:[self frame]]]; 
     60        [_currentListView setAlphaValue:0.0]; 
     61        [_currentListView setWantsLayer:YES]; 
    5462 
    5563        drillItems = [NSMutableArray array]; 
     
    7886         
    7987        [self addSubview:_currentListView]; 
    80         [previousListView removeFromSuperviewWithoutNeedingDisplay]; 
     88 
     89        if(previousListView) { 
     90                imageRep = [previousListView bitmapImageRepForCachingDisplayInRect:[previousListView visibleRect]]; 
     91                [previousListView cacheDisplayInRect:[previousListView visibleRect] toBitmapImageRep:imageRep]; 
     92                 
     93                image = [[NSImage alloc] initWithSize:[imageRep size]]; 
     94                [image addRepresentation:imageRep]; 
     95                 
     96                imageView = [[NSImageView alloc] initWithFrame:[previousListView frame]]; 
     97                [imageView setWantsLayer:YES]; 
     98                [imageView setImageScaling:NSScaleToFit]; 
     99                [imageView setImage:image]; 
     100                [self addSubview:imageView]; 
     101                 
     102                [previousListView removeFromSuperview]; 
     103                 
     104                if(transitionIn) 
     105                        [self performSelector:@selector(_transitionInListViewFromView:) withObject:imageView afterDelay:0.05]; 
     106                else 
     107                        [self performSelector:@selector(_transitionOutListViewFromView:) withObject:imageView afterDelay:0.05]; 
     108                 
     109                [imageView release]; 
     110        } else { 
     111                [_currentListView setAlphaValue:1.0]; 
     112        } 
     113         
     114        [_currentListView release]; 
     115
     116 
     117 
     118 
     119- (void)_transitionInListViewFromView:(NSView *)view { 
     120        NSRect          frame; 
     121        CGFloat         factor; 
     122         
     123        frame                           = [view frame]; 
     124        factor                          = frame.size.height / frame.size.width; 
     125        frame.origin.x          -= 150.0; 
     126        frame.origin.y          -= factor * 150.0; 
     127        frame.size.width        += 300.0; 
     128        frame.size.height       += factor * 300.0; 
     129         
     130        [self _transitionListViewFromView:view frame:frame]; 
     131
     132 
     133 
     134 
     135- (void)_transitionOutListViewFromView:(NSView *)view { 
     136        NSRect          frame; 
     137        CGFloat         factor; 
     138         
     139        frame = [view frame]; 
     140         
     141        factor                          = frame.size.height / frame.size.width; 
     142        frame.origin.x          += 150.0; 
     143        frame.origin.y          += factor * 150.0; 
     144        frame.size.width        -= 300.0; 
     145        frame.size.height       -= factor * 300.0; 
     146         
     147        [self _transitionListViewFromView:view frame:frame]; 
     148
     149 
     150 
     151 
     152- (void)_transitionListViewFromView:(NSView *)view frame:(NSRect)frame { 
     153        [NSAnimationContext beginGrouping]; 
     154        [[NSAnimationContext currentContext] setDuration:0.2]; 
     155        [[view animator] setFrame:frame]; 
     156        [[view animator] setAlphaValue:0.0]; 
     157        [[_currentListView animator] setAlphaValue:1.0]; 
     158        [NSAnimationContext endGrouping]; 
    81159} 
    82160 
     
    92170        [super dealloc]; 
    93171} 
    94  
    95172 
    96173 
     
    116193        _playlist = playlist; 
    117194         
    118         [self _addListViewWithItem:playlist selectCurrentItem:NO]; 
     195        [_currentListView removeFromSuperview]; 
     196        _currentListView = NULL; 
     197         
     198        [self _addListViewWithItem:playlist transitionIn:NO selectCurrentItem:NO]; 
    119199} 
    120200 
     
    137217                [[self delegate] drillView:self willOpenContainer:item]; 
    138218                 
    139                 [self _addListViewWithItem:item selectCurrentItem:NO]; 
     219                [self _addListViewWithItem:item transitionIn:YES selectCurrentItem:NO]; 
    140220        } 
    141221        else if([item isKindOfClass:[SPPlaylistFile class]]) { 
     
    152232         
    153233        if(parentItem) 
    154                 [self _addListViewWithItem:parentItem selectCurrentItem:YES]; 
     234                [self _addListViewWithItem:parentItem transitionIn:NO selectCurrentItem:YES]; 
    155235} 
    156236