Ignore:
Timestamp:
May 23, 2008, 8:36:19 PM (14 years ago)
Author:
livings124
Message:

even more efficiency when drawing custom row colors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/TorrentTableView.m

    r5923 r5925  
    703703{
    704704    NSColor * altColor = [[NSColor controlAlternatingRowBackgroundColors] objectAtIndex: 1];
     705    [altColor set];
    705706   
    706707    NSRect visibleRect = clipRect;
    707708    NSRange rows = [self rowsInRect: visibleRect];
    708709    BOOL start = YES;
     710    int i;
    709711   
    710712    if (rows.length > 0)
    711713    {
    712         int i;
    713        
    714714        //determine what the first row color should be
    715715        if ([[self itemAtRow: rows.location] isKindOfClass: [Torrent class]])
     
    737737           
    738738            if (!start)
    739             {
    740                 [altColor set];
    741739                NSRectFill([self rectOfRow: i]);
    742             }
    743740           
    744741            start = !start;
     
    751748   
    752749    //remaining visible rows continue alternating
    753     NSRect rowRect = visibleRect;
    754     rowRect.size.height = [self rowHeight] + [self intercellSpacing].height;
    755    
    756     while (rowRect.origin.y < NSMaxY(visibleRect))
     750    float height = [self rowHeight] + [self intercellSpacing].height;
     751    int numberOfRects = ceil(visibleRect.size.height / height);
     752    visibleRect.size.height = height;
     753   
     754    for (i=0; i<numberOfRects; i++)
    757755    {
    758756        if (!start)
    759         {
    760             [altColor set];
    761             NSRectFill(rowRect);
    762         }
     757            NSRectFill(visibleRect);
    763758       
    764759        start = !start;
    765         rowRect.origin.y += rowRect.size.height;
     760        visibleRect.origin.y += height;
    766761    }
    767762   
Note: See TracChangeset for help on using the changeset viewer.