Changeset 10398


Ignore:
Timestamp:
Mar 20, 2010, 3:27:17 AM (12 years ago)
Author:
livings124
Message:

first attempt at a single-row, more compact Compact (Minimal) View

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r10272 r10398  
    132132
    133133#define ROW_HEIGHT_REGULAR      62.0
    134 #define ROW_HEIGHT_SMALL        38.0
     134#define ROW_HEIGHT_SMALL        22.0
    135135#define WINDOW_REGULAR_WIDTH    468.0
    136136
  • trunk/macosx/ProgressGradients.h

    r9844 r10398  
    2525@interface ProgressGradients : NSObject
    2626
    27 + (NSGradient *) progressGradientForRed: (CGFloat) redComponent green: (CGFloat) greenComponent blue: (CGFloat) blueComponent;
    28 
    2927+ (NSGradient *) progressWhiteGradient;
    3028+ (NSGradient *) progressGrayGradient;
  • trunk/macosx/ProgressGradients.m

    r9844 r10398  
    2525#import "ProgressGradients.h"
    2626
    27 @implementation ProgressGradients
     27@implementation ProgressGradients (Private)
    2828
    2929+ (NSGradient *) progressGradientForRed: (CGFloat) redComponent green: (CGFloat) greenComponent blue: (CGFloat) blueComponent
    3030{
    31     NSColor * baseColor = [NSColor colorWithCalibratedRed: redComponent green: greenComponent blue: blueComponent alpha: 1.0];
     31    const CGFloat alpha = [[NSUserDefaults standardUserDefaults] boolForKey: @"SmallView"] ? 0.075 : 1.0;
     32   
     33    NSColor * baseColor = [NSColor colorWithCalibratedRed: redComponent green: greenComponent blue: blueComponent alpha: alpha];
    3234   
    3335    NSColor * color2 = [NSColor colorWithCalibratedRed: redComponent * 0.95 green: greenComponent * 0.95 blue: blueComponent * 0.95
    34                         alpha: 1.0];
     36                        alpha: alpha];
    3537   
    3638    NSColor * color3 = [NSColor colorWithCalibratedRed: redComponent * 0.85 green: greenComponent * 0.85 blue: blueComponent * 0.85
    37                         alpha: 1.0];
     39                        alpha: alpha];
    3840   
    3941    NSGradient * progressGradient = [[NSGradient alloc] initWithColorsAndLocations: baseColor, 0.0, color2, 0.5, color3, 0.5,
     
    4244}
    4345
    44 NSGradient * fProgressWhiteGradient = nil;
     46@end
     47
     48@implementation ProgressGradients
     49
    4550+ (NSGradient *) progressWhiteGradient
    4651{
    47     if (!fProgressWhiteGradient)
    48         fProgressWhiteGradient = [[[self class] progressGradientForRed: 0.95 green: 0.95 blue: 0.95] retain];
    49     return fProgressWhiteGradient;
     52    return [[self class] progressGradientForRed: 0.95 green: 0.95 blue: 0.95];
    5053}
    5154
    52 NSGradient * fProgressGrayGradient = nil;
    5355+ (NSGradient *) progressGrayGradient
    5456{
    55     if (!fProgressGrayGradient)
    56         fProgressGrayGradient = [[[self class] progressGradientForRed: 0.7 green: 0.7 blue: 0.7] retain];
    57     return fProgressGrayGradient;
     57    return [[self class] progressGradientForRed: 0.7 green: 0.7 blue: 0.7];
    5858}
    5959
    60 NSGradient * fProgressLightGrayGradient = nil;
    6160+ (NSGradient *) progressLightGrayGradient
    6261{
    63     if (!fProgressLightGrayGradient)
    64         fProgressLightGrayGradient = [[[self class] progressGradientForRed: 0.87 green: 0.87 blue: 0.87] retain];
    65     return fProgressLightGrayGradient;
     62    return [[self class] progressGradientForRed: 0.87 green: 0.87 blue: 0.87];
    6663}
    6764
    68 NSGradient * fProgressBlueGradient = nil;
    6965+ (NSGradient *) progressBlueGradient
    7066{
    71     if (!fProgressBlueGradient)
    72         fProgressBlueGradient = [[[self class] progressGradientForRed: 0.35 green: 0.67 blue: 0.98] retain];
    73     return fProgressBlueGradient;
     67    return [[self class] progressGradientForRed: 0.35 green: 0.67 blue: 0.98];
    7468}
    7569
    76 NSGradient * fProgressDarkBlueGradient = nil;
    7770+ (NSGradient *) progressDarkBlueGradient
    7871{
    79     if (!fProgressDarkBlueGradient)
    80         fProgressDarkBlueGradient = [[[self class] progressGradientForRed: 0.616 green: 0.722 blue: 0.776] retain];
    81     return fProgressDarkBlueGradient;
     72    return [[self class] progressGradientForRed: 0.616 green: 0.722 blue: 0.776];
    8273}
    8374
    84 NSGradient * fProgressGreenGradient = nil;
    8575+ (NSGradient *) progressGreenGradient
    8676{
    87     if (!fProgressGreenGradient)
    88         fProgressGreenGradient = [[[self class] progressGradientForRed: 0.44 green: 0.89 blue: 0.40] retain];
    89     return fProgressGreenGradient;
     77    return [[self class] progressGradientForRed: 0.44 green: 0.89 blue: 0.40];
    9078}
    9179
    92 NSGradient * fProgressLightGreenGradient = nil;
    9380+ (NSGradient *) progressLightGreenGradient
    9481{
    95     if (!fProgressLightGreenGradient)
    96         fProgressLightGreenGradient = [[[self class] progressGradientForRed: 0.62 green: 0.99 blue: 0.58] retain];
    97     return fProgressLightGreenGradient;
     82    return [[self class] progressGradientForRed: 0.62 green: 0.99 blue: 0.58];
    9883}
    9984
    100 NSGradient * fProgressDarkGreenGradient = nil;
    10185+ (NSGradient *) progressDarkGreenGradient
    10286{
    103     if (!fProgressDarkGreenGradient)
    104         fProgressDarkGreenGradient = [[[self class] progressGradientForRed: 0.627 green: 0.714 blue: 0.639] retain];
    105     return fProgressDarkGreenGradient;
     87    return [[self class] progressGradientForRed: 0.627 green: 0.714 blue: 0.639];
    10688}
    10789
    108 NSGradient * fProgressRedGradient = nil;
    10990+ (NSGradient *) progressRedGradient
    11091{
    111     if (!fProgressRedGradient)
    112         fProgressRedGradient = [[[self class] progressGradientForRed: 0.902 green: 0.439 blue: 0.451] retain];
    113     return fProgressRedGradient;
     92    return [[self class] progressGradientForRed: 0.902 green: 0.439 blue: 0.451];
    11493}
    11594
    116 NSGradient * fProgressYellowGradient = nil;
    11795+ (NSGradient *) progressYellowGradient
    11896{
    119     if (!fProgressYellowGradient)
    120         fProgressYellowGradient = [[[self class] progressGradientForRed: 0.933 green: 0.890 blue: 0.243] retain];
    121     return fProgressYellowGradient;
     97    return [[self class] progressGradientForRed: 0.933 green: 0.890 blue: 0.243];
    12298}
    12399
  • trunk/macosx/TorrentCell.h

    r9844 r10398  
    3030   
    3131    BOOL fTracking, fMouseDownControlButton, fMouseDownRevealButton, fMouseDownActionButton,
    32             fHoverControl, fHoverReveal, fHoverAction;
     32            fHover, fHoverControl, fHoverReveal, fHoverAction;
    3333   
    3434    NSColor * fBarBorderColor, * fBluePieceColor;
     
    3939- (void) addTrackingAreasForView: (NSView *) controlView inRect: (NSRect) cellFrame withUserInfo: (NSDictionary *) userInfo
    4040            mouseLocation: (NSPoint) mouseLocation;
     41- (void) setHover: (BOOL) hover;
    4142- (void) setControlHover: (BOOL) hover;
    4243- (void) setRevealHover: (BOOL) hover;
  • trunk/macosx/TorrentCell.m

    r10318 r10398  
    113113       
    114114        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];
     115        fBarBorderColor = [[NSColor colorWithCalibratedWhite: 0.0 alpha: 0.2 * 0.075] retain];
    116116    }
    117117        return self;
     
    156156    const BOOL checkReveal = NSMouseInRect(point, revealRect, [controlView isFlipped]);
    157157   
    158     [(TorrentTableView *)controlView removeButtonTrackingAreas];
     158    [(TorrentTableView *)controlView removeTrackingAreas];
    159159   
    160160    while ([event type] != NSLeftMouseUp)
     
    230230    NSTrackingAreaOptions options = NSTrackingEnabledDuringMouseDrag | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways;
    231231   
     232    //whole row
     233    NSTrackingAreaOptions rowOptions = options;
     234    if (NSMouseInRect(mouseLocation, cellFrame, [controlView isFlipped]))
     235    {
     236        rowOptions |= NSTrackingAssumeInside;
     237        [(TorrentTableView *)controlView setRowHover: [[userInfo objectForKey: @"Row"] integerValue]];
     238    }
     239   
     240    NSMutableDictionary * rowInfo = [userInfo mutableCopy];
     241    [rowInfo setObject: @"Row" forKey: @"Type"];
     242    NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: cellFrame options: rowOptions owner: controlView userInfo: rowInfo];
     243    [controlView addTrackingArea: area];
     244    [rowInfo release];
     245    [area release];
     246   
    232247    //control button
    233248    NSRect controlButtonRect = [self controlButtonRectForBounds: cellFrame];
     
    241256    NSMutableDictionary * controlInfo = [userInfo mutableCopy];
    242257    [controlInfo setObject: @"Control" forKey: @"Type"];
    243     NSTrackingArea * area = [[NSTrackingArea alloc] initWithRect: controlButtonRect options: controlOptions owner: controlView
     258    area = [[NSTrackingArea alloc] initWithRect: controlButtonRect options: controlOptions owner: controlView
    244259                                userInfo: controlInfo];
    245260    [controlView addTrackingArea: area];
     
    280295}
    281296
     297- (void) setHover: (BOOL) hover
     298{
     299    fHover = hover;
     300}
     301
    282302- (void) setControlHover: (BOOL) hover
    283303{
     
    355375    }
    356376   
     377    //bar
     378    [self drawBar: [self barRectForBounds: cellFrame]];
     379   
    357380    //text color
    358381    NSColor * titleColor, * statusColor;
     
    370393    //minimal status
    371394    NSRect minimalStatusRect;
    372     if (minimal)
     395    if (minimal && !fHover)
    373396    {
    374397        NSAttributedString * minimalString = [self attributedStatusString: [self minimalStatusString]];
     
    408431    }
    409432   
    410     //bar
    411     [self drawBar: [self barRectForBounds: cellFrame]];
    412    
    413     //control button
    414     NSString * controlImageSuffix;
    415     if (fMouseDownControlButton)
    416         controlImageSuffix = @"On.png";
    417     else if (!fTracking && fHoverControl)
    418         controlImageSuffix = @"Hover.png";
    419     else
    420         controlImageSuffix = @"Off.png";
    421    
    422     NSImage * controlImage;
    423     if ([torrent isActive])
    424         controlImage = [NSImage imageNamed: [@"Pause" stringByAppendingString: controlImageSuffix]];
    425     else
    426     {
    427         if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
    428             controlImage = [NSImage imageNamed: [@"ResumeNoWait" stringByAppendingString: controlImageSuffix]];
    429         else if ([torrent waitingToStart])
     433    if (!minimal || fHover)
     434    {
     435        //control button
     436        NSString * controlImageSuffix;
     437        if (fMouseDownControlButton)
     438            controlImageSuffix = @"On.png";
     439        else if (!fTracking && fHoverControl)
     440            controlImageSuffix = @"Hover.png";
     441        else
     442            controlImageSuffix = @"Off.png";
     443       
     444        NSImage * controlImage;
     445        if ([torrent isActive])
    430446            controlImage = [NSImage imageNamed: [@"Pause" stringByAppendingString: controlImageSuffix]];
    431447        else
    432             controlImage = [NSImage imageNamed: [@"Resume" stringByAppendingString: controlImageSuffix]];
    433     }
    434    
    435     [self drawImage: controlImage inRect: [self controlButtonRectForBounds: cellFrame]];
    436    
    437     //reveal button
    438     NSString * revealImageString;
    439     if (fMouseDownRevealButton)
    440         revealImageString = @"RevealOn.png";
    441     else if (!fTracking && fHoverReveal)
    442         revealImageString = @"RevealHover.png";
    443     else
    444         revealImageString = @"RevealOff.png";
    445    
    446     NSImage * revealImage = [NSImage imageNamed: revealImageString];
    447     [self drawImage: revealImage inRect: [self revealButtonRectForBounds: cellFrame]];
    448    
    449     //action button
    450     NSString * actionImageString;
    451     if (fMouseDownActionButton)
    452         actionImageString = @"ActionOn.png";
    453     else if (!fTracking && fHoverAction)
    454         actionImageString = @"ActionHover.png";
    455     else
    456         actionImageString = nil;
    457    
    458     if (actionImageString)
    459     {
    460         NSImage * actionImage = [NSImage imageNamed: actionImageString];
    461         [self drawImage: actionImage inRect: [self actionButtonRectForBounds: cellFrame]];
     448        {
     449            if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
     450                controlImage = [NSImage imageNamed: [@"ResumeNoWait" stringByAppendingString: controlImageSuffix]];
     451            else if ([torrent waitingToStart])
     452                controlImage = [NSImage imageNamed: [@"Pause" stringByAppendingString: controlImageSuffix]];
     453            else
     454                controlImage = [NSImage imageNamed: [@"Resume" stringByAppendingString: controlImageSuffix]];
     455        }
     456       
     457        [self drawImage: controlImage inRect: [self controlButtonRectForBounds: cellFrame]];
     458       
     459        //reveal button
     460        NSString * revealImageString;
     461        if (fMouseDownRevealButton)
     462            revealImageString = @"RevealOn.png";
     463        else if (!fTracking && fHoverReveal)
     464            revealImageString = @"RevealHover.png";
     465        else
     466            revealImageString = @"RevealOff.png";
     467       
     468        NSImage * revealImage = [NSImage imageNamed: revealImageString];
     469        [self drawImage: revealImage inRect: [self revealButtonRectForBounds: cellFrame]];
     470       
     471        //action button
     472        NSString * actionImageString;
     473        if (fMouseDownActionButton)
     474            actionImageString = @"ActionOn.png";
     475        else if (!fTracking && fHoverAction)
     476            actionImageString = @"ActionHover.png";
     477        else
     478            actionImageString = nil;
     479       
     480        if (actionImageString)
     481        {
     482            NSImage * actionImage = [NSImage imageNamed: actionImageString];
     483            [self drawImage: actionImage inRect: [self actionButtonRectForBounds: cellFrame]];
     484        }
    462485    }
    463486   
     
    493516    }
    494517   
    495     [fBarBorderColor set];
    496     [NSBezierPath strokeRect: NSInsetRect(barRect, 0.5, 0.5)];
     518    if ([fDefaults boolForKey: @"SmallView"])
     519    {
     520        [fBarBorderColor set];
     521        [NSBezierPath strokeRect: NSInsetRect(barRect, 0.5, 0.5)];
     522    }
    497523}
    498524
     
    684710    result.origin.x = NSMinX(bounds) + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_BAR;
    685711   
    686     result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE;
     712    result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE;
    687713    if (minimal)
    688         result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN;
     714#warning make const
     715        result.origin.y += 2.0;
    689716    else
    690         result.origin.y += PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
    691    
    692     result.size.width = floor(NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL - 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH));
     717        result.origin.y += HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
     718   
     719    result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
     720    if (!minimal)
     721        result.size.width -= 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
     722    result.size.width = floor(NSWidth(result));
    693723   
    694724    return result;
     
    702732    result.origin.x = NSMaxX(bounds) - 2.0 * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
    703733   
    704     result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5;
    705     if ([fDefaults boolForKey: @"SmallView"])
    706         result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN;
    707     else
    708         result.origin.y += PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
     734    result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE;
     735    if (![fDefaults boolForKey: @"SmallView"])
     736        result.origin.y += HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5
     737                            + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
    709738   
    710739    return result;
     
    718747    result.origin.x = NSMaxX(bounds) - (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH);
    719748   
    720     result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5;
    721     if ([fDefaults boolForKey: @"SmallView"])
    722         result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN;
    723     else
    724         result.origin.y += PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
     749    result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE;
     750    if (![fDefaults boolForKey: @"SmallView"])
     751        result.origin.y += HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5
     752                            + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS + PADDING_BETWEEN_PROGRESS_AND_BAR;
    725753   
    726754    return result;
  • trunk/macosx/TorrentTableView.h

    r9844 r10398  
    4444    IBOutlet NSMenu * fContextRow, * fContextNoRow;
    4545   
    46     NSInteger fMouseControlRow, fMouseRevealRow, fMouseActionRow, fActionPushedRow;
     46    NSInteger fMouseRow, fMouseControlRow, fMouseRevealRow, fMouseActionRow, fActionPushedRow;
    4747    NSArray * fSelectedValues;
    4848   
     
    6060- (void) saveCollapsedGroups;
    6161
    62 - (void) removeButtonTrackingAreas;
     62- (void) removeTrackingAreas;
     63- (void) setRowHover: (NSInteger) row;
    6364- (void) setControlButtonHover: (NSInteger) row;
    6465- (void) setRevealButtonHover: (NSInteger) row;
  • trunk/macosx/TorrentTableView.m

    r10206 r10398  
    6767            fCollapsedGroups = [[NSMutableIndexSet alloc] init];
    6868       
     69        fMouseRow = -1;
    6970        fMouseControlRow = -1;
    7071        fMouseRevealRow = -1;
     
    153154       
    154155        const NSInteger row = [self rowForItem: item];
     156        [cell setHover: row == fMouseRow];
    155157        [cell setControlHover: row == fMouseControlRow];
    156158        [cell setRevealHover: row == fMouseRevealRow];
     
    227229{
    228230    [super updateTrackingAreas];
    229     [self removeButtonTrackingAreas];
     231    [self removeTrackingAreas];
    230232   
    231233    NSRange rows = [self rowsInRect: [self visibleRect]];
     
    245247}
    246248
    247 - (void) removeButtonTrackingAreas
    248 {
     249- (void) removeTrackingAreas
     250{
     251    fMouseRow = -1;
    249252    fMouseControlRow = -1;
    250253    fMouseRevealRow = -1;
     
    256259            [self removeTrackingArea: area];
    257260    }
     261}
     262
     263- (void) setRowHover: (NSInteger) row
     264{
     265    fMouseRow = row;
     266    if (row >= 0 && [fDefaults boolForKey: @"SmallView"])
     267        [self setNeedsDisplayInRect: [self rectOfRow: row]];
    258268}
    259269
     
    292302        else if ([type isEqualToString: @"Control"])
    293303            fMouseControlRow = rowVal;
     304        else if ([type isEqualToString: @"Reveal"])
     305            fMouseRevealRow = rowVal;
    294306        else
    295             fMouseRevealRow = rowVal;
     307        {
     308            fMouseRow = rowVal;
     309            if (![fDefaults boolForKey: @"SmallView"])
     310                return;
     311        }
    296312       
    297313        [self setNeedsDisplayInRect: [self rectOfRow: rowVal]];
     
    311327        else if ([type isEqualToString: @"Control"])
    312328            fMouseControlRow = -1;
     329        else if ([type isEqualToString: @"Reveal"])
     330            fMouseRevealRow = -1;
    313331        else
    314             fMouseRevealRow = -1;
     332        {
     333            fMouseRow = -1;
     334            if (![fDefaults boolForKey: @"SmallView"])
     335                return;
     336        }
    315337       
    316338        [self setNeedsDisplayInRect: [self rectOfRow: [row integerValue]]];
Note: See TracChangeset for help on using the changeset viewer.