Changeset 3757


Ignore:
Timestamp:
Nov 8, 2007, 12:58:05 PM (14 years ago)
Author:
livings124
Message:

use gradients for drawing the file priority background

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileOutlineView.h

    r3475 r3757  
    2626
    2727@class Torrent;
     28@class CTGradient;
    2829
    2930@interface FileOutlineView : NSOutlineView
     
    3132    Torrent * fTorrent;
    3233   
    33     NSColor * fHighPriorityColor, * fLowPriorityColor, * fMixedPriorityColor;
     34    CTGradient * fHighPriorityGradient, * fLowPriorityGradient, * fMixedPriorityGradient;
    3435   
    3536    int fHoverRow;
  • trunk/macosx/FileOutlineView.m

    r3701 r3757  
    2727#import "FilePriorityCell.h"
    2828#import "Torrent.h"
     29#import "CTGradient.h"
    2930
    3031@implementation FileOutlineView
     
    4344    [self setIndentationPerLevel: 14.0];
    4445   
    45     fHighPriorityColor = [[NSColor colorWithCalibratedRed: 0.8588 green: 0.9961 blue: 0.8311 alpha: 1.0] retain];
    46     fLowPriorityColor = [[NSColor colorWithCalibratedRed: 1.0 green: 0.9529 blue: 0.8078 alpha: 1.0] retain];
    47     fMixedPriorityColor = [[NSColor colorWithCalibratedRed: 0.9216 green: 0.9059 blue: 1.0 alpha: 1.0] retain];
     46    NSColor * beginningColor = [NSColor colorWithCalibratedRed: 217.0/255.0 green: 250.0/255.0 blue: 211.0/255.0 alpha: 1.0];
     47    NSColor * endingColor = [NSColor colorWithCalibratedRed: 200.0/255.0 green: 231.0/255.0 blue: 194.0/255.0 alpha: 1.0];
     48    fHighPriorityGradient = [[CTGradient gradientWithBeginningColor: beginningColor endingColor: endingColor] retain];
     49   
     50    beginningColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 243.0/255.0 blue: 206.0/255.0 alpha: 1.0];
     51    endingColor = [NSColor colorWithCalibratedRed: 235.0/255.0 green: 226.0/255.0 blue: 192.0/255.0 alpha: 1.0];
     52    fLowPriorityGradient = [[CTGradient gradientWithBeginningColor: beginningColor endingColor: endingColor] retain];
     53   
     54    beginningColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 218.0/255.0 blue: 255.0/255.0 alpha: 1.0];
     55    endingColor = [NSColor colorWithCalibratedRed: 214.0/255.0 green: 207.0/255.0 blue: 242.0/255.0 alpha: 1.0];
     56    fMixedPriorityGradient = [[CTGradient gradientWithBeginningColor: beginningColor endingColor: endingColor] retain];
    4857   
    4958    fHoverRow = -1;
     
    5261- (void) dealloc
    5362{
    54     [fHighPriorityColor release];
    55     [fLowPriorityColor release];
    56     [fMixedPriorityColor release];
     63    [fHighPriorityGradient release];
     64    [fLowPriorityGradient release];
     65    [fMixedPriorityGradient release];
    5766   
    5867    [super dealloc];
     
    124133        if ([fTorrent checkForFiles: indexes] != NSOffState)
    125134        {
     135            CTGradient * gradient = nil;
     136           
    126137            NSSet * priorities = [fTorrent filePrioritiesForIndexes: indexes];
    127138            int count = [priorities count];
    128             if (count > 0)
     139            if (count == 1)
    129140            {
    130                 BOOL custom = YES;
    131                 if (count > 1)
    132                     [fMixedPriorityColor set];
    133                 else
     141                switch ([[priorities anyObject] intValue])
    134142                {
    135                     switch ([[priorities anyObject] intValue])
    136                     {
    137                         case TR_PRI_LOW:
    138                             [fLowPriorityColor set];
    139                             break;
    140                         case TR_PRI_HIGH:
    141                             [fHighPriorityColor set];
    142                             break;
    143                         default:
    144                             custom = NO;
    145                     }
     143                    case TR_PRI_LOW:
     144                        gradient = fLowPriorityGradient;
     145                        break;
     146                    case TR_PRI_HIGH:
     147                        gradient = fHighPriorityGradient;
     148                        break;
    146149                }
    147                
    148                 if (custom)
    149                 {
    150                     NSRect rect = [self rectOfRow: row];
    151                     rect.size.height -= 1.0;
     150            }
     151            else if (count > 1)
     152                gradient = fMixedPriorityGradient;
     153            else;
    152154           
    153                     NSRectFill(rect);
    154                 }
     155            if (gradient)
     156            {
     157                NSRect rect = [self rectOfRow: row];
     158                rect.size.height -= 1.0;
     159                [gradient fillRect: rect angle: 90];
    155160            }
    156161        }
Note: See TracChangeset for help on using the changeset viewer.