Changeset 3730


Ignore:
Timestamp:
Nov 6, 2007, 4:53:06 AM (15 years ago)
Author:
livings124
Message:

clean up the pieces bar drawing to avoid putting it into an image, and use NSColor object for the piece colors

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/appcast.xml

    r3726 r3730  
    77    <language>en</language>
    88    <pubDate>Tue, 23 Oct 2007 23:20:00 -0400</pubDate>
    9     <lastBuildDate>Mon, 07 Nov 2007 16:45:00 -0400</lastBuildDate>
     9    <lastBuildDate>Mon, 05 Nov 2007 16:45:00 -0400</lastBuildDate>
    1010
    1111        <item>
     
    2525 <li>Leopard: Fix bug with toggling Minimal View</li>
    2626</ul>]]></description>
    27       <pubDate>Mon, 07 Nov 2007 16:45:00 -0400</pubDate>
    28       <enclosure sparkle:version="3711" sparkle:shortVersionString="0.92" url="http://mirrors.m0k.org/transmission/files/Transmission-0.92.dmg" length="2143155" type="application/octet-stream"/>
     27      <pubDate>Mon, 05 Nov 2007 16:45:00 -0400</pubDate>
     28      <enclosure sparkle:version="3711" sparkle:shortVersionString="0.92" url="http://mirrors.m0k.org/transmission/files/Transmission-0.92.dmg" length="2145246" type="application/octet-stream"/>
    2929    </item>
    3030   
  • trunk/macosx/Controller.m

    r3714 r3730  
    296296   
    297297    //set sort
     298    #warning clean up
    298299    NSString * sortType = [fDefaults stringForKey: @"Sort"];
    299300   
     
    336337   
    337338    //set filter
     339    #warning clean up
    338340    NSString * filterType = [fDefaults stringForKey: @"Filter"];
    339341   
  • trunk/macosx/TorrentCell.h

    r3698 r3730  
    3636                * fGreenGradient, * fLightGreenGradient, * fDarkGreenGradient, * fYellowGradient, * fTransparentGradient;
    3737   
     38    NSColor * fGrayColor, * fBlueColor, * fBlue1Color, * fBlue2Color, * fBlue3Color, * fBlue4Color;
     39   
    3840    NSBitmapImageRep * fBitmap;
    3941    int8_t * fPieces;
  • trunk/macosx/TorrentCell.m

    r3719 r3730  
    5454@interface TorrentCell (Private)
    5555
    56 // Used to optimize drawing. They contain packed RGBA pixels for every color needed.
    57 static uint32_t kBlue   = OSSwapBigToHostConstInt32(0x50A0FFFF), //80, 160, 255
    58                 kBlue1  = OSSwapBigToHostConstInt32(0x84FFFFFF), //204, 255, 255
    59                 kBlue2  = OSSwapBigToHostConstInt32(0x6BFFFFFF), //153, 255, 255
    60                 kBlue3  = OSSwapBigToHostConstInt32(0x6B84FFFF), //153, 204, 255
    61                 kBlue4  = OSSwapBigToHostConstInt32(0x426BFFFF), //102, 153, 255
    62                 kGray   = OSSwapBigToHostConstInt32(0xE9E9E9FF); //100, 100, 100
    63 
    6456- (void) drawBar: (NSRect) barRect;
    6557- (void) drawRegularBar: (NSRect) barRect;
     
    9688                                paragraphStyle, NSParagraphStyleAttributeName, nil];
    9789        [paragraphStyle release];
     90       
     91        //store box colors
     92        fGrayColor = [[NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0] retain];
     93        fBlue1Color = [[NSColor colorWithCalibratedRed: 0.8 green: 1.0 blue: 1.0 alpha: 1.0] retain];
     94        fBlue2Color = [[NSColor colorWithCalibratedRed: 0.6 green: 1.0 blue: 1.0 alpha: 1.0] retain];
     95        fBlue3Color = [[NSColor colorWithCalibratedRed: 0.6 green: 0.8 blue: 1.0 alpha: 1.0] retain];
     96        fBlue4Color = [[NSColor colorWithCalibratedRed: 0.4 green: 0.6 blue: 1.0 alpha: 1.0] retain];
     97        fBlueColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
    9898       
    9999        fBarOverlayColor = [[NSColor colorWithDeviceWhite: 0.0 alpha: 0.2] retain];
     
    446446            isPlanar: NO colorSpaceName: NSCalibratedRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0];
    447447   
    448     uint32_t * p;
    449     uint8_t * bitmapData = [fBitmap bitmapData];
    450     int bytesPerRow = [fBitmap bytesPerRow];
    451    
    452448    if (!fPieces)
    453449    {
     
    469465    int i, h, index;
    470466    float increment = (float)pieceCount / MAX_PIECES;
    471     uint32_t color;
     467    NSColor * pieceColor;
    472468    BOOL change;
    473469    for (i = 0; i < MAX_PIECES; i++)
    474470    {
    475471        index = i * increment;
    476         change = NO;
     472        pieceColor = nil;
    477473       
    478474        if (piecePercent[index] >= 1.0)
     
    480476            if (fPieces[i] != -1)
    481477            {
    482                 color = kBlue;
     478                pieceColor = fBlueColor;
    483479                fPieces[i] = -1;
    484                 change = YES;
    485480            }
    486481        }
     
    489484            if (fPieces[i] != 0)
    490485            {
    491                 color = kGray;
     486                pieceColor = fGrayColor;
    492487                fPieces[i] = 0;
    493                 change = YES;
    494488            }
    495489        }
     
    498492            if (fPieces[i] != 1)
    499493            {
    500                 color = kBlue1;
     494                pieceColor = fBlue1Color;
    501495                fPieces[i] = 1;
    502                 change = YES;
    503496            }
    504497        }
     
    507500            if (fPieces[i] != 2)
    508501            {
    509                 color = kBlue2;
     502                pieceColor = fBlue2Color;
    510503                fPieces[i] = 2;
    511                 change = YES;
    512504            }
    513505        }
     
    516508            if (fPieces[i] != 3)
    517509            {
    518                 color = kBlue3;
     510                pieceColor = fBlue3Color;
    519511                fPieces[i] = 3;
    520                 change = YES;
    521512            }
    522513        }
     
    525516            if (fPieces[i] != 4)
    526517            {
    527                 color = kBlue4;
     518                pieceColor = fBlue4Color;
    528519                fPieces[i] = 4;
    529                 change = YES;
    530             }
    531         }
    532        
    533         if (change)
    534         {
    535             //draw vertically
    536             p = (uint32_t *)(bitmapData) + i;
     520            }
     521        }
     522       
     523        if (pieceColor)
    537524            for (h = 0; h < barRect.size.height; h++)
    538             {
    539                 p[0] = color;
    540                 p = (uint32_t *)((uint8_t *)p + bytesPerRow);
    541             }
    542         }
     525                [fBitmap setColor: pieceColor atX: i y: h];
    543526    }
    544527   
     
    546529   
    547530    //actually draw image
    548     NSImage * bar = [[NSImage alloc] initWithSize: [fBitmap size]];
    549     [bar setFlipped: YES];
    550     [bar addRepresentation: fBitmap];
    551    
    552     [bar drawInRect: barRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
    553     [bar release];
     531    [fBitmap drawInRect: barRect];
    554532   
    555533    if (!fTransparentGradient)
Note: See TracChangeset for help on using the changeset viewer.