From e03444fe86afbb76fa06cf10d6c6a36edbe0b96f Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 23 May 2008 20:36:19 +0000 Subject: [PATCH] even more efficiency when drawing custom row colors --- macosx/TorrentTableView.m | 21 ++++++++------------- macosx/TrackerTableView.m | 21 ++++++++------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 95d4934f9..7ce7e1ef5 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -702,15 +702,15 @@ - (void) highlightSelectionInClipRect: (NSRect) clipRect { NSColor * altColor = [[NSColor controlAlternatingRowBackgroundColors] objectAtIndex: 1]; + [altColor set]; NSRect visibleRect = clipRect; NSRange rows = [self rowsInRect: visibleRect]; BOOL start = YES; + int i; if (rows.length > 0) { - int i; - //determine what the first row color should be if ([[self itemAtRow: rows.location] isKindOfClass: [Torrent class]]) { @@ -736,10 +736,7 @@ } if (!start) - { - [altColor set]; NSRectFill([self rectOfRow: i]); - } start = !start; } @@ -750,19 +747,17 @@ } //remaining visible rows continue alternating - NSRect rowRect = visibleRect; - rowRect.size.height = [self rowHeight] + [self intercellSpacing].height; + float height = [self rowHeight] + [self intercellSpacing].height; + int numberOfRects = ceil(visibleRect.size.height / height); + visibleRect.size.height = height; - while (rowRect.origin.y < NSMaxY(visibleRect)) + for (i=0; i 0) { - int i; - //determine what the first row color should be if (![[fTrackers objectAtIndex: rows.location] isKindOfClass: [NSNumber class]]) { @@ -69,10 +69,7 @@ } if (!start) - { - [altColor set]; NSRectFill([self rectOfRow: i]); - } start = !start; } @@ -83,19 +80,17 @@ } //remaining visible rows continue alternating - NSRect rowRect = visibleRect; - rowRect.size.height = [self rowHeight] + [self intercellSpacing].height; + float height = [self rowHeight] + [self intercellSpacing].height; + int numberOfRects = ceil(visibleRect.size.height / height); + visibleRect.size.height = height; - while (rowRect.origin.y < NSMaxY(visibleRect)) + for (i=0; i