Changeset 657


Ignore:
Timestamp:
Jul 22, 2006, 4:57:41 PM (16 years ago)
Author:
livings124
Message:

Simplify window sizing code a little.

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r655 r657  
    180180
    181181- (void) setWindowSizeToFit;
     182- (NSRect) windowFrameFor: (int) count;
    182183
    183184- (void) showMainWindow:    (id) sender;
  • trunk/macosx/Controller.m

    r656 r657  
    21252125        return [fWindow frame];
    21262126
    2127     NSRect windowRect = [fWindow frame];
    2128     float newHeight = windowRect.size.height - [fScrollView frame].size.height
    2129         + [fFilteredTorrents count] * ([fTableView rowHeight] + [fTableView intercellSpacing].height);
     2127    return [self windowFrameFor: [fFilteredTorrents count]];
     2128}
     2129
     2130- (void) setWindowSizeToFit
     2131{
     2132    if (![fDefaults boolForKey: @"AutoSize"])
     2133        return;
     2134
     2135    [fWindow setFrame: [self windowFrameFor: [fTorrents count]] display: YES animate: YES];
     2136}
     2137
     2138- (NSRect) windowFrameFor: (int) count
     2139{
     2140    NSRect frame = [fWindow frame];
     2141    float newHeight = frame.size.height - [fScrollView frame].size.height
     2142        + count * ([fTableView rowHeight] + [fTableView intercellSpacing].height);
    21302143
    21312144    float minHeight = [fWindow minSize].height;
     
    21332146        newHeight = minHeight;
    21342147
    2135     windowRect.origin.y -= (newHeight - windowRect.size.height);
    2136     windowRect.size.height = newHeight;
    2137 
    2138     return windowRect;
    2139 }
    2140 
    2141 - (void) setWindowSizeToFit
    2142 {
    2143     if (![fDefaults boolForKey: @"AutoSize"])
    2144         return;
    2145 
    2146     NSRect frame = [fWindow frame];
    2147     float newHeight = frame.size.height - [fScrollView frame].size.height
    2148         + [fTorrents count] * ([fTableView rowHeight] + [fTableView intercellSpacing].height);
    2149 
    2150     float minHeight = [fWindow minSize].height;
    2151     if (newHeight < minHeight)
    2152         newHeight = minHeight;
    2153 
    21542148    frame.origin.y -= (newHeight - frame.size.height);
    21552149    frame.size.height = newHeight;
    21562150   
    2157     [fWindow setFrame: frame display: YES animate: YES];
     2151    return frame;
    21582152}
    21592153
Note: See TracChangeset for help on using the changeset viewer.