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/TrackerTableView.m

    r5923 r5925  
    3636{
    3737    NSColor * altColor = [[NSColor controlAlternatingRowBackgroundColors] objectAtIndex: 1];
     38    [altColor set];
    3839   
    3940    NSRect visibleRect = clipRect;
    4041    NSRange rows = [self rowsInRect: visibleRect];
    4142    BOOL start = YES;
     43    int i;
    4244   
    4345    if (rows.length > 0)
    4446    {
    45         int i;
    46        
    4747        //determine what the first row color should be
    4848        if (![[fTrackers objectAtIndex: rows.location] isKindOfClass: [NSNumber class]])
     
    7070           
    7171            if (!start)
    72             {
    73                 [altColor set];
    7472                NSRectFill([self rectOfRow: i]);
    75             }
    7673           
    7774            start = !start;
     
    8481   
    8582    //remaining visible rows continue alternating
    86     NSRect rowRect = visibleRect;
    87     rowRect.size.height = [self rowHeight] + [self intercellSpacing].height;
     83    float height = [self rowHeight] + [self intercellSpacing].height;
     84    int numberOfRects = ceil(visibleRect.size.height / height);
     85    visibleRect.size.height = height;
    8886   
    89     while (rowRect.origin.y < NSMaxY(visibleRect))
     87    for (i=0; i<numberOfRects; i++)
    9088    {
    9189        if (!start)
    92         {
    93             [altColor set];
    94             NSRectFill(rowRect);
    95         }
     90            NSRectFill(visibleRect);
    9691       
    9792        start = !start;
    98         rowRect.origin.y += rowRect.size.height;
     93        visibleRect.origin.y += height;
    9994    }
    10095   
Note: See TracChangeset for help on using the changeset viewer.