mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
flash orange in pieces in the advanced progress bar that just completed
This commit is contained in:
parent
8b6d7f7b63
commit
3377bc4e02
4 changed files with 38 additions and 6 deletions
|
@ -61,6 +61,9 @@ typedef enum
|
|||
|
||||
NSMenu * fFileMenu;
|
||||
|
||||
float * fPreviousFinishedPieces;
|
||||
NSDate * fFinishedPiecesDate;
|
||||
|
||||
float fRatioLimit;
|
||||
int fRatioSetting;
|
||||
BOOL fFinishedSeeding, fWaitToStart, fError, fChecking, fStalled;
|
||||
|
@ -86,6 +89,8 @@ typedef enum
|
|||
|
||||
- (void) getAvailability: (int8_t *) tab size: (int) size;
|
||||
- (void) getAmountFinished: (float *) tab size: (int) size;
|
||||
- (float *) getPreviousAmountFinished;
|
||||
-(void) setPreviousAmountFinished: (float *) tab;
|
||||
|
||||
- (void) update;
|
||||
|
||||
|
|
|
@ -154,6 +154,9 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
if (fileStat)
|
||||
tr_torrentFilesFree(fileStat, [self fileCount]);
|
||||
|
||||
if (fPreviousFinishedPieces != NULL)
|
||||
free(fPreviousFinishedPieces);
|
||||
|
||||
[fDownloadFolder release];
|
||||
[fIncompleteFolder release];
|
||||
|
||||
|
@ -212,6 +215,24 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
|
|||
tr_torrentAmountFinished(fHandle, tab, size);
|
||||
}
|
||||
|
||||
- (float *) getPreviousAmountFinished
|
||||
{
|
||||
if (fFinishedPiecesDate && [fFinishedPiecesDate timeIntervalSinceNow] < -1.0)
|
||||
return fPreviousFinishedPieces;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
-(void) setPreviousAmountFinished: (float *) tab
|
||||
{
|
||||
if (fPreviousFinishedPieces != NULL)
|
||||
free(fPreviousFinishedPieces);
|
||||
fPreviousFinishedPieces = tab;
|
||||
|
||||
[fFinishedPiecesDate release];
|
||||
fFinishedPiecesDate = fPreviousFinishedPieces != NULL ? [[NSDate alloc] init] : nil;
|
||||
}
|
||||
|
||||
- (void) update
|
||||
{
|
||||
fStat = tr_torrentStat(fHandle);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
* fGreenGradient, * fLightGreenGradient, * fDarkGreenGradient, * fYellowGradient, * fRedGradient,
|
||||
* fTransparentGradient;
|
||||
|
||||
NSColor * fGrayColor, * fBlueColor, * fBlue1Color, * fBlue2Color, * fBlue3Color, * fBlue4Color;
|
||||
NSColor * fGrayColor, * fBlueColor, * fBlue1Color, * fBlue2Color, * fBlue3Color, * fBlue4Color, * fOrangeColor;
|
||||
|
||||
NSBitmapImageRep * fBitmap;
|
||||
}
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
fBlue3Color = [[NSColor colorWithCalibratedRed: 0.6 green: 0.8 blue: 1.0 alpha: 1.0] retain];
|
||||
fBlue4Color = [[NSColor colorWithCalibratedRed: 0.4 green: 0.6 blue: 1.0 alpha: 1.0] retain];
|
||||
fBlueColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
|
||||
fOrangeColor = [[NSColor orangeColor] retain];
|
||||
|
||||
fBarOverlayColor = [[NSColor colorWithDeviceWhite: 0.0 alpha: 0.2] retain];
|
||||
}
|
||||
|
@ -307,6 +308,7 @@
|
|||
{
|
||||
[fBitmap release];
|
||||
fBitmap = nil;
|
||||
[[self representedObject] setPreviousAmountFinished: NULL];
|
||||
|
||||
[self drawRegularBar: barRect];
|
||||
}
|
||||
|
@ -453,12 +455,11 @@
|
|||
pixelsWide: MAX_PIECES pixelsHigh: barRect.size.height bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES
|
||||
isPlanar: NO colorSpaceName: NSCalibratedRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0];
|
||||
|
||||
#warning add flashing orange
|
||||
|
||||
Torrent * torrent = [self representedObject];
|
||||
|
||||
int pieceCount = MIN([torrent pieceCount], MAX_PIECES);
|
||||
float * piecePercent = malloc(pieceCount * sizeof(float));
|
||||
float * piecePercent = malloc(pieceCount * sizeof(float)),
|
||||
* previousPiecePercent = [torrent getPreviousAmountFinished];
|
||||
[torrent getAmountFinished: piecePercent size: pieceCount];
|
||||
|
||||
int i, h, index;
|
||||
|
@ -468,7 +469,12 @@
|
|||
{
|
||||
index = i * increment;
|
||||
if (piecePercent[index] >= 1.0)
|
||||
pieceColor = fBlueColor;
|
||||
{
|
||||
if (previousPiecePercent != NULL && previousPiecePercent[index] < 1.0)
|
||||
pieceColor = fOrangeColor;
|
||||
else
|
||||
pieceColor = fBlueColor;
|
||||
}
|
||||
else if (piecePercent[index] <= 0.0)
|
||||
pieceColor = fGrayColor;
|
||||
else if (piecePercent[index] <= 0.25)
|
||||
|
@ -485,7 +491,7 @@
|
|||
[fBitmap setColor: pieceColor atX: i y: h];
|
||||
}
|
||||
|
||||
free(piecePercent);
|
||||
[torrent setPreviousAmountFinished: piecePercent];
|
||||
|
||||
//actually draw image
|
||||
[fBitmap drawInRect: barRect];
|
||||
|
|
Loading…
Reference in a new issue