Changeset 6125


Ignore:
Timestamp:
Jun 10, 2008, 7:56:53 PM (14 years ago)
Author:
livings124
Message:

the pieces bar and pieces view now show shades of blue/green based on progress/availability instead of preset "levels" of color - in other words, it mixes white with either blue or green where the amount of color is the exact percentage of the piece that has been downloaded

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PiecesView.h

    r6105 r6125  
    3131   
    3232    NSImage * fBack;
    33     NSColor * fWhiteColor, * fBlueColor, * fOrangeColor,
    34             * fGreen1Color, * fGreen2Color, * fGreen3Color,
    35             * fBlue1Color, * fBlue2Color, * fBlue3Color, * fBlue4Color;
     33    NSColor * fGreenAvailabilityColor, * fBluePieceColor;
    3634   
    3735    Torrent * fTorrent;
  • trunk/macosx/PiecesView.m

    r6105 r6125  
    2929#define MAX_ACROSS 18
    3030#define BETWEEN 1.0
     31
     32#define HIGH_PEERS 15
     33
     34#define FINISHED 1
    3135
    3236@implementation PiecesView
     
    4448       
    4549        //store box colors
    46         fWhiteColor = [[NSColor whiteColor] retain];
    47         fOrangeColor = [[NSColor orangeColor] retain];
    48         fGreen1Color = [[NSColor colorWithCalibratedRed: 0.6 green: 1.0 blue: 0.8 alpha: 1.0] retain];
    49         fGreen2Color = [[NSColor colorWithCalibratedRed: 0.4 green: 1.0 blue: 0.6 alpha: 1.0] retain];
    50         fGreen3Color = [[NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 0.4 alpha: 1.0] retain];
    51         fBlue1Color = [[NSColor colorWithCalibratedRed: 0.8 green: 1.0 blue: 1.0 alpha: 1.0] retain];
    52         fBlue2Color = [[NSColor colorWithCalibratedRed: 0.6 green: 1.0 blue: 1.0 alpha: 1.0] retain];
    53         fBlue3Color = [[NSColor colorWithCalibratedRed: 0.6 green: 0.8 blue: 1.0 alpha: 1.0] retain];
    54         fBlue4Color = [[NSColor colorWithCalibratedRed: 0.4 green: 0.6 blue: 1.0 alpha: 1.0] retain];
    55         fBlueColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
    56        
     50        fGreenAvailabilityColor = [[NSColor colorWithCalibratedRed: 0.0 green: 1.0 blue: 0.4 alpha: 1.0] retain];
     51        fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
     52               
    5753        //actually draw the box
    5854        [self setTorrent: nil];
     
    6561    [fBack release];
    6662   
    67     [fWhiteColor release];
    68     [fOrangeColor release];
    69     [fGreen1Color release];
    70     [fGreen2Color release];
    71     [fGreen3Color release];
    72     [fBlue1Color release];
    73     [fBlue2Color release];
    74     [fBlue3Color release];
    75     [fBlue4Color release];
    76     [fBlueColor release];
     63    [fGreenAvailabilityColor release];
     64    [fBluePieceColor release];
    7765   
    7866    [super dealloc];
     
    143131   
    144132    BOOL change = NO;
    145        
     133   
    146134    for (i = 0; i < fAcross; i++)
    147135        for (j = 0; j < fAcross; j++)
     
    154142            }
    155143           
    156             NSColor * pieceColor = nil;
     144            NSColor * pieceColor;
    157145           
    158146            if (showAvailablity)
    159147            {
    160                 int piece = pieces[index];
    161                 if (piece == -1)
    162                 {
    163                     if (first || fPieces[index] == -2)
    164                     {
    165                         fPieces[index] = -1;
    166                         pieceColor = fBlueColor;
    167                     }
    168                     else if (fPieces[index] != -1)
    169                     {
    170                         fPieces[index] = -2;
    171                         pieceColor = fOrangeColor;
    172                     }
    173                     else;
    174                 }
    175                 else if (piece == 0)
    176                 {
    177                     if (first || fPieces[index] != 0)
    178                     {
    179                         fPieces[index] = 0;
    180                         pieceColor = fWhiteColor;
    181                     }
    182                 }
    183                 else if (piece <= 4)
    184                 {
    185                     if (first || fPieces[index] != 1)
    186                     {
    187                         fPieces[index] = 1;
    188                         pieceColor = fGreen1Color;
    189                     }
    190                 }
    191                 else if (piece <= 8)
    192                 {
    193                     if (first || fPieces[index] != 2)
    194                     {
    195                         fPieces[index] = 2;
    196                         pieceColor = fGreen2Color;
    197                     }
    198                 }
     148                if (pieces[index] == -1)
     149                    pieceColor = !first && fPieces[index] != FINISHED ? [NSColor orangeColor] : fBluePieceColor;
    199150                else
    200151                {
    201                     if (first || fPieces[index] != 3)
    202                     {
    203                         fPieces[index] = 3;
    204                         pieceColor = fGreen3Color;
    205                     }
     152                    float percent;
     153                    if (pieces[index] < HIGH_PEERS)
     154                        percent = (float)pieces[index]/HIGH_PEERS;
     155                    else
     156                        percent = 1.0;
     157                   
     158                    pieceColor = [[NSColor whiteColor] blendedColorWithFraction: percent ofColor: fGreenAvailabilityColor];
    206159                }
     160               
     161                fPieces[index] = pieces[index] == -1 ? FINISHED : 0;
    207162            }
    208163            else
    209164            {
    210                 float piecePercent = piecesPercent[index];
    211                 if (piecePercent >= 1.0)
    212                 {
    213                     if (first || fPieces[index] == -2)
    214                     {
    215                         fPieces[index] = -1;
    216                         pieceColor = fBlueColor;
    217                     }
    218                     else if (fPieces[index] != -1)
    219                     {
    220                         fPieces[index] = -2;
    221                         pieceColor = fOrangeColor;
    222                     }
    223                     else;
    224                 }
    225                 else if (piecePercent == 0.0)
    226                 {
    227                     if (first || fPieces[index] != 0)
    228                     {
    229                         fPieces[index] = 0;
    230                         pieceColor = fWhiteColor;
    231                     }
    232                 }
    233                 else if (piecePercent < 0.25)
    234                 {
    235                     if (first || fPieces[index] != 1)
    236                     {
    237                         fPieces[index] = 1;
    238                         pieceColor = fBlue1Color;
    239                     }
    240                 }
    241                 else if (piecePercent < 0.5)
    242                 {
    243                     if (first || fPieces[index] != 2)
    244                     {
    245                         fPieces[index] = 2;
    246                         pieceColor = fBlue2Color;
    247                     }
    248                 }
    249                 else if (piecePercent < 0.75)
    250                 {
    251                     if (first || fPieces[index] != 3)
    252                     {
    253                         fPieces[index] = 3;
    254                         pieceColor = fBlue3Color;
    255                     }
    256                 }
     165                if (piecesPercent[index] == 1.0 && !first && fPieces[index] != FINISHED)
     166                    pieceColor = [NSColor orangeColor];
    257167                else
    258                 {
    259                     if (first || fPieces[index] != 4)
    260                     {
    261                         fPieces[index] = 4;
    262                         pieceColor = fBlue4Color;
    263                     }
    264                 }
     168                    pieceColor = [[NSColor whiteColor] blendedColorWithFraction: piecesPercent[index] ofColor: fBluePieceColor];
     169               
     170                fPieces[index] = piecesPercent[index] == 1.0 ? FINISHED : 0;
    265171            }
    266172           
  • trunk/macosx/PrefsController.m

    r6123 r6125  
    3333
    3434#define RPC_ACCESS_ALLOW    0
    35 #define RPC_ACCESS_DENY    1
     35#define RPC_ACCESS_DENY     1
    3636
    3737#define RPC_IP_ADD_TAG      0
  • trunk/macosx/Torrent.m

    r6116 r6125  
    169169        tr_torrentFilesFree(fFileStat, [self fileCount]);
    170170   
    171     if (fPreviousFinishedPieces != NULL)
    172         free(fPreviousFinishedPieces);
     171    tr_free(fPreviousFinishedPieces);
    173172    [fFinishedPiecesDate release];
    174173   
     
    243242- (float *) getPreviousAmountFinished
    244243{
     244    //if the torrent hasn't been seen in a bit, and therefore hasn't been refreshed, return NULL
    245245    if (fFinishedPiecesDate && [fFinishedPiecesDate timeIntervalSinceNow] > -2.0)
    246246        return fPreviousFinishedPieces;
     
    251251-(void) setPreviousAmountFinished: (float *) tab
    252252{
    253     if (fPreviousFinishedPieces != NULL)
    254         free(fPreviousFinishedPieces);
     253    tr_free(fPreviousFinishedPieces);
    255254    fPreviousFinishedPieces = tab;
    256255   
  • trunk/macosx/TorrentCell.h

    r5946 r6125  
    3939                * fGreenGradient, * fLightGreenGradient, * fDarkGreenGradient, * fYellowGradient, * fRedGradient;
    4040   
    41     NSColor * fGrayColor, * fBlueColor, * fBlue1Color, * fBlue2Color, * fBlue3Color, * fBlue4Color, * fOrangeColor;
     41    NSColor * fBluePieceColor;
    4242}
    4343
  • trunk/macosx/TorrentCell.m

    r6098 r6125  
    9999        [paragraphStyle release];
    100100       
    101         //store box colors
    102         fGrayColor = [[NSColor colorWithCalibratedRed: 0.95 green: 0.95 blue: 0.95 alpha: 1.0] retain];
    103         fBlue1Color = [[NSColor colorWithCalibratedRed: 0.8 green: 1.0 blue: 1.0 alpha: 1.0] retain];
    104         fBlue2Color = [[NSColor colorWithCalibratedRed: 0.6 green: 1.0 blue: 1.0 alpha: 1.0] retain];
    105         fBlue3Color = [[NSColor colorWithCalibratedRed: 0.6 green: 0.8 blue: 1.0 alpha: 1.0] retain];
    106         fBlue4Color = [[NSColor colorWithCalibratedRed: 0.4 green: 0.6 blue: 1.0 alpha: 1.0] retain];
    107         fBlueColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
    108         fOrangeColor = [[NSColor orangeColor] retain];
    109        
     101        fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
    110102        fBarBorderColor = [[NSColor colorWithDeviceWhite: 0.0 alpha: 0.2] retain];
    111103    }
     
    756748    {
    757749        NSColor * pieceColor;
    758        
    759         if (piecePercent[i] >= 1.0)
    760         {
    761             if (previousPiecePercent != NULL && previousPiecePercent[i] < 1.0)
    762                 pieceColor = fOrangeColor;
    763             else
    764                 pieceColor = fBlueColor;
    765         }
    766         else if (piecePercent[i] <= 0.0)
    767             pieceColor = fGrayColor;
    768         else if (piecePercent[i] <= 0.25)
    769             pieceColor = fBlue1Color;
    770         else if (piecePercent[i] <= 0.5)
    771             pieceColor = fBlue2Color;
    772         else if (piecePercent[i] <= 0.75)
    773             pieceColor = fBlue3Color;
     750        if (piecePercent[i] == 1.0 && previousPiecePercent != NULL && previousPiecePercent[i] < 1.0)
     751            pieceColor = [NSColor orangeColor];
    774752        else
    775             pieceColor = fBlue4Color;
     753            pieceColor = [[NSColor whiteColor] blendedColorWithFraction: piecePercent[i] ofColor: fBluePieceColor];
    776754       
    777755        //it's faster to just set color instead of checking previous color
Note: See TracChangeset for help on using the changeset viewer.