streamline and improve action button placement code in TorrentTableView

This commit is contained in:
Mitchell Livingston 2007-08-16 03:28:01 +00:00
parent 7a96fcbb7f
commit 91304ec1e6
3 changed files with 12 additions and 14 deletions

View File

@ -54,7 +54,7 @@
- (void) drawSimpleBar: (NSRect) barRect;
- (void) drawAdvancedBar: (NSRect) barRect;
- (NSImage *) advancedBarSimple;
- (NSImage *) advancedBar;
- (NSRect) rectForMinimalStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
- (NSRect) rectForTitleWithString: (NSAttributedString *) string basedOnMinimalStatusRect: (NSRect) statusRect
@ -369,7 +369,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (void) drawAdvancedBar: (NSRect) barRect
{
[[self advancedBarSimple] drawInRect: barRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
[[self advancedBar] drawInRect: barRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
if (!fTransparentGradient)
fTransparentGradient = [[CTGradient progressTransparentGradient] retain];
@ -379,7 +379,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[NSBezierPath strokeRect: NSInsetRect(barRect, 0.5, 0.5)];
}
- (NSImage *) advancedBarSimple
- (NSImage *) advancedBar
{
if (!fBitmap)
fBitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: nil

View File

@ -26,8 +26,6 @@
#import <transmission.h>
#import <Controller.h>
#define PADDING 3.0
//button layout (from end of bar) is: button, padding, button, padding
#define BUTTON_WIDTH 14.0
#define BUTTONS_TOTAL_WIDTH 36.0

View File

@ -27,6 +27,8 @@
#import "Controller.h"
#import "Torrent.h"
#define PADDING 3.0
#define BUTTON_TO_TOP_REGULAR 33.0
#define BUTTON_TO_TOP_SMALL 20.0
@ -474,17 +476,15 @@
{
if (row < 0)
return NSZeroRect;
else if ([fDefaults boolForKey: @"SmallView"])
{
TorrentCell * cell = [[self tableColumnWithIdentifier: @"Torrent"] dataCell];
return [cell iconRectForBounds: [self frameOfCellAtColumn: 0 row: row]];
}
else;
NSRect cellRect = [self frameOfCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: row];
TorrentCell * cell = [[self tableColumnWithIdentifier: @"Torrent"] dataCell];
NSRect cellRect = [self frameOfCellAtColumn: 0 row: row],
iconRect = [cell iconRectForBounds: cellRect];
return NSMakeRect(cellRect.origin.x + PADDING +
([[[fTorrents objectAtIndex: row] iconFlipped] size].width - ACTION_BUTTON_WIDTH) * 0.5,
if ([fDefaults boolForKey: @"SmallView"])
return iconRect;
else
return NSMakeRect(iconRect.origin.x + (iconRect.size.width - ACTION_BUTTON_WIDTH) * 0.5,
cellRect.origin.y + ACTION_BUTTON_TO_TOP, ACTION_BUTTON_WIDTH, ACTION_BUTTON_HEIGHT);
}