mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
efficiency is advanced bar drawing
This commit is contained in:
parent
727e167705
commit
131fa9011d
2 changed files with 28 additions and 16 deletions
|
@ -485,7 +485,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
enumerator = [fTorrents objectEnumerator];
|
||||
Torrent * torrent;
|
||||
while (!timeUp && ((torrent = [enumerator nextObject]) || tr_handleStatus(fLib)->natTraversalStatus != TR_NAT_TRAVERSAL_DISABLED))
|
||||
while (!timeUp && ((torrent = [enumerator nextObject])
|
||||
|| tr_handleStatus(fLib)->natTraversalStatus != TR_NAT_TRAVERSAL_DISABLED))
|
||||
while (![torrent isPaused] && !(timeUp = [start timeIntervalSinceNow] < -5.0))
|
||||
{
|
||||
usleep(100000);
|
||||
|
|
|
@ -1342,23 +1342,37 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
index = (int)indexValue;
|
||||
}
|
||||
|
||||
free(piecesAvailablity);
|
||||
|
||||
//determine percentage finished and available
|
||||
int have, avail;
|
||||
if ([self progress] >= 1.0)
|
||||
{
|
||||
have = MAX_PIECES;
|
||||
avail = 0;
|
||||
}
|
||||
else if (![self isActive])
|
||||
{
|
||||
have = rintf((float)MAX_PIECES * [self progress]);
|
||||
avail = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
float * piecesFinished = malloc(pieceCount * sizeof(float));
|
||||
[self getAmountFinished: piecesFinished size: pieceCount];
|
||||
|
||||
float finished = 0, available = 0;
|
||||
float available = 0;
|
||||
for (i = 0; i < pieceCount; i++)
|
||||
{
|
||||
finished += piecesFinished[i];
|
||||
if (piecesAvailablity[i] > 0)
|
||||
available += 1.0 - piecesFinished[i];
|
||||
}
|
||||
|
||||
int have = rintf((float)MAX_PIECES * finished / (float)pieceCount),
|
||||
have = rintf((float)MAX_PIECES * [self progress]);
|
||||
avail = rintf((float)MAX_PIECES * available / (float)pieceCount);
|
||||
if (have + avail > MAX_PIECES) //case if both end in .5 and all pieces are available
|
||||
avail--;
|
||||
|
||||
free(piecesFinished);
|
||||
}
|
||||
|
||||
//first two lines: dark blue to show progression, green to show available
|
||||
p = (uint32_t *)bitmapData;
|
||||
for (i = 0; i < have; i++)
|
||||
|
@ -1377,9 +1391,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
p[i + bytesPerRow / 4] = kWhite;
|
||||
}
|
||||
|
||||
free(piecesAvailablity);
|
||||
free(piecesFinished);
|
||||
|
||||
//actually draw image
|
||||
NSImage * bar = [[NSImage alloc] initWithSize: [fBitmap size]];
|
||||
[bar addRepresentation: fBitmap];
|
||||
|
|
Loading…
Reference in a new issue