Changeset 6125
- Timestamp:
- Jun 10, 2008, 7:56:53 PM (14 years ago)
- Location:
- trunk/macosx
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/PiecesView.h
r6105 r6125 31 31 32 32 NSImage * fBack; 33 NSColor * fWhiteColor, * fBlueColor, * fOrangeColor, 34 * fGreen1Color, * fGreen2Color, * fGreen3Color, 35 * fBlue1Color, * fBlue2Color, * fBlue3Color, * fBlue4Color; 33 NSColor * fGreenAvailabilityColor, * fBluePieceColor; 36 34 37 35 Torrent * fTorrent; -
trunk/macosx/PiecesView.m
r6105 r6125 29 29 #define MAX_ACROSS 18 30 30 #define BETWEEN 1.0 31 32 #define HIGH_PEERS 15 33 34 #define FINISHED 1 31 35 32 36 @implementation PiecesView … … 44 48 45 49 //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 57 53 //actually draw the box 58 54 [self setTorrent: nil]; … … 65 61 [fBack release]; 66 62 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]; 77 65 78 66 [super dealloc]; … … 143 131 144 132 BOOL change = NO; 145 133 146 134 for (i = 0; i < fAcross; i++) 147 135 for (j = 0; j < fAcross; j++) … … 154 142 } 155 143 156 NSColor * pieceColor = nil;144 NSColor * pieceColor; 157 145 158 146 if (showAvailablity) 159 147 { 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; 199 150 else 200 151 { 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]; 206 159 } 160 161 fPieces[index] = pieces[index] == -1 ? FINISHED : 0; 207 162 } 208 163 else 209 164 { 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]; 257 167 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; 265 171 } 266 172 -
trunk/macosx/PrefsController.m
r6123 r6125 33 33 34 34 #define RPC_ACCESS_ALLOW 0 35 #define RPC_ACCESS_DENY 135 #define RPC_ACCESS_DENY 1 36 36 37 37 #define RPC_IP_ADD_TAG 0 -
trunk/macosx/Torrent.m
r6116 r6125 169 169 tr_torrentFilesFree(fFileStat, [self fileCount]); 170 170 171 if (fPreviousFinishedPieces != NULL) 172 free(fPreviousFinishedPieces); 171 tr_free(fPreviousFinishedPieces); 173 172 [fFinishedPiecesDate release]; 174 173 … … 243 242 - (float *) getPreviousAmountFinished 244 243 { 244 //if the torrent hasn't been seen in a bit, and therefore hasn't been refreshed, return NULL 245 245 if (fFinishedPiecesDate && [fFinishedPiecesDate timeIntervalSinceNow] > -2.0) 246 246 return fPreviousFinishedPieces; … … 251 251 -(void) setPreviousAmountFinished: (float *) tab 252 252 { 253 if (fPreviousFinishedPieces != NULL) 254 free(fPreviousFinishedPieces); 253 tr_free(fPreviousFinishedPieces); 255 254 fPreviousFinishedPieces = tab; 256 255 -
trunk/macosx/TorrentCell.h
r5946 r6125 39 39 * fGreenGradient, * fLightGreenGradient, * fDarkGreenGradient, * fYellowGradient, * fRedGradient; 40 40 41 NSColor * f GrayColor, * fBlueColor, * fBlue1Color, * fBlue2Color, * fBlue3Color, * fBlue4Color, * fOrangeColor;41 NSColor * fBluePieceColor; 42 42 } 43 43 -
trunk/macosx/TorrentCell.m
r6098 r6125 99 99 [paragraphStyle release]; 100 100 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]; 110 102 fBarBorderColor = [[NSColor colorWithDeviceWhite: 0.0 alpha: 0.2] retain]; 111 103 } … … 756 748 { 757 749 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]; 774 752 else 775 pieceColor = fBlue4Color;753 pieceColor = [[NSColor whiteColor] blendedColorWithFraction: piecePercent[i] ofColor: fBluePieceColor]; 776 754 777 755 //it's faster to just set color instead of checking previous color
Note: See TracChangeset
for help on using the changeset viewer.