]> granicus.if.org Git - transmission/commitdiff
same for torrent table, and fix a code placement issue
authorMitchell Livingston <livings124@transmissionbt.com>
Thu, 17 Sep 2009 04:36:09 +0000 (04:36 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Thu, 17 Sep 2009 04:36:09 +0000 (04:36 +0000)
macosx/TorrentTableView.m
macosx/TrackerTableView.m

index 6c095bedcea2c0f7bd56b76f584abcfb667aabc2..c44097a5ed43aaa6fb9c57583512af34ff457346 100644 (file)
 //alternating rows - first row after group row is white
 - (void) highlightSelectionInClipRect: (NSRect) clipRect
 {
-    NSColor * altColor = [[NSColor controlAlternatingRowBackgroundColors] objectAtIndex: 1];
-    [altColor set];
-    
     NSRect visibleRect = clipRect;
     NSRange rows = [self rowsInRect: visibleRect];
     BOOL start = YES;
     
+    const CGFloat totalRowHeight = [self rowHeight] + [self intercellSpacing].height;
+    
+    NSRect * gridRects = (NSRect *)alloca(sizeof(NSRect) * (ceil(visibleRect.size.height / totalRowHeight) / 2));
+    NSInteger rectNum = 0;
+    
     if (rows.length > 0)
     {
         //determine what the first row color should be
             }
             
             if (!start && ![self isRowSelected: i])
-                NSRectFill([self rectOfRow: i]);
+                gridRects[rectNum++] = [self rectOfRow: i];
             
             start = !start;
         }
         
-        CGFloat newY = NSMaxY([self rectOfRow: i-1]);
+        const CGFloat newY = NSMaxY([self rectOfRow: i-1]);
         visibleRect.size.height -= newY - visibleRect.origin.y;
         visibleRect.origin.y = newY;
     }
-        
-    //remaining visible rows continue alternating
-    const CGFloat height = [self rowHeight] + [self intercellSpacing].height;
-    const NSInteger numberOfRects = ceil(visibleRect.size.height / height);
     
-    visibleRect.size.height = height;
-    if (start)
-        visibleRect.origin.y += height;
+    const NSInteger numberBlankRows = ceil(visibleRect.size.height / totalRowHeight);
     
-    for (NSInteger i = start ? 1 : 0; i < numberOfRects; i += 2)
+    //remaining visible rows continue alternating
+    visibleRect.size.height = totalRowHeight;
+    if (start)
+        visibleRect.origin.y += totalRowHeight;
+    for (NSInteger i = start ? 1 : 0; i < numberBlankRows; i += 2)
     {
-        NSRectFill(visibleRect);
-        visibleRect.origin.y += 2.0 * height;
+        gridRects[rectNum++] = visibleRect;
+        visibleRect.origin.y += 2.0 * totalRowHeight;
     }
     
+    NSAssert([[NSColor controlAlternatingRowBackgroundColors] count] >= 2, @"There should be 2 alternating row colors");
+    
+    [[[NSColor controlAlternatingRowBackgroundColors] objectAtIndex: 1] set];
+    NSRectFillList(gridRects, rectNum);
+    
     [super highlightSelectionInClipRect: clipRect];
 }
 
index 5d076e2e49e7f16badec8eb1a6b0b49cef925e76..9c625adeb99e54a0224315bdd52fcbde27b40e6e 100644 (file)
         visibleRect.origin.y = newY;
     }
     
+    const NSInteger numberBlankRows = ceil(visibleRect.size.height / totalRowHeight);
+    
     //remaining visible rows continue alternating
     visibleRect.size.height = totalRowHeight;
     if (start)
         visibleRect.origin.y += totalRowHeight;
-    
-    const NSInteger numberBlankRows = ceil(visibleRect.size.height / totalRowHeight);
     for (NSInteger i = start ? 1 : 0; i < numberBlankRows; i += 2)
     {
         gridRects[rectNum++] = visibleRect;