Changeset 4058


Ignore:
Timestamp:
Dec 4, 2007, 6:03:38 AM (15 years ago)
Author:
livings124
Message:

clean up icon memory management for the window drag overlay - pointed out by Stick Men on the forum

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/DragOverlayView.h

    r3083 r4058  
    2727@interface DragOverlayView : NSView
    2828{
    29     NSImage * fBadge, * fBackBadge, * fAppIcon;
     29    NSImage * fBadge, * fBackBadge;
    3030   
    3131    NSDictionary * fMainLineAttributes, * fSubLineAttributes;
  • trunk/macosx/DragOverlayView.m

    r3394 r4058  
    2727
    2828#define PADDING 10.0
     29#define ICON_WIDTH 64.0
    2930
    3031@implementation DragOverlayView
     
    7778{
    7879    [fBackBadge release];
    79    
    8080    [fBadge release];
    81     [fAppIcon release];
    8281   
    8382    [fMainLineAttributes release];
     
    9392    NSSize badgeSize = [fBadge size];
    9493   
    95     //get icon
    96     NSSize iconSize = NSMakeSize(64.0, 64.0);
    97     if (!icon)
    98     {
    99         if (!fAppIcon)
    100         {
    101             fAppIcon = [[NSImage imageNamed: @"TransmissionDocument.icns"] copy];
    102             [fAppIcon setScalesWhenResized: YES];
    103             [fAppIcon setSize: iconSize];
    104         }
    105         icon = [fAppIcon retain];
    106     }
    107     else
    108     {
    109         icon = [icon copy];
    110         [icon setScalesWhenResized: YES];
    111         [icon setSize: iconSize];
    112     }
    113    
     94    //place icon
    11495    [fBadge lockFocus];
    115    
    116     //place icon
    117     [icon compositeToPoint: NSMakePoint(PADDING, (badgeSize.height - iconSize.height) * 0.5)
    118                 operation: NSCompositeSourceOver];
    119     [icon release];
     96    const float WIDTH = 64.0;
     97    [icon drawInRect: NSMakeRect(PADDING, (badgeSize.height - ICON_WIDTH) * 0.5, ICON_WIDTH, ICON_WIDTH) fromRect: NSZeroRect
     98            operation: NSCompositeSourceOver fraction: 1.0];
    12099   
    121100    //place main text
     
    123102    NSSize subLineSize = [subLine sizeWithAttributes: fSubLineAttributes];
    124103   
    125     NSRect lineRect = NSMakeRect(PADDING + iconSize.width + 5.0,
     104    NSRect lineRect = NSMakeRect(PADDING + ICON_WIDTH + 5.0,
    126105                        (badgeSize.height + (subLineSize.height + 2.0 - mainLineSize.height)) * 0.5,
    127                         badgeSize.width - (PADDING + iconSize.width + 2.0) - PADDING, mainLineSize.height);
     106                        badgeSize.width - (PADDING + ICON_WIDTH + 2.0) - PADDING, mainLineSize.height);
    128107    [mainLine drawInRect: lineRect withAttributes: fMainLineAttributes];
    129108   
  • trunk/macosx/DragOverlayWindow.m

    r3955 r4058  
    107107   
    108108    //set strings and icon
    109     NSImage * icon = nil;
    110109    NSString * secondString = [NSString stringForFileSize: size];
    111110    if (count > 1 || folder)
     
    119118    }
    120119   
     120    NSImage * icon;
    121121    if (count == 1)
    122122        icon = [[NSWorkspace sharedWorkspace] iconForFileType: folder ? NSFileTypeForHFSTypeCode('fldr') : [name pathExtension]];
     
    125125        name = [NSString stringWithFormat: NSLocalizedString(@"%d Torrent Files", "Drag overlay -> torrents"), count];
    126126        secondString = [secondString stringByAppendingString: @" Total"];
     127        icon = [NSImage imageNamed: @"TransmissionDocument.icns"];
    127128    }
    128129   
Note: See TracChangeset for help on using the changeset viewer.