From d25466eefc31a0135058a9074a1d17eb59a9a23a Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 22 Jul 2006 16:57:41 +0000 Subject: [PATCH] Simplify window sizing code a little. --- macosx/Controller.h | 1 + macosx/Controller.m | 22 ++++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/macosx/Controller.h b/macosx/Controller.h index 20c3162c2..a0e66a069 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -179,6 +179,7 @@ - (void) toggleAdvancedBar: (id) sender; - (void) setWindowSizeToFit; +- (NSRect) windowFrameFor: (int) count; - (void) showMainWindow: (id) sender; - (void) linkHomepage: (id) sender; diff --git a/macosx/Controller.m b/macosx/Controller.m index 45419edaa..fbf52bfa6 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -2124,18 +2124,7 @@ static void sleepCallBack(void * controller, io_service_t y, if ([fDefaults boolForKey: @"AutoSize"]) return [fWindow frame]; - NSRect windowRect = [fWindow frame]; - float newHeight = windowRect.size.height - [fScrollView frame].size.height - + [fFilteredTorrents count] * ([fTableView rowHeight] + [fTableView intercellSpacing].height); - - float minHeight = [fWindow minSize].height; - if (newHeight < minHeight) - newHeight = minHeight; - - windowRect.origin.y -= (newHeight - windowRect.size.height); - windowRect.size.height = newHeight; - - return windowRect; + return [self windowFrameFor: [fFilteredTorrents count]]; } - (void) setWindowSizeToFit @@ -2143,9 +2132,14 @@ static void sleepCallBack(void * controller, io_service_t y, if (![fDefaults boolForKey: @"AutoSize"]) return; + [fWindow setFrame: [self windowFrameFor: [fTorrents count]] display: YES animate: YES]; +} + +- (NSRect) windowFrameFor: (int) count +{ NSRect frame = [fWindow frame]; float newHeight = frame.size.height - [fScrollView frame].size.height - + [fTorrents count] * ([fTableView rowHeight] + [fTableView intercellSpacing].height); + + count * ([fTableView rowHeight] + [fTableView intercellSpacing].height); float minHeight = [fWindow minSize].height; if (newHeight < minHeight) @@ -2154,7 +2148,7 @@ static void sleepCallBack(void * controller, io_service_t y, frame.origin.y -= (newHeight - frame.size.height); frame.size.height = newHeight; - [fWindow setFrame: frame display: YES animate: YES]; + return frame; } - (void) showMainWindow: (id) sender