Changeset 2716


Ignore:
Timestamp:
Aug 11, 2007, 1:48:06 AM (15 years ago)
Author:
livings124
Message:

general code cleanup

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/TorrentCell.h

    r2715 r2716  
    3838}
    3939
    40 - (void) toggleMinimalStatus;
    41 
    4240- (NSRect) imageRectForBounds: (NSRect) bounds;
    4341- (NSRect) titleRectForBounds: (NSRect) bounds;
  • trunk/macosx/TorrentCell.m

    r2715 r2716  
    4747@interface TorrentCell (Private)
    4848
    49 #warning make some public
    5049- (NSImage *) simpleBar: (NSSize) barSize;
    5150- (NSImage *) advancedBar: (NSSize) barSize;
     
    117116}
    118117
    119 #warning why!?!?!??!!?!
    120 - (void) toggleMinimalStatus
    121 {
    122     [fDefaults setBool: ![fDefaults boolForKey: @"SmallStatusRegular"] forKey: @"SmallStatusRegular"];
    123 }
    124 
    125118- (NSRect) imageRectForBounds: (NSRect) bounds
    126119{
     
    255248        [[self attributedStatusWithColor: statusColor] drawInRect: statusRect];
    256249    }
    257    
    258     /*BOOL highlighted = [self isHighlighted] && [[self highlightColorWithFrame: cellFrame inView: view]
    259                                                         isEqual: [NSColor alternateSelectedControlColor]];
    260    
    261     [nameAttributes setObject: highlighted ? [NSColor whiteColor] : [NSColor controlTextColor]
    262                         forKey: NSForegroundColorAttributeName];
    263     [statusAttributes setObject: highlighted ? [NSColor whiteColor] : [NSColor darkGrayColor]
    264                         forKey: NSForegroundColorAttributeName];
    265    
    266     NSPoint pen = cellFrame.origin;
    267     const float LINE_PADDING = 2.0, EXTRA_NAME_SHIFT = 1.0; //standard padding is defined in TorrentCell.h
    268    
    269     Torrent * torrent = [self representedObject];
    270    
    271     if (![fDefaults boolForKey: @"SmallView"]) //regular size
    272     {
    273         //icon
    274         NSImage * icon = [torrent iconFlipped];
    275         NSSize iconSize = [icon size];
    276        
    277         pen.x += PADDING;
    278         pen.y += (cellFrame.size.height - (iconSize.height + ACTION_BUTTON_HEIGHT)) * 0.5;
    279        
    280         [icon drawAtPoint: pen fromRect: NSMakeRect(0, 0, iconSize.width, iconSize.height)
    281                 operation: NSCompositeSourceOver fraction: 1.0];
    282        
    283         //error badge
    284         if ([torrent isError])
    285         {
    286             if (!fErrorImage)
    287             {
    288                 fErrorImage = [[NSImage imageNamed: @"Error.png"] copy];
    289                 [fErrorImage setFlipped: YES];
    290             }
    291            
    292             NSSize errorIconSize = [fErrorImage size];
    293             [fErrorImage drawAtPoint: NSMakePoint(pen.x + iconSize.width - errorIconSize.width,
    294                                                     pen.y + iconSize.height  - errorIconSize.height)
    295                 fromRect: NSMakeRect(0, 0, errorIconSize.width, errorIconSize.height)
    296                 operation: NSCompositeSourceOver fraction: 1.0];
    297         }
    298 
    299         float mainWidth = cellFrame.size.width - iconSize.width - 3.0 * PADDING - EXTRA_NAME_SHIFT;
    300 
    301         //name string
    302         pen.x += iconSize.width + PADDING + EXTRA_NAME_SHIFT;
    303         pen.y = cellFrame.origin.y + PADDING;
    304        
    305         NSString * nameString = [torrent name];
    306         NSSize nameSize = [nameString sizeWithAttributes: nameAttributes];
    307         [nameString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, nameSize.height) withAttributes: nameAttributes];
    308        
    309         //progress string
    310         pen.y += nameSize.height + LINE_PADDING - 1.0;
    311        
    312         NSString * progressString = [torrent progressString];
    313         NSSize progressSize = [progressString sizeWithAttributes: statusAttributes];
    314         [progressString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, progressSize.height) withAttributes: statusAttributes];
    315 
    316         //progress bar
    317         pen.x -= EXTRA_NAME_SHIFT;
    318         pen.y += progressSize.height + LINE_PADDING + BAR_HEIGHT;
    319        
    320         float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
    321        
    322         if ([fDefaults boolForKey: @"UseAdvancedBar"])
    323             [self buildAdvancedBar: barWidth point: pen];
    324         else
    325             [self buildSimpleBar: barWidth point: pen];
    326 
    327         //status string
    328         pen.x += EXTRA_NAME_SHIFT;
    329         pen.y += LINE_PADDING;
    330        
    331         NSString * statusString = [torrent statusString];
    332         NSSize statusSize = [statusString sizeWithAttributes: statusAttributes];
    333         [statusString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, statusSize.height) withAttributes: statusAttributes];
    334     }
    335     else //small size
    336     {
    337         //icon
    338         NSImage * icon;
    339         if ([torrent isError])
    340         {
    341             if (!fErrorImage)
    342             {
    343                 fErrorImage = [[NSImage imageNamed: @"Error.png"] copy];
    344                 [fErrorImage setFlipped: YES];
    345             }
    346             icon = fErrorImage;
    347         }
    348         else
    349             icon = [torrent iconSmall];
    350         NSSize iconSize = [icon size];
    351        
    352         pen.x += PADDING;
    353         pen.y += (cellFrame.size.height - iconSize.height) * 0.5;
    354        
    355         [icon drawAtPoint: pen fromRect: NSMakeRect(0, 0, iconSize.width, iconSize.height)
    356                 operation: NSCompositeSourceOver fraction: 1.0];
    357 
    358         //name and status string
    359         float mainWidth = cellFrame.size.width - iconSize.width - 3.0 * PADDING - EXTRA_NAME_SHIFT;
    360                      
    361         //place name string
    362         pen.x += iconSize.width + PADDING + EXTRA_NAME_SHIFT;
    363         pen.y = cellFrame.origin.y + LINE_PADDING;
    364 
    365         NSString * nameString = [torrent name];
    366         NSSize nameSize = [nameString sizeWithAttributes: nameAttributes];
    367        
    368         NSString * statusString = ![fDefaults boolForKey: @"SmallStatusRegular"] && [torrent isActive]
    369                                     ? [torrent remainingTimeString] : [torrent shortStatusString];
    370         NSSize statusSize = [statusString sizeWithAttributes: statusAttributes];
    371        
    372         [nameString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth - statusSize.width - 2.0 * LINE_PADDING, nameSize.height)
    373                         withAttributes: nameAttributes];
    374        
    375         //place status string
    376         pen.x = NSMaxX(cellFrame) - PADDING - statusSize.width;
    377         pen.y += (nameSize.height - statusSize.height) * 0.5;
    378        
    379         [statusString drawInRect: NSMakeRect(pen.x, pen.y, statusSize.width, statusSize.height)
    380                         withAttributes: statusAttributes];
    381        
    382         //progress bar
    383         pen.x = cellFrame.origin.x + iconSize.width + 2.0 * PADDING;
    384         pen.y = cellFrame.origin.y + nameSize.height + LINE_PADDING + PADDING + BAR_HEIGHT;
    385        
    386         float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
    387        
    388         if ([fDefaults boolForKey: @"UseAdvancedBar"])
    389             [self buildAdvancedBar: barWidth point: pen];
    390         else
    391             [self buildSimpleBar: barWidth point: pen];
    392     }*/
    393250}
    394251
  • trunk/macosx/TorrentTableView.m

    r2708 r2716  
    118118    if ([self pointInActionRect: fClickPoint])
    119119    {
    120        
    121120        [self setNeedsDisplayInRect: [self rectOfRow: [self rowAtPoint: fClickPoint]]]; //ensure button is pushed down
    122121        [self displayTorrentMenuForEvent: event];
     
    136135            if ([self pointInMinimalStatusRect: fClickPoint])
    137136            {
    138                 [(TorrentCell *)[[self tableColumnWithIdentifier: @"Torrent"] dataCell] toggleMinimalStatus];
     137                [fDefaults setBool: ![fDefaults boolForKey: @"SmallStatusRegular"] forKey: @"SmallStatusRegular"];
    139138                fClickPoint = NSZeroPoint;
    140139            }
     
    143142        }
    144143    }
    145 
     144   
     145    #warning make more efficient
    146146    [self display];
    147147}
Note: See TracChangeset for help on using the changeset viewer.