Changeset 10407


Ignore:
Timestamp:
Mar 20, 2010, 6:54:24 PM (12 years ago)
Author:
livings124
Message:

appropriately shorten the title length when showing the control buttons in compact view

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/TorrentCell.m

    r10406 r10407  
    5656#define PADDING_BETWEEN_TITLE_AND_PROGRESS 1.0
    5757#define PADDING_BETWEEN_PROGRESS_AND_BAR 2.0
    58 #define PADDING_BETWEEN_TITLE_AND_BAR_MIN 3.0
    5958#define PADDING_BETWEEN_BAR_AND_STATUS 2.0
    6059
     
    7069
    7170- (NSRect) rectForMinimalStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
    72 - (NSRect) rectForTitleWithString: (NSAttributedString *) string basedOnMinimalStatusRect: (NSRect) statusRect inBounds: (NSRect) bounds;
     71- (NSRect) rectForTitleWithString: (NSAttributedString *) string withRightBound: (CGFloat) rightBound inBounds: (NSRect) bounds;
    7372- (NSRect) rectForProgressWithStringInBounds: (NSRect) bounds;
    7473- (NSRect) rectForStatusWithStringInBounds: (NSRect) bounds;
     
    277276    NSMutableDictionary * revealInfo = [userInfo mutableCopy];
    278277    [revealInfo setObject: @"Reveal" forKey: @"Type"];
    279     NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: revealButtonRect options: revealOptions owner: controlView userInfo: revealInfo];
     278    NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: revealButtonRect options: revealOptions owner: controlView
     279                                userInfo: revealInfo];
    280280    [controlView addTrackingArea: area];
    281281    [revealInfo release];
     
    404404       
    405405        [minimalString drawInRect: minimalStatusRect];
    406     }
    407    
    408     //title
    409     NSAttributedString * titleString = [self attributedTitle];
    410     NSRect titleRect = [self rectForTitleWithString: titleString basedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame];
    411     [titleString drawInRect: titleRect];
    412    
    413     //priority icon
    414     if ([torrent priority] != TR_PRI_NORMAL)
    415     {
    416         NSImage * priorityImage = [torrent priority] == TR_PRI_HIGH ? [NSImage imageNamed: @"PriorityHigh.png"]
    417                                                                     : [NSImage imageNamed: @"PriorityLow.png"];
    418         //take line out completely when 10.6-only
    419         priorityImage = [NSApp isOnSnowLeopardOrBetter] ? [priorityImage retain] : [priorityImage copy];
    420        
    421         NSRect priorityRect = NSMakeRect(NSMaxX(titleRect) + PADDING_BETWEEN_TITLE_AND_PRIORITY,
    422                                         NSMidY(titleRect) - PRIORITY_ICON_HEIGHT  * 0.5,
    423                                         PRIORITY_ICON_WIDTH, PRIORITY_ICON_HEIGHT);
    424        
    425         [self drawImage: priorityImage inRect: priorityRect];
    426         [priorityImage release];
    427406    }
    428407   
     
    460439        }
    461440       
    462         [self drawImage: controlImage inRect: [self controlButtonRectForBounds: cellFrame]];
     441        const NSRect controlRect = [self controlButtonRectForBounds: cellFrame];
     442        [self drawImage: controlImage inRect: controlRect];
     443        minimalStatusRect = controlRect; //used for limiting title width
    463444       
    464445        //reveal button
     
    488469            [self drawImage: actionImage inRect: [self actionButtonRectForBounds: cellFrame]];
    489470        }
     471    }
     472   
     473    //title
     474    NSAttributedString * titleString = [self attributedTitle];
     475    NSRect titleRect = [self rectForTitleWithString: titleString withRightBound: NSMinX(minimalStatusRect) inBounds: cellFrame];
     476    [titleString drawInRect: titleRect];
     477   
     478    //priority icon
     479    if ([torrent priority] != TR_PRI_NORMAL)
     480    {
     481        NSImage * priorityImage = [torrent priority] == TR_PRI_HIGH ? [NSImage imageNamed: @"PriorityHigh.png"]
     482                                                                    : [NSImage imageNamed: @"PriorityLow.png"];
     483        //take line out completely when 10.6-only
     484        priorityImage = [NSApp isOnSnowLeopardOrBetter] ? [priorityImage retain] : [priorityImage copy];
     485       
     486        NSRect priorityRect = NSMakeRect(NSMaxX(titleRect) + PADDING_BETWEEN_TITLE_AND_PRIORITY,
     487                                        NSMidY(titleRect) - PRIORITY_ICON_HEIGHT  * 0.5,
     488                                        PRIORITY_ICON_WIDTH, PRIORITY_ICON_HEIGHT);
     489       
     490        [self drawImage: priorityImage inRect: priorityRect];
     491        [priorityImage release];
    490492    }
    491493   
     
    665667}
    666668
    667 - (NSRect) rectForTitleWithString: (NSAttributedString *) string basedOnMinimalStatusRect: (NSRect) statusRect inBounds: (NSRect) bounds
     669- (NSRect) rectForTitleWithString: (NSAttributedString *) string withRightBound: (CGFloat) rightBound inBounds: (NSRect) bounds
    668670{
    669671    const BOOL minimal = [fDefaults boolForKey: @"SmallView"];
     
    675677   
    676678    result.size.height = HEIGHT_TITLE;
    677     result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
    678679    if (minimal)
    679         result.size.width -= PADDING_BETWEEN_TITLE_AND_MIN_STATUS + NSWidth(statusRect);
     680        result.size.width = rightBound - NSMinX(result) - PADDING_BETWEEN_TITLE_AND_MIN_STATUS;
     681    else
     682        result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
     683   
    680684    if ([[self representedObject] priority] != TR_PRI_NORMAL)
    681685    {
  • trunk/macosx/TorrentTableView.m

    r10406 r10407  
    231231    [self removeTrackingAreas];
    232232   
    233     NSRange rows = [self rowsInRect: [self visibleRect]];
     233    const NSRange rows = [self rowsInRect: [self visibleRect]];
    234234    if (rows.length == 0)
    235235        return;
     
    263263- (void) setRowHover: (NSInteger) row
    264264{
     265    NSAssert([fDefaults boolForKey: @"SmallView"], @"cannot set a hover row when not in compact view");
     266   
    265267    fMouseRow = row;
    266268    if (row >= 0)
Note: See TracChangeset for help on using the changeset viewer.