Changeset 9807


Ignore:
Timestamp:
Dec 20, 2009, 9:02:58 PM (12 years ago)
Author:
livings124
Message:

miscellany

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/GroupsPrefsController.m

    r9800 r9807  
    225225    }
    226226   
    227     [self refreshCustomLocation];
     227    [self refreshCustomLocationWithSingleGroup];
    228228   
    229229    [fCustomLocationPopUp selectItemAtIndex: 0];
  • trunk/macosx/TorrentCell.m

    r9764 r9807  
    3131#import "TorrentTableView.h"
    3232
    33 #define BAR_HEIGHT 12.0f
    34 
    35 #define IMAGE_SIZE_REG 32.0f
    36 #define IMAGE_SIZE_MIN 16.0f
    37 #define ERROR_IMAGE_SIZE 20.0f
    38 
    39 #define NORMAL_BUTTON_WIDTH 14.0f
    40 #define ACTION_BUTTON_WIDTH 16.0f
    41 
    42 #define PRIORITY_ICON_WIDTH 14.0f
    43 #define PRIORITY_ICON_HEIGHT 14.0f
     33#define BAR_HEIGHT 12.0
     34
     35#define IMAGE_SIZE_REG 32.0
     36#define IMAGE_SIZE_MIN 16.0
     37#define ERROR_IMAGE_SIZE 20.0
     38
     39#define NORMAL_BUTTON_WIDTH 14.0
     40#define ACTION_BUTTON_WIDTH 16.0
     41
     42#define PRIORITY_ICON_WIDTH 14.0
     43#define PRIORITY_ICON_HEIGHT 14.0
    4444
    4545//ends up being larger than font height
    46 #define HEIGHT_TITLE 16.0f
    47 #define HEIGHT_STATUS 12.0f
    48 
    49 #define PADDING_HORIZONTAL 3.0f
    50 #define PADDING_BETWEEN_IMAGE_AND_TITLE 5.0f
    51 #define PADDING_BETWEEN_IMAGE_AND_BAR 7.0f
    52 #define PADDING_BETWEEN_TITLE_AND_PRIORITY 4.0f
    53 #define PADDING_ABOVE_TITLE 4.0f
    54 #define PADDING_ABOVE_MIN_STATUS 4.0f
    55 #define PADDING_BETWEEN_TITLE_AND_MIN_STATUS 2.0f
    56 #define PADDING_BETWEEN_TITLE_AND_PROGRESS 1.0f
    57 #define PADDING_BETWEEN_PROGRESS_AND_BAR 2.0f
    58 #define PADDING_BETWEEN_TITLE_AND_BAR_MIN 3.0f
    59 #define PADDING_BETWEEN_BAR_AND_STATUS 2.0f
    60 
    61 #define PIECES_TOTAL_PERCENT 0.6f
     46#define HEIGHT_TITLE 16.0
     47#define HEIGHT_STATUS 12.0
     48
     49#define PADDING_HORIZONTAL 3.0
     50#define PADDING_BETWEEN_IMAGE_AND_TITLE 5.0
     51#define PADDING_BETWEEN_IMAGE_AND_BAR 7.0
     52#define PADDING_BETWEEN_TITLE_AND_PRIORITY 4.0
     53#define PADDING_ABOVE_TITLE 4.0
     54#define PADDING_ABOVE_MIN_STATUS 4.0
     55#define PADDING_BETWEEN_TITLE_AND_MIN_STATUS 2.0
     56#define PADDING_BETWEEN_TITLE_AND_PROGRESS 1.0
     57#define PADDING_BETWEEN_PROGRESS_AND_BAR 2.0
     58#define PADDING_BETWEEN_TITLE_AND_BAR_MIN 3.0
     59#define PADDING_BETWEEN_BAR_AND_STATUS 2.0
     60
     61#define PIECES_TOTAL_PERCENT 0.6
    6262
    6363#define MAX_PIECES (18*18)
     
    101101        NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    102102        [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
    103    
    104         fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    105                                 [NSFont messageFontOfSize: 12.0f], NSFontAttributeName,
    106                                 paragraphStyle, NSParagraphStyleAttributeName, nil];
    107         fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    108                                 [NSFont messageFontOfSize: 9.0f], NSFontAttributeName,
    109                                 paragraphStyle, NSParagraphStyleAttributeName, nil];
     103       
     104        fTitleAttributes = [[NSMutableDictionary alloc] initWithCapacity: 3];
     105        [fTitleAttributes setObject: [NSFont messageFontOfSize: 12.0] forKey: NSFontAttributeName];
     106        [fTitleAttributes setObject: paragraphStyle forKey: NSParagraphStyleAttributeName];
     107       
     108        fStatusAttributes = [[NSMutableDictionary alloc] initWithCapacity: 3];
     109        [fStatusAttributes setObject: [NSFont messageFontOfSize: 9.0] forKey: NSFontAttributeName];
     110        [fStatusAttributes setObject: paragraphStyle forKey: NSParagraphStyleAttributeName];
     111       
    110112        [paragraphStyle release];
    111113       
    112         fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0f green: 0.4f blue: 0.8f alpha: 1.0f] retain];
    113         fBarBorderColor = [[NSColor colorWithCalibratedWhite: 0.0f alpha: 0.2f] retain];
     114        fBluePieceColor = [[NSColor colorWithCalibratedRed: 0.0 green: 0.4 blue: 0.8 alpha: 1.0] retain];
     115        fBarBorderColor = [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.2] retain];
    114116    }
    115117        return self;
     
    120122    const CGFloat imageSize = [fDefaults boolForKey: @"SmallView"] ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG;
    121123   
    122     NSRect result = bounds;
    123     result.origin.x += PADDING_HORIZONTAL;
    124     result.origin.y += floor((result.size.height - imageSize) * 0.5);
    125     result.size = NSMakeSize(imageSize, imageSize);
    126    
    127     return result;
     124    return NSMakeRect(NSMinX(bounds) + PADDING_HORIZONTAL, floor(NSMidY(bounds) - imageSize * 0.5),
     125                        imageSize, imageSize);
    128126}
    129127
     
    238236    {
    239237        controlOptions |= NSTrackingAssumeInside;
    240         [(TorrentTableView *)controlView setControlButtonHover: [[userInfo objectForKey: @"Row"] intValue]];
     238        [(TorrentTableView *)controlView setControlButtonHover: [[userInfo objectForKey: @"Row"] integerValue]];
    241239    }
    242240   
     
    255253    {
    256254        revealOptions |= NSTrackingAssumeInside;
    257         [(TorrentTableView *)controlView setRevealButtonHover: [[userInfo objectForKey: @"Row"] intValue]];
     255        [(TorrentTableView *)controlView setRevealButtonHover: [[userInfo objectForKey: @"Row"] integerValue]];
    258256    }
    259257   
     
    271269    {
    272270        actionOptions |= NSTrackingAssumeInside;
    273         [(TorrentTableView *)controlView setActionButtonHover: [[userInfo objectForKey: @"Row"] intValue]];
     271        [(TorrentTableView *)controlView setActionButtonHover: [[userInfo objectForKey: @"Row"] integerValue]];
    274272    }
    275273   
     
    309307   
    310308    //group coloring
    311     NSRect iconRect = [self iconRectForBounds: cellFrame];
    312    
    313     NSInteger groupValue = [torrent groupValue];
     309    const NSRect iconRect = [self iconRectForBounds: cellFrame];
     310   
     311    const NSInteger groupValue = [torrent groupValue];
    314312    if (groupValue != -1)
    315313    {
    316         NSRect groupRect = NSInsetRect(iconRect, -1.0f, -2.0f);
     314        NSRect groupRect = NSInsetRect(iconRect, -1.0, -2.0);
    317315        if (!minimal)
    318316        {
    319             groupRect.size.height -= 1.0f;
    320             groupRect.origin.y -= 1.0f;
    321         }
    322         const CGFloat radius = minimal ? 3.0f : 6.0f;
     317            groupRect.size.height -= 1.0;
     318            groupRect.origin.y -= 1.0;
     319        }
     320        const CGFloat radius = minimal ? 3.0 : 6.0;
    323321       
    324322        NSColor * groupColor = [[GroupsController groups] colorForIndex: groupValue],
    325                 * darkGroupColor = [groupColor blendedColorWithFraction: 0.2f ofColor: [NSColor whiteColor]];
     323                * darkGroupColor = [groupColor blendedColorWithFraction: 0.2 ofColor: [NSColor whiteColor]];
    326324       
    327325        //border
    328326        NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: groupRect xRadius: radius yRadius: radius];
    329327        [darkGroupColor set];
    330         [bp setLineWidth: 2.0f];
     328        [bp setLineWidth: 2.0];
    331329        [bp stroke];
    332330       
    333331        //inside
    334332        bp = [NSBezierPath bezierPathWithRoundedRect: groupRect xRadius: radius yRadius: radius];
    335         NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [groupColor blendedColorWithFraction: 0.7f
     333        NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: [groupColor blendedColorWithFraction: 0.7
    336334                                    ofColor: [NSColor whiteColor]] endingColor: darkGroupColor];
    337         [gradient drawInBezierPath: bp angle: 90.0f];
     335        [gradient drawInBezierPath: bp angle: 90.0];
    338336        [gradient release];
    339337    }
     
    390388        NSImage * priorityImage = [torrent priority] == TR_PRI_HIGH ? [NSImage imageNamed: @"PriorityHigh.png"]
    391389                                                                    : [NSImage imageNamed: @"PriorityLow.png"];
    392         priorityImage = [NSApp isOnSnowLeopardOrBetter] ? [priorityImage retain] : [priorityImage copy]; //take line out completely when 10.6-only
     390        //take line out completely when 10.6-only
     391        priorityImage = [NSApp isOnSnowLeopardOrBetter] ? [priorityImage retain] : [priorityImage copy];
    393392       
    394393        NSRect priorityRect = NSMakeRect(NSMaxX(titleRect) + PADDING_BETWEEN_TITLE_AND_PRIORITY,
    395                                 titleRect.origin.y - (PRIORITY_ICON_HEIGHT - titleRect.size.height) / 2.0,
    396                                 PRIORITY_ICON_WIDTH, PRIORITY_ICON_HEIGHT);
     394                                        NSMidY(titleRect) - PRIORITY_ICON_HEIGHT  * 0.5,
     395                                        PRIORITY_ICON_WIDTH, PRIORITY_ICON_HEIGHT);
    397396       
    398397        [self drawImage: priorityImage inRect: priorityRect];
     
    638637    {
    639638        result.size.width -= PRIORITY_ICON_WIDTH + PADDING_BETWEEN_TITLE_AND_PRIORITY;
    640         result.size.width = MIN(result.size.width, [string size].width); //only need to force it smaller for the priority icon
     639        result.size.width = MIN(NSWidth(result), [string size].width); //only need to force it smaller for the priority icon
    641640    }
    642641   
     
    693692    result.size.height = NORMAL_BUTTON_WIDTH;
    694693    result.size.width = NORMAL_BUTTON_WIDTH;
    695     result.origin.x = NSMaxX(bounds) - 2.0f * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
    696    
    697     result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f;
     694    result.origin.x = NSMaxX(bounds) - 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
     695   
     696    result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5;
    698697    if ([fDefaults boolForKey: @"SmallView"])
    699698        result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN;
     
    711710    result.origin.x = NSMaxX(bounds) - (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
    712711   
    713     result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f;
     712    result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5;
    714713    if ([fDefaults boolForKey: @"SmallView"])
    715714        result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN;
     
    722721- (NSRect) actionButtonRectForBounds: (NSRect) bounds
    723722{
    724     NSRect result = [self iconRectForBounds: bounds];
    725     if (![fDefaults boolForKey: @"SmallView"])
    726     {
    727         result.origin.x += (result.size.width - ACTION_BUTTON_WIDTH) * 0.5f;
    728         result.origin.y += (result.size.height - ACTION_BUTTON_WIDTH) * 0.5f;
    729         result.size.width = ACTION_BUTTON_WIDTH;
    730         result.size.height = ACTION_BUTTON_WIDTH;
    731     }
    732    
    733     return result;
     723    const NSRect iconRect = [self iconRectForBounds: bounds];
     724   
     725    //in minimal view the rect will be the icon rect, but avoid the extra defaults lookup with some cheap math
     726    return NSMakeRect(NSMidX(iconRect) - ACTION_BUTTON_WIDTH * 0.5, NSMidY(iconRect) - ACTION_BUTTON_WIDTH * 0.5,
     727                        ACTION_BUTTON_WIDTH, ACTION_BUTTON_WIDTH);
    734728}
    735729
  • trunk/macosx/TorrentTableView.m

    r9674 r9807  
    241241            continue;
    242242       
    243         NSDictionary * userInfo = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt: row] forKey: @"Row"];
     243        NSDictionary * userInfo = [NSDictionary dictionaryWithObject: [NSNumber numberWithUnsignedInteger: row] forKey: @"Row"];
    244244        TorrentCell * cell = (TorrentCell *)[self preparedCellAtColumn: -1 row: row];
    245245        [cell addTrackingAreasForView: self inRect: [self rectOfRow: row] withUserInfo: userInfo mouseLocation: mouseLocation];
Note: See TracChangeset for help on using the changeset viewer.