1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-03 02:05:19 +00:00

only draw rows that are visible

This commit is contained in:
Mitchell Livingston 2007-08-08 17:57:50 +00:00
parent bccab83fde
commit 7a049126a9
4 changed files with 44 additions and 47 deletions

View file

@ -205,6 +205,8 @@
- (void) sleepCallBack: (natural_t) messageType argument: (void *) messageArgument;
- (void) torrentTableViewSelectionDidChange: (NSNotification *) notification;
- (void) toggleSmallView: (id) sender;
- (void) toggleStatusBar: (id) sender;

View file

@ -391,6 +391,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[nc addObserver: self selector: @selector(torrentRestartedDownloading:)
name: @"TorrentRestartedDownloading" object: nil];
//avoids need of setting delegate
[nc addObserver: self selector: @selector(torrentTableViewSelectionDidChange:)
name: NSTableViewSelectionDidChangeNotification object: fTableView];
[nc addObserver: self selector: @selector(updateControlTint:)
name: NSControlTintDidChangeNotification object: nil];
@ -2208,8 +2212,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
return YES;
}
#warning get rid of delegate and make a notification
- (void) tableViewSelectionDidChange: (NSNotification *) notification
- (void) torrentTableViewSelectionDidChange: (NSNotification *) notification
{
[fInfoController updateInfoForTorrents: [fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]]];
}

Binary file not shown.

View file

@ -76,6 +76,8 @@
[NSFont messageFontOfSize: 9.0], NSFontAttributeName, nil];
fDefaults = [NSUserDefaults standardUserDefaults];
[self setDelegate: self];
}
return self;
@ -351,55 +353,45 @@
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateStats" object: nil];
}
#warning only update shown
- (void) drawRect: (NSRect) r
- (void) drawRow: (int) row clipRect: (NSRect) rect
{
NSRect rect;
Torrent * torrent;
NSImage * image;
BOOL smallView = [fDefaults boolForKey: @"SmallView"];
[super drawRow: row clipRect: rect];
[super drawRect: r];
Torrent * torrent = [fTorrents objectAtIndex: row];
int i;
for (i = 0; i < [fTorrents count]; i++)
//pause/resume icon
NSImage * pauseImage = nil;
NSRect pauseRect = [self pauseRectForRow: row];
if ([torrent isActive])
{
torrent = [fTorrents objectAtIndex: i];
rect = [self pauseRectForRow: i];
//pause/resume icon
image = nil;
if ([torrent isActive])
{
if (![torrent isChecking])
image = NSPointInRect(fClickPoint, rect) ? fPauseOnIcon : fPauseOffIcon;
}
else if ([torrent isPaused])
{
if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask && [fDefaults boolForKey: @"Queue"])
image = NSPointInRect(fClickPoint, rect) ? fResumeNoWaitOnIcon : fResumeNoWaitOffIcon;
else if ([torrent waitingToStart])
image = NSPointInRect(fClickPoint, rect) ? fPauseOnIcon : fPauseOffIcon;
else
image = NSPointInRect(fClickPoint, rect) ? fResumeOnIcon : fResumeOffIcon;
}
else;
if (image)
[image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver];
//reveal icon
rect = [self revealRectForRow: i];
image = NSPointInRect(fClickPoint, rect) ? fRevealOnIcon : fRevealOffIcon;
[image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver];
//action icon
if (!smallView)
{
rect = [self actionRectForRow: i];
image = NSPointInRect(fClickPoint, rect) ? fActionOnIcon : fActionOffIcon;
[image compositeToPoint: NSMakePoint(rect.origin.x, NSMaxY(rect)) operation: NSCompositeSourceOver];
}
if (![torrent isChecking])
pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fPauseOnIcon : fPauseOffIcon;
}
else if ([torrent isPaused])
{
if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask && [fDefaults boolForKey: @"Queue"])
pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fResumeNoWaitOnIcon : fResumeNoWaitOffIcon;
else if ([torrent waitingToStart])
pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fPauseOnIcon : fPauseOffIcon;
else
pauseImage = NSPointInRect(fClickPoint, pauseRect) ? fResumeOnIcon : fResumeOffIcon;
}
else;
if (pauseImage)
[pauseImage compositeToPoint: NSMakePoint(pauseRect.origin.x, NSMaxY(pauseRect)) operation: NSCompositeSourceOver];
//reveal icon
NSRect revealRect = [self revealRectForRow: row];
NSImage * revealImage = NSPointInRect(fClickPoint, revealRect) ? fRevealOnIcon : fRevealOffIcon;
[revealImage compositeToPoint: NSMakePoint(revealRect.origin.x, NSMaxY(revealRect)) operation: NSCompositeSourceOver];
//action icon
if (![fDefaults boolForKey: @"SmallView"])
{
NSRect actionRect = [self actionRectForRow: row];
NSImage * actionImage = NSPointInRect(fClickPoint, actionRect) ? fActionOnIcon : fActionOffIcon;
[actionImage compositeToPoint: NSMakePoint(actionRect.origin.x, NSMaxY(actionRect)) operation: NSCompositeSourceOver];
}
}