simplify rect width and height measurements

This commit is contained in:
Mitchell Livingston 2006-07-23 19:22:24 +00:00
parent bd9593226e
commit 30ef4b0a52
5 changed files with 15 additions and 19 deletions

View File

@ -96,8 +96,7 @@
[dockIcon lockFocus];
//place badge
[fBadge compositeToPoint: badgeRect.origin
operation: NSCompositeSourceOver];
[fBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOver];
//ignore shadow of badge when placing string
float badgeBottomExtra = 5.0;
@ -105,8 +104,7 @@
badgeRect.origin.y += badgeBottomExtra;
//place badge text
[self badgeString: [NSString stringWithInt: completed]
forRect: badgeRect];
[self badgeString: [NSString stringWithInt: completed] forRect: badgeRect];
[dockIcon unlockFocus];
}
@ -143,8 +141,7 @@
if (uploadRateString)
{
//place badge
[fUploadBadge compositeToPoint: badgeRect.origin
operation: NSCompositeSourceOver];
[fUploadBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOver];
//place badge text
[self badgeString: uploadRateString forRect: stringRect];
@ -161,8 +158,7 @@
}
//place badge
[fDownloadBadge compositeToPoint: badgeRect.origin
operation: NSCompositeSourceOver];
[fDownloadBadge compositeToPoint: badgeRect.origin operation: NSCompositeSourceOver];
//place badge text
[self badgeString: downloadRateString forRect: stringRect];

View File

@ -47,8 +47,9 @@
#define TORRENT_TABLE_VIEW_DATA_TYPE @"TorrentTableViewDataType"
#define ROW_HEIGHT_REGULAR 65.0
#define ROW_HEIGHT_SMALL 40.0
#define ROW_HEIGHT_REGULAR 65.0
#define ROW_HEIGHT_SMALL 40.0
#define WINDOW_REGULAR_WIDTH 468.0
#define WEBSITE_URL @"http://transmission.m0k.org/"
#define FORUM_URL @"http://transmission.m0k.org/forum/"
@ -150,7 +151,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[fFilterBar setFrame: filterBarFrame];
[contentView addSubview: fFilterBar];
[fFilterBar setFrameOrigin: NSMakePoint(0, [contentView frame].origin.y + [contentView frame].size.height)];
[fFilterBar setFrameOrigin: NSMakePoint(0, NSMaxY([contentView frame]))];
[self showFilterBar: [fDefaults boolForKey: @"FilterBar"] animate: NO];
@ -163,7 +164,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[fStatusBar setFrame: statusBarFrame];
[contentView addSubview: fStatusBar];
[fStatusBar setFrameOrigin: NSMakePoint(0, [contentView frame].origin.y + [contentView frame].size.height)];
[fStatusBar setFrameOrigin: NSMakePoint(0, NSMaxY([contentView frame]))];
[self showStatusBar: [fDefaults boolForKey: @"StatusBar"] animate: NO];
//set speed limit
@ -2119,7 +2120,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
NSRect frame = [fDefaults boolForKey: @"AutoSize"] ? [window frame]
: [self windowFrameForAmount: [fFilteredTorrents count]];
frame.size.width = [fDefaults boolForKey: @"SmallView"] ? [fWindow minSize].width : 468.0;
frame.size.width = [fDefaults boolForKey: @"SmallView"] ? [fWindow minSize].width : WINDOW_REGULAR_WIDTH;
return frame;
}
@ -2186,7 +2187,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
{
//hide search filter if it overlaps filter buttons
NSRect buttonFrame = [fPauseFilterButton frame];
if (buttonFrame.origin.x + buttonFrame.size.width + 2.0 > [fSearchFilterField frame].origin.x)
if (NSMaxX(buttonFrame) + 2.0 > [fSearchFilterField frame].origin.x)
{
if (![fSearchFilterField isHidden])
[fSearchFilterField setHidden: YES];

View File

@ -217,8 +217,7 @@
[fStateField setStringValue: [torrent stateString]];
/*
[fPercentField setStringValue: [NSString stringWithFormat:
@"%.2f%%", 100.0 * [torrent progress]]];
[fPercentField setStringValue: [NSString stringWithFormat: @"%.2f%%", 100.0 * [torrent progress]]];
*/
int seeders = [torrent seeders], leechers = [torrent leechers];
[fSeedersField setStringValue: seeders < 0 ?

View File

@ -367,7 +367,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[nameString drawAtPoint: pen];
//place status string
pen.x = cellFrame.origin.x + cellFrame.size.width - PADDING - [statusString size].width;
pen.x = NSMaxX(cellFrame) - PADDING - [statusString size].width;
pen.y += ([nameString size].height - [statusString size].height) * 0.5;
[statusString drawAtPoint: pen];

View File

@ -189,7 +189,7 @@
float buttonToTop = [fDefaults boolForKey: @"SmallView"] ? BUTTON_TO_TOP_SMALL : BUTTON_TO_TOP_REGULAR;
return NSMakeRect(cellRect.origin.x + cellRect.size.width - AREA_CENTER - DISTANCE_FROM_CENTER - BUTTON_WIDTH,
return NSMakeRect(NSMaxX(cellRect) - AREA_CENTER - DISTANCE_FROM_CENTER - BUTTON_WIDTH,
cellRect.origin.y + buttonToTop, BUTTON_WIDTH, BUTTON_WIDTH);
}
@ -199,7 +199,7 @@
float buttonToTop = [fDefaults boolForKey: @"SmallView"] ? BUTTON_TO_TOP_SMALL : BUTTON_TO_TOP_REGULAR;
return NSMakeRect(cellRect.origin.x + cellRect.size.width - AREA_CENTER + DISTANCE_FROM_CENTER,
return NSMakeRect(NSMaxX(cellRect) - AREA_CENTER + DISTANCE_FROM_CENTER,
cellRect.origin.y + buttonToTop, BUTTON_WIDTH, BUTTON_WIDTH);
}