Changeset 1398


Ignore:
Timestamp:
Jan 18, 2007, 10:00:24 PM (15 years ago)
Author:
livings124
Message:

file table rows for files are now larger with the size displayed under it

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileBrowserCell.m

    r1394 r1398  
    1313{
    1414    [image setFlipped: YES];
     15    [image setScalesWhenResized: YES];
    1516    [super setImage: image];
    1617}
     
    1920{
    2021    //image
    21     NSImage * icon = [self image];
    22     NSSize iconSize = [icon size];
    23     NSRect imageRect = NSMakeRect(cellFrame.origin.x + 2.0 * SPACE, cellFrame.origin.y, iconSize.width, iconSize.height);
     22    float imageHeight = cellFrame.size.height - 2.0;
    2423   
    25     [icon drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
     24    NSImage * image = [self image];
     25    [image setSize: NSMakeSize(imageHeight, imageHeight)];
     26    NSRect imageRect = NSMakeRect(cellFrame.origin.x + 2.0 * SPACE,
     27                                    cellFrame.origin.y + (cellFrame.size.height - imageHeight) / 2.0,
     28                                    imageHeight, imageHeight);
     29   
     30    [image drawInRect: imageRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
    2631   
    2732    //text
    28     NSRect textRect = NSMakeRect(NSMaxX(imageRect) + SPACE, cellFrame.origin.y,
    29                                     cellFrame.size.width - 4.0 * SPACE, cellFrame.size.height);
     33    NSArray * strings = [[self stringValue] componentsSeparatedByString: @"\n"];
    3034   
    31     if ([self isHighlighted] && [[self highlightColorWithFrame: cellFrame inView: controlView]
    32                                     isEqual: [NSColor alternateSelectedControlColor]])
     35    NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
     36    [paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
     37   
     38    BOOL highlighted = [self isHighlighted] && [[self highlightColorWithFrame: cellFrame inView: controlView]
     39                                    isEqual: [NSColor alternateSelectedControlColor]];
     40    NSDictionary * nameAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
     41                    highlighted ? [NSColor whiteColor] : [NSColor controlTextColor], NSForegroundColorAttributeName,
     42                    [NSFont messageFontOfSize: 12.0], NSFontAttributeName,
     43                    paragraphStyle, NSParagraphStyleAttributeName, nil];
     44   
     45    float textHeight = [(NSTableView *)controlView rowHeight];
     46    NSRect textRect = NSMakeRect(NSMaxX(imageRect) + SPACE, cellFrame.origin.y + 2.0,
     47                                    NSMaxX(cellFrame) - NSMaxX(imageRect) - 2.0 * SPACE, textHeight);
     48   
     49    NSAttributedString * text = [[NSAttributedString alloc] initWithString: [strings objectAtIndex: 0]
     50                                                                attributes: nameAttributes];
     51    [text drawInRect: textRect];
     52    [text release];
     53   
     54    //bottomText
     55    if ([strings count] > 1)
    3356    {
    34         NSMutableAttributedString * text = [[self attributedStringValue] mutableCopy];
    35         NSDictionary * attributes = [[NSDictionary alloc] initWithObjectsAndKeys:
    36                                         [NSColor whiteColor], NSForegroundColorAttributeName, nil];
    37         [text addAttributes: attributes range: NSMakeRange(0, [text length])];
    38         [text drawInRect: textRect];
     57        NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
     58                    highlighted ? [NSColor whiteColor] : [NSColor darkGrayColor], NSForegroundColorAttributeName,
     59                    [NSFont messageFontOfSize: 9.0], NSFontAttributeName,
     60                    paragraphStyle, NSParagraphStyleAttributeName, nil];
    3961       
    40         [attributes release];
    41         [text release];
     62        NSRect bottomTextRect = textRect;
     63        bottomTextRect.origin.y += textHeight;
     64        bottomTextRect.size.height = cellFrame.size.height - textHeight;
     65       
     66        NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString: [strings objectAtIndex: 1]
     67                                                                                        attributes: statusAttributes];
     68       
     69        [bottomText drawInRect: bottomTextRect];
     70        [bottomText release];
     71       
     72        [statusAttributes release];
    4273    }
    43     else
    44         [[self attributedStringValue] drawInRect: textRect];
    45        
     74   
     75    [paragraphStyle release];
     76    [nameAttributes release];
    4677}
    4778
  • trunk/macosx/InfoWindowController.m

    r1397 r1398  
    677677            byItem: (id) item
    678678{
    679     if ([[tableColumn identifier] isEqualToString: @"Size"])
    680         return ![[item objectForKey: @"IsFolder"] boolValue]
    681                 ? [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]] : @"";
    682     else if ([[tableColumn identifier] isEqualToString: @"Check"])
     679    if ([[tableColumn identifier] isEqualToString: @"Check"])
    683680        return [item objectForKey: @"Check"];
    684681    else
    685         return [item objectForKey: @"Name"];
     682    {
     683        if ([[item objectForKey: @"IsFolder"] boolValue])
     684            return [item objectForKey: @"Name"];
     685        else
     686            return [NSString stringWithFormat: @"%@\n%@", [item objectForKey: @"Name"],
     687                        [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]];
     688    }
    686689}
    687690
     
    753756        NSImage * icon = [[NSWorkspace sharedWorkspace] iconForFileType: ![[item objectForKey: @"IsFolder"] boolValue]
    754757                            ? [[item objectForKey: @"Name"] pathExtension] : NSFileTypeForHFSTypeCode('fldr')];
    755         [icon setScalesWhenResized: YES];
    756         [icon setSize: NSMakeSize(16.0, 16.0)];
    757758        [cell setImage: icon];
    758759    }
     
    769770{
    770771    NSString * ident = [tableColumn identifier];
    771     if ([ident isEqualToString: @"Size"])
     772    #warning change
     773    /*if ([ident isEqualToString: @"Size"])
    772774        return ![[item objectForKey: @"IsFolder"] boolValue]
    773775                    ? [[[item objectForKey: @"Size"] stringValue] stringByAppendingString: NSLocalizedString(@" bytes",
    774776                            "Inspector -> Files tab -> table row tooltip")] : nil;
    775     else if ([ident isEqualToString: @"Name"])
     777    else*/ if ([ident isEqualToString: @"Name"])
    776778        return [[[fTorrents objectAtIndex: 0] downloadFolder] stringByAppendingPathComponent: [item objectForKey: @"Path"]];
    777779    else
    778780        return nil;
     781}
     782
     783- (float) outlineView: (NSOutlineView *) outlineView heightOfRowByItem: (id) item
     784{
     785    float height = [outlineView rowHeight];
     786    if (![[item objectForKey: @"IsFolder"] boolValue])
     787        height = 34.0;
     788    return height;
    779789}
    780790
Note: See TracChangeset for help on using the changeset viewer.