Changeset 9737


Ignore:
Timestamp:
Dec 13, 2009, 3:13:34 AM (12 years ago)
Author:
livings124
Message:

less calculations are usually a good thing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/TorrentCell.m

    r9726 r9737  
    7070
    7171- (NSRect) rectForMinimalStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
    72 - (NSRect) rectForTitleWithString: (NSAttributedString *) string basedOnMinimalStatusRect: (NSRect) statusRect
     72- (NSRect) rectForTitleWithStringBasedOnMinimalStatusRect: (NSRect) statusRect
    7373            inBounds: (NSRect) bounds;
    74 - (NSRect) rectForProgressWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
    75 - (NSRect) rectForStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
     74- (NSRect) rectForProgressWithStringInBounds: (NSRect) bounds;
     75- (NSRect) rectForStatusWithStringInBounds: (NSRect) bounds;
    7676- (NSRect) barRectForBounds: (NSRect) bounds;
    7777
     
    383383    //title
    384384    NSAttributedString * titleString = [self attributedTitle];
    385     NSRect titleRect = [self rectForTitleWithString: titleString basedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame];
     385    NSRect titleRect = [self rectForTitleWithStringBasedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame];
    386386    [titleString drawInRect: titleRect];
    387387   
     
    405405    {
    406406        NSAttributedString * progressString = [self attributedStatusString: [torrent progressString]];
    407         NSRect progressRect = [self rectForProgressWithString: progressString inBounds: cellFrame];
     407        NSRect progressRect = [self rectForProgressWithStringInBounds: cellFrame];
    408408       
    409409        [progressString drawInRect: progressRect];
     
    468468    {
    469469        NSAttributedString * statusString = [self attributedStatusString: [self statusString]];
    470         [statusString drawInRect: [self rectForStatusWithString: statusString inBounds: cellFrame]];
     470        [statusString drawInRect: [self rectForStatusWithStringInBounds: cellFrame]];
    471471    }
    472472}
     
    623623}
    624624
    625 - (NSRect) rectForTitleWithString: (NSAttributedString *) string basedOnMinimalStatusRect: (NSRect) statusRect
     625- (NSRect) rectForTitleWithStringBasedOnMinimalStatusRect: (NSRect) statusRect
    626626            inBounds: (NSRect) bounds
    627627{
     
    633633                        + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_TITLE;
    634634   
    635     result.size = [string size];
    636     result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL
    637                 - (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + statusRect.size.width : 0.0)
    638                 - ([[self representedObject] priority] != TR_PRI_NORMAL ? PRIORITY_ICON_WIDTH + PADDING_BETWEEN_TITLE_AND_PRIORITY: 0.0));
     635    result.size.height = HEIGHT_TITLE;
     636    result.size.width = NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL
     637                - (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + NSWidth(statusRect) : 0.0)
     638                - ([[self representedObject] priority] != TR_PRI_NORMAL ? PRIORITY_ICON_WIDTH + PADDING_BETWEEN_TITLE_AND_PRIORITY: 0.0);
    639639   
    640640    return result;
    641641}
    642642
    643 - (NSRect) rectForProgressWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
     643- (NSRect) rectForProgressWithStringInBounds: (NSRect) bounds
    644644{
    645645    NSRect result;
     
    647647    result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_TITLE;
    648648   
    649     result.size = [string size];
    650     result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL);
     649    result.size.height = HEIGHT_STATUS;
     650    result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
    651651   
    652652    return result;
    653653}
    654654
    655 - (NSRect) rectForStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
     655- (NSRect) rectForStatusWithStringInBounds: (NSRect) bounds
    656656{
    657657    NSRect result;
     
    660660    result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_TITLE;
    661661   
    662     result.size = [string size];
    663     result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL);
     662    result.size.height = HEIGHT_STATUS;
     663    result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
    664664   
    665665    return result;
Note: See TracChangeset for help on using the changeset viewer.