Changeset 5944


Ignore:
Timestamp:
May 27, 2008, 5:27:42 AM (14 years ago)
Author:
livings124
Message:

improvement for showing the pieces bar for transfers with few pieces (less than 324)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/TorrentCell.m

    r5943 r5944  
    731731- (void) drawPiecesBar: (NSRect) barRect
    732732{
    733     NSBitmapImageRep * bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil
    734                                     pixelsWide: MAX_PIECES pixelsHigh: 1 bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES
    735                                     isPlanar: NO colorSpaceName: NSCalibratedRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0];
    736    
    737733    Torrent * torrent = [self representedObject];
    738734   
     
    742738    [torrent getAmountFinished: piecePercent size: pieceCount];
    743739   
    744     int i, index;
    745     float increment = (float)pieceCount / MAX_PIECES;
    746     NSColor * pieceColor;
    747     for (i = 0; i < MAX_PIECES; i++)
    748     {
    749         index = i * increment;
    750         if (piecePercent[index] >= 1.0)
     740    NSBitmapImageRep * bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil
     741                                    pixelsWide: pieceCount pixelsHigh: 1 bitsPerSample: 8 samplesPerPixel: 4 hasAlpha: YES
     742                                    isPlanar: NO colorSpaceName: NSCalibratedRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0];
     743   
     744    int i;
     745    for (i = 0; i < pieceCount; i++)
     746    {
     747        NSColor * pieceColor;
     748       
     749        if (piecePercent[i] >= 1.0)
    751750        {
    752             if (previousPiecePercent != NULL && previousPiecePercent[index] < 1.0)
     751            if (previousPiecePercent != NULL && previousPiecePercent[i] < 1.0)
    753752                pieceColor = fOrangeColor;
    754753            else
    755754                pieceColor = fBlueColor;
    756755        }
    757         else if (piecePercent[index] <= 0.0)
     756        else if (piecePercent[i] <= 0.0)
    758757            pieceColor = fGrayColor;
    759         else if (piecePercent[index] <= 0.25)
     758        else if (piecePercent[i] <= 0.25)
    760759            pieceColor = fBlue1Color;
    761         else if (piecePercent[index] <= 0.5)
     760        else if (piecePercent[i] <= 0.5)
    762761            pieceColor = fBlue2Color;
    763         else if (piecePercent[index] <= 0.75)
     762        else if (piecePercent[i] <= 0.75)
    764763            pieceColor = fBlue3Color;
    765764        else
     
    776775   
    777776    [bitmap release];
    778     bitmap = nil;
    779777}
    780778
Note: See TracChangeset for help on using the changeset viewer.