Changeset 13138


Ignore:
Timestamp:
Jan 7, 2012, 9:05:02 PM (10 years ago)
Author:
livings124
Message:

Animate rearranging the queue separately from the main filter animation. This allows us to ensure that the animation shows the dragged torrents being moved instead of the torrents around them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13137 r13138  
    29112911        NSMutableArray * movingTorrents = [NSMutableArray arrayWithCapacity: [indexes count]];
    29122912        for (NSUInteger i = [indexes firstIndex]; i != NSNotFound; i = [indexes indexGreaterThanIndex: i])
    2913             [movingTorrents addObject: [fTableView itemAtRow: i]];
    2914        
    2915         //reset groups
    2916         if (item)
    2917         {
     2913        {
     2914            Torrent * torrent = [fTableView itemAtRow: i];
     2915            [movingTorrents addObject: torrent];
     2916           
    29182917            //change groups
    2919             const NSInteger groupValue = [item groupIndex];
    2920             [movingTorrents enumerateObjectsWithOptions: NSEnumerationConcurrent usingBlock: ^(id obj, NSUInteger idx, BOOL *stop)  {
    2921                 [(Torrent *)obj setGroupValue: groupValue];
    2922             }];
     2918            if (item)
     2919                [torrent setGroupValue: [item groupIndex]];
    29232920        }
    29242921       
     
    29432940           
    29442941            //insert objects at new location
    2945             NSUInteger insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0;
     2942            const NSUInteger insertIndex = topTorrent ? [fTorrents indexOfObject: topTorrent] + 1 : 0;
    29462943            NSIndexSet * insertIndexes = [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(insertIndex, [movingTorrents count])];
    29472944            [fTorrents insertObjects: movingTorrents atIndexes: insertIndexes];
     
    29542951                [torrent update];
    29552952            }
     2953           
     2954            //do the drag animation here so that the dragged torrents are the ones that are animated as moving, and not the torrents around them
     2955            const BOOL onLion = [NSApp isOnLionOrBetter];
     2956            if (onLion)
     2957                [fTableView beginUpdates];
     2958           
     2959            NSUInteger insertDisplayIndex = topTorrent ? [groupTorrents indexOfObject: topTorrent] + 1 : 0;
     2960           
     2961            for (Torrent * torrent in movingTorrents)
     2962            {
     2963                TorrentGroup * oldParent = item ? [fTableView parentForItem: torrent] : nil;
     2964                NSMutableArray * oldTorrents = oldParent ? [oldParent torrents] : fDisplayedTorrents;
     2965                const NSUInteger oldIndex = [oldTorrents indexOfObject: torrent];
     2966               
     2967                if (item == oldParent)
     2968                {
     2969                    if (oldIndex < insertDisplayIndex)
     2970                        --insertDisplayIndex;
     2971                    [oldTorrents moveObjectAtIndex: oldIndex toIndex: insertDisplayIndex];
     2972                }
     2973                else
     2974                {
     2975                    NSMutableArray * newTorrents = [(TorrentGroup *)item torrents];
     2976                    [newTorrents insertObject: torrent atIndex: insertDisplayIndex];
     2977                    [oldTorrents removeObjectAtIndex: oldIndex];
     2978                }
     2979               
     2980                if (onLion)
     2981                    [fTableView moveItemAtIndex: oldIndex inParent: oldParent toIndex: insertDisplayIndex inParent: item];
     2982               
     2983                ++insertDisplayIndex;
     2984            }
     2985           
     2986            if (onLion)
     2987                [fTableView endUpdates];
    29562988        }
    29572989       
Note: See TracChangeset for help on using the changeset viewer.