Changeset 341


Ignore:
Timestamp:
Jun 12, 2006, 4:58:04 PM (15 years ago)
Author:
livings124
Message:

This look for the progress bars matches the new smooth aqua look a lot more and is generated from images instead of drawing the bar from scratch.

The advanced bar should also be easier on the eyes now that the overlay isn't as extreme.

Thanks to FOOOD for the images.

Location:
trunk
Files:
10 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r334 r341  
    8181                A2173E1C0A33C1B300B0D8AB /* ActionButtonPressed.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.tiff */; };
    8282                A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
     83                A2305A800A3DC9E400AB2D77 /* ProgressBarWhite.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */; };
     84                A2305A810A3DC9E400AB2D77 /* ProgressBarBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */; };
     85                A2305A820A3DC9E400AB2D77 /* ProgressBarGray.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7E0A3DC9E400AB2D77 /* ProgressBarGray.png */; };
     86                A2305A830A3DC9E400AB2D77 /* ProgressBarGreen.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7F0A3DC9E400AB2D77 /* ProgressBarGreen.png */; };
     87                A2305A950A3DCAC500AB2D77 /* ProgressBarAdvanced.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A940A3DCAC500AB2D77 /* ProgressBarAdvanced.png */; };
     88                A2305AA90A3DCCEF00AB2D77 /* ProgressBarEndAdvanced.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305AA40A3DCCEF00AB2D77 /* ProgressBarEndAdvanced.png */; };
     89                A2305AAA0A3DCCEF00AB2D77 /* ProgressBarEndBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305AA50A3DCCEF00AB2D77 /* ProgressBarEndBlue.png */; };
     90                A2305AAB0A3DCCEF00AB2D77 /* ProgressBarEndWhite.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305AA60A3DCCEF00AB2D77 /* ProgressBarEndWhite.png */; };
     91                A2305AAC0A3DCCEF00AB2D77 /* ProgressBarEndGreen.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305AA70A3DCCEF00AB2D77 /* ProgressBarEndGreen.png */; };
     92                A2305AAD0A3DCCEF00AB2D77 /* ProgressBarEndGray.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305AA80A3DCCEF00AB2D77 /* ProgressBarEndGray.png */; };
    8393                A24F19080A3A790800C9C145 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; };
    8494                A24F19210A3A796800C9C145 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A24F19070A3A790800C9C145 /* Sparkle.framework */; };
     
    253263                A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = ActionButtonPressed.tiff; path = macosx/Images/ActionButtonPressed.tiff; sourceTree = "<group>"; };
    254264                A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
     265                A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarWhite.png; path = macosx/Images/ProgressBarWhite.png; sourceTree = "<group>"; };
     266                A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarBlue.png; path = macosx/Images/ProgressBarBlue.png; sourceTree = "<group>"; };
     267                A2305A7E0A3DC9E400AB2D77 /* ProgressBarGray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarGray.png; path = macosx/Images/ProgressBarGray.png; sourceTree = "<group>"; };
     268                A2305A7F0A3DC9E400AB2D77 /* ProgressBarGreen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarGreen.png; path = macosx/Images/ProgressBarGreen.png; sourceTree = "<group>"; };
     269                A2305A940A3DCAC500AB2D77 /* ProgressBarAdvanced.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarAdvanced.png; path = macosx/Images/ProgressBarAdvanced.png; sourceTree = "<group>"; };
     270                A2305AA40A3DCCEF00AB2D77 /* ProgressBarEndAdvanced.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarEndAdvanced.png; path = macosx/Images/ProgressBarEndAdvanced.png; sourceTree = "<group>"; };
     271                A2305AA50A3DCCEF00AB2D77 /* ProgressBarEndBlue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarEndBlue.png; path = macosx/Images/ProgressBarEndBlue.png; sourceTree = "<group>"; };
     272                A2305AA60A3DCCEF00AB2D77 /* ProgressBarEndWhite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarEndWhite.png; path = macosx/Images/ProgressBarEndWhite.png; sourceTree = "<group>"; };
     273                A2305AA70A3DCCEF00AB2D77 /* ProgressBarEndGreen.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarEndGreen.png; path = macosx/Images/ProgressBarEndGreen.png; sourceTree = "<group>"; };
     274                A2305AA80A3DCCEF00AB2D77 /* ProgressBarEndGray.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarEndGray.png; path = macosx/Images/ProgressBarEndGray.png; sourceTree = "<group>"; };
    255275                A24F19070A3A790800C9C145 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Sparkle.framework; sourceTree = "<group>"; };
    256276                A2519D470A2FADFC00479D0C /* SmoothAquaView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SmoothAquaView.m; path = macosx/SmoothAquaView.m; sourceTree = "<group>"; };
     
    362382                        children = (
    363383                                A2F8951E0A2D4BA500ED2127 /* Credits.rtf */,
     384                                A2305AA40A3DCCEF00AB2D77 /* ProgressBarEndAdvanced.png */,
     385                                A2305AA50A3DCCEF00AB2D77 /* ProgressBarEndBlue.png */,
     386                                A2305AA60A3DCCEF00AB2D77 /* ProgressBarEndWhite.png */,
     387                                A2305AA70A3DCCEF00AB2D77 /* ProgressBarEndGreen.png */,
     388                                A2305AA80A3DCCEF00AB2D77 /* ProgressBarEndGray.png */,
     389                                A2305A940A3DCAC500AB2D77 /* ProgressBarAdvanced.png */,
     390                                A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */,
     391                                A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */,
     392                                A2305A7E0A3DC9E400AB2D77 /* ProgressBarGray.png */,
     393                                A2305A7F0A3DC9E400AB2D77 /* ProgressBarGreen.png */,
    364394                                A21DFF0F0A292B2B007C5F76 /* Transfers.png */,
    365395                                A27A53640A06AED200E1F16F /* StatusBorder.tiff */,
     
    635665                                A25FCDEF0A3769A6002BCBBE /* PauseSelected.png in Resources */,
    636666                                A25FCDF00A3769AC002BCBBE /* ResumeSelected.png in Resources */,
     667                                A2305A800A3DC9E400AB2D77 /* ProgressBarWhite.png in Resources */,
     668                                A2305A810A3DC9E400AB2D77 /* ProgressBarBlue.png in Resources */,
     669                                A2305A820A3DC9E400AB2D77 /* ProgressBarGray.png in Resources */,
     670                                A2305A830A3DC9E400AB2D77 /* ProgressBarGreen.png in Resources */,
     671                                A2305A950A3DCAC500AB2D77 /* ProgressBarAdvanced.png in Resources */,
     672                                A2305AA90A3DCCEF00AB2D77 /* ProgressBarEndAdvanced.png in Resources */,
     673                                A2305AAA0A3DCCEF00AB2D77 /* ProgressBarEndBlue.png in Resources */,
     674                                A2305AAB0A3DCCEF00AB2D77 /* ProgressBarEndWhite.png in Resources */,
     675                                A2305AAC0A3DCCEF00AB2D77 /* ProgressBarEndGreen.png in Resources */,
     676                                A2305AAD0A3DCCEF00AB2D77 /* ProgressBarEndGray.png in Resources */,
    637677                        );
    638678                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/macosx/TorrentCell.m

    r340 r341  
    2727#import "StringAdditions.h"
    2828
    29 #define BAR_HEIGHT 12
     29#define BAR_HEIGHT 12.0
     30
     31@interface TorrentCell (Private)
     32
     33- (void) placeBar: (NSImage *) barImage width: (float) width point: (NSPoint) point;
     34- (void) buildSimpleBar: (int) width point: (NSPoint) point;
     35- (void) buildAdvancedBar: (int) width point: (NSPoint) point;
     36
     37@end
    3038
    3139@implementation TorrentCell
    3240
    33 /***********************************************************************
    34  * Static tables
    35  ***********************************************************************
    36  * We use these tables to optimize the drawing. They contain packed
    37  * RGBA pixels for every color we might need.
    38  **********************************************************************/
    39 
     41static NSImage * fProgressWhite, * fProgressBlue, * fProgressGray, * fProgressGreen,
     42                * fProgressAdvanced, * fProgressEndWhite, * fProgressEndBlue,
     43                * fProgressEndGray, * fProgressEndGreen, * fProgressEndAdvanced;
     44
     45// Used to optimize drawing. They contain packed RGBA pixels for every color needed.
    4046static uint32_t kBorder[] =
    4147    { 0x00000005, 0x00000010, 0x00000015, 0x00000015,
     
    4349      0x00000015, 0x00000015, 0x00000010, 0x00000005 };
    4450
    45 static uint32_t kBack[] =
    46     { 0xB4B4B4FF, 0xE3E3E3FF, 0xE8E8E8FF, 0xDEDEDEFF,
    47       0xDBDBDBFF, 0xE5E5E5FF, 0xE7E7E7FF, 0xF5F5F5FF,
    48       0xFAFAFAFF, 0xDEDEDEFF, 0x0000003F, 0x00000015 };
    49 
    50 /* Coefficients for the "3D effect":
    51    0.59, 0.91, 0.97, 0.92, 0.79, 0.76, 0.85, 0.93, 1.00, 0.99 */
    52 
    53 /* 255, 100, 80 */
    54 static uint32_t kRed[] =
    55     { 0x963A2FFF, 0xE85B48FF, 0xF7614DFF, 0xEA5C49FF,
    56       0xC94F3FFF, 0xC14C3CFF, 0xD85544FF, 0xED5D4AFF,
    57       0xFF6450FF, 0xFC634FFF, 0x0000003F, 0x00000015 };
    58 
    59 /* 160, 220, 255 */
    60 static uint32_t kBlue1[] =
    61     { 0x5E8196FF, 0x91C8E8FF, 0x9BD5F7FF, 0x93CAEAFF,
    62       0x7EADC9FF, 0x79A7C1FF, 0x88BBD8FF, 0x94CCEDFF,
    63       0xA0DCFFFF, 0x9ED9FCFF, 0x0000003F, 0x00000015 };
    64 
    65 /* 120, 190, 255 */
    66 static uint32_t kBlue2[] =
    67     { 0x467096FF, 0x6DACE8FF, 0x74B8F7FF, 0x6EAEEAFF,
    68       0x5E96C9FF, 0x5B90C1FF, 0x66A1D8FF, 0x6FB0EDFF,
    69       0x78BEFFFF, 0x76BCFCFF, 0x0000003F, 0x00000015 };
    70 
    71 /* 80, 160, 255 */
    72 static uint32_t kBlue3[] =
    73     { 0x2F5E96FF, 0x4891E8FF, 0x4D9BF7FF, 0x4993EAFF,
    74       0x3F7EC9FF, 0x3C79C1FF, 0x4488D8FF, 0x4A94EDFF,
    75       0x50A0FFFF, 0x4F9EFCFF, 0x0000003F, 0x00000015 };
    76 
    77 /* 30, 70, 180 */
    78 static uint32_t kBlue4[] =
    79     { 0x11296AFF, 0x1B3FA3FF, 0x1D43AEFF, 0x1B40A5FF,
    80       0x17378EFF, 0x163588FF, 0x193B99FF, 0x1B41A7FF,
    81       0x1E46B4FF, 0x1D45B2FF, 0x0000003F, 0x00000015 };
    82 
    83 /* 130, 130, 130 */
    84 static uint32_t kGray[] =
    85     { 0x4C4C4CFF, 0x767676FF, 0x7E7E7EFF, 0x777777FF,
    86       0x666666FF, 0x626262FF, 0x6E6E6EFF, 0x787878FF,
    87       0x828282FF, 0x808080FF, 0x0000003F, 0x00000015 };
    88 
    89 /* 0, 255, 0 */
    90 static uint32_t kGreen[] =
    91     { 0x009600FF, 0x00E800FF, 0x00F700FF, 0x00EA00FF,
    92       0x00C900FF, 0x00C100FF, 0x00D800FF, 0x00ED00FF,
    93       0x00FF00FF, 0x00FC00FF, 0x0000003F, 0x00000015 };
     51static uint32_t kBack[] = { 0xB4B4B4FF, 0xE3E3E3FF };
     52
     53static uint32_t kRed = 0xFF6450FF, //255, 100, 80
     54    kBlue1 = 0xA0DCFFFF, //160, 220, 255
     55    kBlue2 = 0x78BEFFFF, //120, 190, 255
     56    kBlue3 = 0x50A0FFFF, //80, 160, 255
     57    kBlue4 = 0x1E46B4FF, //30, 70, 180
     58    kGray = 0x828282FF, //130, 130, 130
     59    kGreen = 0x00FF00FF; //0, 255, 0
     60
     61- (id) init
     62{
     63    if ((self = [super init]))
     64    {
     65        NSSize startSize = NSMakeSize(100.0, BAR_HEIGHT);
     66        if (!fProgressWhite)
     67        {
     68            fProgressWhite = [NSImage imageNamed: @"ProgressBarWhite.png"];
     69            [fProgressWhite setScalesWhenResized: YES];
     70            [fProgressWhite setSize: startSize];
     71        }
     72        if (!fProgressBlue)
     73        {
     74            fProgressBlue = [NSImage imageNamed: @"ProgressBarBlue.png"];
     75            [fProgressBlue setScalesWhenResized: YES];
     76            [fProgressBlue setSize: startSize];
     77        }
     78        if (!fProgressGray)
     79        {
     80            fProgressGray = [NSImage imageNamed: @"ProgressBarGray.png"];
     81            [fProgressGray setScalesWhenResized: YES];
     82            [fProgressGray setSize: startSize];
     83        }
     84        if (!fProgressGreen)
     85        {
     86            fProgressGreen = [NSImage imageNamed: @"ProgressBarGreen.png"];
     87            [fProgressGreen setScalesWhenResized: YES];
     88            [fProgressGreen setSize: startSize];
     89        }
     90        if (!fProgressAdvanced)
     91        {
     92            fProgressAdvanced = [NSImage imageNamed: @"ProgressBarAdvanced.png"];
     93            [fProgressAdvanced setScalesWhenResized: YES];
     94            [fProgressAdvanced setSize: startSize];
     95        }
     96       
     97        if (!fProgressEndWhite)
     98            fProgressEndWhite = [NSImage imageNamed: @"ProgressBarEndWhite.png"];
     99        if (!fProgressEndBlue)
     100            fProgressEndBlue = [NSImage imageNamed: @"ProgressBarEndBlue.png"];
     101        if (!fProgressEndGray)
     102            fProgressEndGray = [NSImage imageNamed: @"ProgressBarEndGray.png"];
     103        if (!fProgressEndGreen)
     104            fProgressEndGreen = [NSImage imageNamed: @"ProgressBarEndGreen.png"];
     105        if (!fProgressEndAdvanced)
     106            fProgressEndAdvanced = [NSImage imageNamed: @"ProgressBarEndAdvanced.png"];
     107    }
     108    return self;
     109}
    94110
    95111- (void) setTorrent: (Torrent *) torrent
     
    98114}
    99115
    100 - (void) buildSimpleBar: (int) width bitmap: (NSBitmapImageRep *) bitmap
    101 {
    102     int        h, w, end, pixelsPerRow;
     116- (void) placeBar: (NSImage *) barImage width: (float) width point: (NSPoint) point
     117{
     118    if ([barImage size].width < width)
     119        [barImage setSize: NSMakeSize(width * 1.5, BAR_HEIGHT)];
     120
     121    [barImage compositeToPoint: point fromRect: NSMakeRect(0, 0, width, BAR_HEIGHT)
     122                        operation: NSCompositeSourceOver];
     123}
     124
     125- (void) buildSimpleBar: (int) width point: (NSPoint) point
     126{
     127    width -= 2.0;
     128    if ([fTorrent isSeeding])
     129    {
     130        [fProgressEndGreen compositeToPoint: point operation: NSCompositeSourceOver];
     131       
     132        point.x += 1.0;
     133        [self placeBar: fProgressGreen width: width point: point];
     134       
     135        point.x += width;
     136        [fProgressEndGreen compositeToPoint: point operation: NSCompositeSourceOver];
     137    }
     138    else
     139    {
     140        NSImage * barActiveEnd, * barActive;
     141        if ([fTorrent isActive])
     142        {
     143            barActiveEnd = fProgressEndBlue;
     144            barActive = fProgressBlue;
     145        }
     146        else
     147        {
     148            barActiveEnd = fProgressEndGray;
     149            barActive = fProgressGray;
     150        }
     151       
     152        float completedWidth = [fTorrent progress] * width,
     153                remainingWidth = width - completedWidth;
     154   
     155        if (completedWidth >= 1.0)
     156            [barActiveEnd compositeToPoint: point operation: NSCompositeSourceOver];
     157        else
     158            [fProgressEndWhite compositeToPoint: point operation: NSCompositeSourceOver];
     159       
     160        point.x += 1.0;
     161        [self placeBar: barActive width: completedWidth point: point];
     162       
     163        point.x += completedWidth;
     164        [self placeBar: fProgressWhite width: remainingWidth point: point];
     165       
     166        point.x += remainingWidth;
     167        [fProgressEndWhite compositeToPoint: point operation: NSCompositeSourceOver];
     168    }
     169}
     170
     171- (void) buildAdvancedBar: (int) width point: (NSPoint) point
     172{
     173    //if seeding, there's no need for the advanced bar
     174    if ([fTorrent isSeeding])
     175    {
     176        [self buildSimpleBar: width point: point];
     177        return;
     178    }
     179
     180    NSBitmapImageRep * bitmap = [[NSBitmapImageRep alloc]
     181        initWithBitmapDataPlanes: nil pixelsWide: width
     182        pixelsHigh: BAR_HEIGHT bitsPerSample: 8 samplesPerPixel: 4
     183        hasAlpha: YES isPlanar: NO colorSpaceName:
     184        NSCalibratedRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0];
     185
     186    int h, w;
    103187    uint32_t * p;
    104     uint32_t * colors;
    105 
    106     pixelsPerRow = [bitmap bytesPerRow] / 4;
    107 
    108     p   = (uint32_t *) [bitmap bitmapData] + 1;
    109     end = lrintf( floor( [fTorrent progress] * ( width - 2 ) ) );
    110 
    111     if( [fTorrent isSeeding] )
    112         colors = kGreen;
    113     else if( [fTorrent isActive] )
    114         colors = kBlue2;
    115     else
    116         colors = kGray;
    117 
     188    uint8_t * bitmapData = [bitmap bitmapData];
     189    int bytesPerRow = [bitmap bytesPerRow];
     190
     191    /* Left and right borders */
     192    p = (uint32_t *) bitmapData;
    118193    for( h = 0; h < BAR_HEIGHT; h++ )
    119194    {
    120         for( w = 0; w < end; w++ )
    121         {
    122             p[w] = htonl( colors[h] );
    123         }
    124         for( w = end; w < width - 2; w++ )
    125         {
    126             p[w] = htonl( kBack[h] );
    127         }
    128         p += pixelsPerRow;
    129     }
    130 }
    131 
    132 - (void) buildAdvancedBar: (int) width bitmap: (NSBitmapImageRep *) bitmap
    133 {
    134     int      h, w, end, pixelsPerRow;
    135     uint32_t * p, * colors;
    136     uint8_t  * bitmapData  = [bitmap bitmapData];
    137     int        bytesPerRow = [bitmap bytesPerRow];
     195        p[0] = htonl( kBorder[h] );
     196        p[width - 1] = htonl( kBorder[h] );
     197        p += bytesPerRow / 4;
     198    }
    138199
    139200    int8_t * pieces = malloc( width );
    140201    [fTorrent getAvailability: pieces size: width];
    141202
    142     if( [fTorrent isSeeding] )
    143     {
    144         /* All green, same as the simple bar */
    145         [self buildSimpleBar: width bitmap: bitmap];
    146         return;
    147     }
    148 
    149     pixelsPerRow = bytesPerRow / 4;
    150 
    151203    /* First two lines: dark blue to show progression */
    152     end  = lrintf( floor( [fTorrent progress] * ( width - 2 ) ) );
     204    int end  = lrintf( floor( [fTorrent progress] * ( width - 2 ) ) );
    153205    for( h = 0; h < 2; h++ )
    154206    {
    155207        p = (uint32_t *) ( bitmapData + h * bytesPerRow ) + 1;
    156208        for( w = 0; w < end; w++ )
    157         {
    158             p[w] = htonl( kBlue4[h] );
    159         }
     209            p[w] = htonl( kBlue4 );
    160210        for( w = end; w < width - 2; w++ )
    161         {
    162211            p[w] = htonl( kBack[h] );
    163         }
    164212    }
    165213
    166214    /* Lines 2 to 14: blue or grey depending on whether
    167215       we have the piece or not */
     216    uint32_t color;
    168217    for( w = 0; w < width - 2; w++ )
    169218    {
    170219        /* Point to pixel ( 2 + w, 2 ). We will then draw
    171220           "vertically" */
    172         p  = (uint32_t *) ( bitmapData + 2 * bytesPerRow ) + 1 + w;
    173 
    174         if( pieces[w] < 0 )
    175         {
    176             colors = kGray;
    177         }
    178         else if( pieces[w] < 1 )
    179         {
    180             colors = kRed;
    181         }
    182         else if( pieces[w] < 2 )
    183         {
    184             colors = kBlue1;
    185         }
    186         else if( pieces[w] < 3 )
    187         {
    188             colors = kBlue2;
    189         }
     221        p = (uint32_t *) ( bitmapData + 2 * bytesPerRow ) + 1 + w;
     222
     223        if (pieces[w] < 0)
     224            color = kGray;
     225        else if (pieces[w] == 0)
     226            color = kRed;
     227        else if (pieces[w] == 1)
     228            color = kBlue1;
     229        else if (pieces[w] == 2)
     230            color = kBlue2;
    190231        else
    191         {
    192             colors = kBlue3;
    193         }
     232            color = kBlue3;
    194233
    195234        for( h = 2; h < BAR_HEIGHT; h++ )
    196235        {
    197             p[0] = htonl( colors[h] );
    198             p    = (uint32_t *) ( (uint8_t *) p + bytesPerRow );
     236            p[0] = htonl( color );
     237            p = (uint32_t *) ( (uint8_t *) p + bytesPerRow );
    199238        }
    200239    }
    201240
    202241    free( pieces );
    203 }
    204 
    205 - (void) buildBarWithWidth: (int) width bitmap: (NSBitmapImageRep *) bitmap
    206 {
    207     int h;
    208     uint32_t * p;
    209 
    210     /* Left and right borders */
    211     p = (uint32_t *) [bitmap bitmapData];
    212     for( h = 0; h < BAR_HEIGHT; h++ )
    213     {
    214         p[0]          = htonl( kBorder[h] );
    215         p[width - 1] = htonl( kBorder[h] );
    216         p += [bitmap bytesPerRow] / 4;
    217     }
    218 
    219     /* ...and redraw the progress bar on the top of it */
    220     if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseAdvancedBar"])
    221         [self buildAdvancedBar: width bitmap: bitmap];
    222     else
    223         [self buildSimpleBar: width bitmap: bitmap];
     242   
     243    //actually draw image
     244    NSImage * img = [[NSImage alloc] initWithSize: [bitmap size]];
     245    [img addRepresentation: bitmap];
     246    [img compositeToPoint: point operation: NSCompositeSourceOver];
     247    [img release];
     248    [bitmap release];
     249   
     250    //draw overlay over advanced bar
     251    [self placeBar: fProgressAdvanced width: width point: point];
    224252}
    225253
     
    246274    pen.y += (cellFrame.size.height - iconSize.height) * 0.5;
    247275   
    248     [icon drawAtPoint: pen fromRect:
    249         NSMakeRect( 0, 0, iconSize.width, iconSize.height )
    250         operation: NSCompositeSourceOver fraction: 1.0];
     276    [icon drawAtPoint: pen fromRect: NSMakeRect( 0, 0, iconSize.width, iconSize.height )
     277            operation: NSCompositeSourceOver fraction: 1.0];
    251278
    252279    float extraNameShift = 1.0,
     
    269296    //progress bar
    270297    pen.x -= extraNameShift;
    271     pen.y += [progressString size].height + linePadding;
     298    pen.y += [progressString size].height + linePadding + BAR_HEIGHT;
    272299   
    273300    float barWidth = mainWidth + extraNameShift - BUTTONS_TOTAL_WIDTH + padding;
    274301   
    275     NSBitmapImageRep * bitmap = [[NSBitmapImageRep alloc]
    276         initWithBitmapDataPlanes: nil pixelsWide: barWidth
    277         pixelsHigh: BAR_HEIGHT bitsPerSample: 8 samplesPerPixel: 4
    278         hasAlpha: YES isPlanar: NO colorSpaceName:
    279         NSCalibratedRGBColorSpace bytesPerRow: 0 bitsPerPixel: 0];
    280     NSImage * img = [[NSImage alloc] initWithSize: [bitmap size]];
    281     [img addRepresentation: bitmap];
    282     [img setFlipped: YES];
    283    
    284     [self buildBarWithWidth: barWidth bitmap: bitmap];
    285    
    286     [img drawAtPoint: pen fromRect: NSMakeRect( 0, 0,
    287             [img size].width, [img size].height )
    288         operation: NSCompositeSourceOver fraction: 1.0];
    289     [img release];
    290     [bitmap release];
     302    if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseAdvancedBar"])
     303        [self buildAdvancedBar: barWidth point: pen];
     304    else
     305        [self buildSimpleBar: barWidth point: pen];
    291306
    292307    //status strings
    293308    pen.x += extraNameShift;
    294     pen.y += BAR_HEIGHT + linePadding;
     309    pen.y += linePadding;
    295310    NSAttributedString * statusString = [[fTorrent statusString]
    296311        attributedStringFittingInWidth: mainWidth attributes: statusAttributes];
Note: See TracChangeset for help on using the changeset viewer.