From f4562e3bbdd9f4ca8fad8577b68ae24a92cada64 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Mon, 12 Jun 2006 15:26:24 +0000 Subject: [PATCH] Double-clicking the icon in the table view will reveal the download. --- macosx/TorrentCell.m | 3 ++- macosx/TorrentTableView.h | 2 ++ macosx/TorrentTableView.m | 30 ++++++++++++++++++++++++------ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 8af993054..45dabc9fa 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -23,6 +23,7 @@ *****************************************************************************/ #import "TorrentCell.h" +#import "TorrentTableView.h" #import "StringAdditions.h" #define BAR_HEIGHT 12 @@ -269,7 +270,7 @@ static uint32_t kGreen[] = pen.x -= extraNameShift; pen.y += [progressString size].height + linePadding; - float barWidth = mainWidth + extraNameShift - 42.0 + padding; + float barWidth = mainWidth + extraNameShift - BUTTONS_TOTAL_WIDTH + padding; NSBitmapImageRep * bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil pixelsWide: barWidth diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index bc4725409..3efd791b8 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -25,6 +25,8 @@ #import #import +#define BUTTONS_TOTAL_WIDTH 42.0 + @class Controller; @interface TorrentTableView : NSTableView diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 021cb189e..e3c67971c 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -29,8 +29,9 @@ #define BUTTON_WIDTH 14.0 #define BUTTON_TO_TOP 33.5 -#define AREA_CENTER 21.0 #define DISTANCE_FROM_CENTER 2.5 +//change BUTTONS_TOTAL_WIDTH when changing this +#define AREA_CENTER 21.0 @interface TorrentTableView (Private) @@ -38,6 +39,7 @@ - (NSRect) revealRectForRow: (int) row; - (BOOL) pointInPauseRect: (NSPoint) point; - (BOOL) pointInRevealRect: (NSPoint) point; +- (BOOL) pointInIconRect: (NSPoint) point; @end @@ -96,13 +98,15 @@ } else if( sameRow && [self pointInRevealRect: point] && [self pointInRevealRect: fClickPoint] ) - { - torrent = [fTorrents objectAtIndex: row]; - [torrent reveal]; - } + [[fTorrents objectAtIndex: row] reveal]; else if ([e clickCount] == 2) - [fController showInfo: nil]; + { + if ([self pointInIconRect: point]) + [[fTorrents objectAtIndex: row] reveal]; + else + [fController showInfo: nil]; + } [super mouseUp: e]; @@ -205,6 +209,20 @@ cellRect.origin.y + BUTTON_TO_TOP, BUTTON_WIDTH, BUTTON_WIDTH); } +- (BOOL) pointInIconRect: (NSPoint) point +{ + int row = [self rowAtPoint: point]; + NSRect cellRect = [self frameOfCellAtColumn: + [self columnWithIdentifier: @"Torrent"] row: row]; + NSSize iconSize = [[[fTorrents objectAtIndex: row] iconFlipped] size]; + + NSRect iconRect = NSMakeRect(cellRect.origin.x + 3.0, cellRect.origin.y + + (cellRect.size.height - iconSize.height) * 0.5, + iconSize.width, iconSize.height); + + return NSPointInRect(point, iconRect); +} + - (BOOL) pointInPauseRect: (NSPoint) point { return NSPointInRect( point, [self pauseRectForRow: