1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-22 06:00:41 +00:00

trivial adjustments to pieceview: use an enum instead of #defines; calculate the current piece index being drawn within each pass of the loop instead of incrementing

This commit is contained in:
Mitchell Livingston 2009-10-18 02:12:43 +00:00
parent c0c6a4f6b7
commit a193ba134c

View file

@ -32,11 +32,14 @@
#define HIGH_PEERS 30
#define PIECE_NONE 0
#define PIECE_SOME 1
#define PIECE_HIGH_PEERS 2
#define PIECE_FINISHED 3
#define PIECE_FLASHING 4
enum
{
PIECE_NONE,
PIECE_SOME,
PIECE_HIGH_PEERS,
PIECE_FINISHED,
PIECE_FLASHING
};
@implementation PiecesView
@ -71,7 +74,7 @@
fNumPieces = MIN([fTorrent pieceCount], MAX_ACROSS * MAX_ACROSS);
fAcross = ceil(sqrt(fNumPieces));
CGFloat width = [self bounds].size.width;
const CGFloat width = [self bounds].size.width;
fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross;
fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
}
@ -127,12 +130,12 @@
NSRect fillRects[fNumPieces];
NSColor * fillColors[fNumPieces];
NSInteger index = -1, usedCount = 0;
NSInteger usedCount = 0;
for (NSInteger i = 0; i < fAcross; i++)
for (NSInteger j = 0; j < fAcross; j++)
{
index++;
const NSInteger index = i * fAcross + j;
if (index >= fNumPieces)
{
i = fAcross;