Ignore:
Timestamp:
May 30, 2011, 12:09:22 AM (11 years ago)
Author:
livings124
Message:

instead of displaying a star for multiple priorities, display all relevant icons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FilePriorityCell.m

    r12445 r12473  
    2828#import "NSApplicationAdditions.h"
    2929#import "Torrent.h"
     30
     31#define IMAGE_OVERLAP 3.0
    3032
    3133@implementation FilePriorityCell
     
    124126    else
    125127    {
    126         NSImage * image;
     128        NSMutableArray * images = [NSMutableArray arrayWithCapacity: MAX(count, 1)];
     129        CGFloat totalWidth;
     130       
    127131        if (count == 0)
    128             image = [NSImage imageNamed: @"PriorityNone.png"];
    129         else if (count > 1)
    130             image = [NSImage imageNamed: @"PriorityMixed.png"];
     132        {
     133            NSImage * image = [NSImage imageNamed: @"PriorityNone.png"];
     134            [images addObject: image];
     135            totalWidth = [image size].width;
     136        }
    131137        else
    132138        {
    133             switch ([[priorities anyObject] integerValue])
     139            totalWidth = 0.0;
     140            if ([priorities containsObject: [NSNumber numberWithInteger: TR_PRI_LOW]])
    134141            {
    135                 case TR_PRI_NORMAL:
    136                     image = [NSImage imageNamed: @"PriorityNormal.png"];
    137                     break;
    138                 case TR_PRI_LOW:
    139                     image = [NSImage imageNamed: @"PriorityLow.png"];
    140                     break;
    141                 case TR_PRI_HIGH:
    142                     image = [NSImage imageNamed: @"PriorityHigh.png"];
    143                     break;
     142                NSImage * image = [NSImage imageNamed: @"PriorityLow.png"];
     143                [images addObject: image];
     144                totalWidth += [image size].width;
     145            }
     146            if ([priorities containsObject: [NSNumber numberWithInteger: TR_PRI_NORMAL]])
     147            {
     148                NSImage * image = [NSImage imageNamed: @"PriorityNormal.png"];
     149                [images addObject: image];
     150                totalWidth += [image size].width;
     151            }
     152            if ([priorities containsObject: [NSNumber numberWithInteger: TR_PRI_HIGH]])
     153            {
     154                NSImage * image = [NSImage imageNamed: @"PriorityHigh.png"];
     155                [images addObject: image];
     156                totalWidth += [image size].width;
    144157            }
    145158        }
    146159       
    147         NSSize imageSize = [image size];
    148         NSRect imageRect = NSMakeRect(NSMidX(cellFrame) - imageSize.width * 0.5, NSMidY(cellFrame) - imageSize.height * 0.5,
    149                                         imageSize.width, imageSize.height);
     160        if (count > 1)
     161            totalWidth -= IMAGE_OVERLAP * (count-1);
    150162       
    151         if ([NSApp isOnSnowLeopardOrBetter])
    152             [image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0
    153                 respectFlipped: YES hints: nil];
    154         else
     163        CGFloat currentWidth = floor(NSMidX(cellFrame) - totalWidth * 0.5);
     164       
     165        for (NSImage * image in images)
    155166        {
    156             image = [image copy];
    157             [image setFlipped: YES];
    158             [image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
    159             [image release];
     167            const NSSize imageSize = [image size];
     168            NSRect imageRect = NSMakeRect(currentWidth, floor(NSMidY(cellFrame) - imageSize.height * 0.5), imageSize.width, imageSize.height);
     169           
     170            if ([NSApp isOnSnowLeopardOrBetter])
     171                [image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0 respectFlipped: YES hints: nil];
     172            else
     173            {
     174                image = [image copy];
     175                [image setFlipped: YES];
     176                [image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
     177                [image release];
     178            }
     179           
     180            currentWidth += imageSize.width - IMAGE_OVERLAP;
    160181        }
    161182    }
Note: See TracChangeset for help on using the changeset viewer.