From 30ef4b0a52b7d274713e86c535698073e08241d9 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sun, 23 Jul 2006 19:22:24 +0000 Subject: [PATCH] simplify rect width and height measurements --- macosx/Badger.m | 12 ++++-------- macosx/Controller.m | 13 +++++++------ macosx/InfoWindowController.m | 3 +-- macosx/TorrentCell.m | 2 +- macosx/TorrentTableView.m | 4 ++-- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/macosx/Badger.m b/macosx/Badger.m index 15d5b3265..460df3b30 100644 --- a/macosx/Badger.m +++ b/macosx/Badger.m @@ -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]; diff --git a/macosx/Controller.m b/macosx/Controller.m index 5aefcd9b0..4d236aa86 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -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]; diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index f00127eb9..b2fc3aa75 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -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 ? diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index f2c3af6d0..c18e54767 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -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]; diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 1df0bf161..5f2ea752f 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -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); }