mirror of
https://github.com/transmission/transmission
synced 2025-02-22 22:20:39 +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:
parent
c0c6a4f6b7
commit
a193ba134c
1 changed files with 11 additions and 8 deletions
|
@ -32,11 +32,14 @@
|
||||||
|
|
||||||
#define HIGH_PEERS 30
|
#define HIGH_PEERS 30
|
||||||
|
|
||||||
#define PIECE_NONE 0
|
enum
|
||||||
#define PIECE_SOME 1
|
{
|
||||||
#define PIECE_HIGH_PEERS 2
|
PIECE_NONE,
|
||||||
#define PIECE_FINISHED 3
|
PIECE_SOME,
|
||||||
#define PIECE_FLASHING 4
|
PIECE_HIGH_PEERS,
|
||||||
|
PIECE_FINISHED,
|
||||||
|
PIECE_FLASHING
|
||||||
|
};
|
||||||
|
|
||||||
@implementation PiecesView
|
@implementation PiecesView
|
||||||
|
|
||||||
|
@ -71,7 +74,7 @@
|
||||||
fNumPieces = MIN([fTorrent pieceCount], MAX_ACROSS * MAX_ACROSS);
|
fNumPieces = MIN([fTorrent pieceCount], MAX_ACROSS * MAX_ACROSS);
|
||||||
fAcross = ceil(sqrt(fNumPieces));
|
fAcross = ceil(sqrt(fNumPieces));
|
||||||
|
|
||||||
CGFloat width = [self bounds].size.width;
|
const CGFloat width = [self bounds].size.width;
|
||||||
fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross;
|
fWidth = (width - (fAcross + 1) * BETWEEN) / fAcross;
|
||||||
fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
|
fExtraBorder = (width - ((fWidth + BETWEEN) * fAcross + BETWEEN)) / 2;
|
||||||
}
|
}
|
||||||
|
@ -127,12 +130,12 @@
|
||||||
NSRect fillRects[fNumPieces];
|
NSRect fillRects[fNumPieces];
|
||||||
NSColor * fillColors[fNumPieces];
|
NSColor * fillColors[fNumPieces];
|
||||||
|
|
||||||
NSInteger index = -1, usedCount = 0;
|
NSInteger usedCount = 0;
|
||||||
|
|
||||||
for (NSInteger i = 0; i < fAcross; i++)
|
for (NSInteger i = 0; i < fAcross; i++)
|
||||||
for (NSInteger j = 0; j < fAcross; j++)
|
for (NSInteger j = 0; j < fAcross; j++)
|
||||||
{
|
{
|
||||||
index++;
|
const NSInteger index = i * fAcross + j;
|
||||||
if (index >= fNumPieces)
|
if (index >= fNumPieces)
|
||||||
{
|
{
|
||||||
i = fAcross;
|
i = fAcross;
|
||||||
|
|
Loading…
Reference in a new issue