diff --git a/macosx/DragOverlayView.h b/macosx/DragOverlayView.h index 1930f0129..a3ff44b70 100644 --- a/macosx/DragOverlayView.h +++ b/macosx/DragOverlayView.h @@ -26,7 +26,7 @@ @interface DragOverlayView : NSView { - NSImage * fBadge, * fBackBadge, * fAppIcon; + NSImage * fBadge, * fBackBadge; NSDictionary * fMainLineAttributes, * fSubLineAttributes; } diff --git a/macosx/DragOverlayView.m b/macosx/DragOverlayView.m index dc12f634f..972f3dead 100644 --- a/macosx/DragOverlayView.m +++ b/macosx/DragOverlayView.m @@ -26,6 +26,7 @@ #import "NSBezierPathAdditions.h" #define PADDING 10.0 +#define ICON_WIDTH 64.0 @implementation DragOverlayView @@ -76,9 +77,7 @@ - (void) dealloc { [fBackBadge release]; - [fBadge release]; - [fAppIcon release]; [fMainLineAttributes release]; [fSubLineAttributes release]; @@ -92,39 +91,19 @@ fBadge = [fBackBadge copy]; NSSize badgeSize = [fBadge size]; - //get icon - NSSize iconSize = NSMakeSize(64.0, 64.0); - if (!icon) - { - if (!fAppIcon) - { - fAppIcon = [[NSImage imageNamed: @"TransmissionDocument.icns"] copy]; - [fAppIcon setScalesWhenResized: YES]; - [fAppIcon setSize: iconSize]; - } - icon = [fAppIcon retain]; - } - else - { - icon = [icon copy]; - [icon setScalesWhenResized: YES]; - [icon setSize: iconSize]; - } - - [fBadge lockFocus]; - //place icon - [icon compositeToPoint: NSMakePoint(PADDING, (badgeSize.height - iconSize.height) * 0.5) - operation: NSCompositeSourceOver]; - [icon release]; + [fBadge lockFocus]; + const float WIDTH = 64.0; + [icon drawInRect: NSMakeRect(PADDING, (badgeSize.height - ICON_WIDTH) * 0.5, ICON_WIDTH, ICON_WIDTH) fromRect: NSZeroRect + operation: NSCompositeSourceOver fraction: 1.0]; //place main text NSSize mainLineSize = [mainLine sizeWithAttributes: fMainLineAttributes]; NSSize subLineSize = [subLine sizeWithAttributes: fSubLineAttributes]; - NSRect lineRect = NSMakeRect(PADDING + iconSize.width + 5.0, + NSRect lineRect = NSMakeRect(PADDING + ICON_WIDTH + 5.0, (badgeSize.height + (subLineSize.height + 2.0 - mainLineSize.height)) * 0.5, - badgeSize.width - (PADDING + iconSize.width + 2.0) - PADDING, mainLineSize.height); + badgeSize.width - (PADDING + ICON_WIDTH + 2.0) - PADDING, mainLineSize.height); [mainLine drawInRect: lineRect withAttributes: fMainLineAttributes]; //place sub text diff --git a/macosx/DragOverlayWindow.m b/macosx/DragOverlayWindow.m index 5eaa39600..3c9f2e770 100644 --- a/macosx/DragOverlayWindow.m +++ b/macosx/DragOverlayWindow.m @@ -106,7 +106,6 @@ return; //set strings and icon - NSImage * icon = nil; NSString * secondString = [NSString stringForFileSize: size]; if (count > 1 || folder) { @@ -118,12 +117,14 @@ secondString = [fileString stringByAppendingString: secondString]; } + NSImage * icon; if (count == 1) icon = [[NSWorkspace sharedWorkspace] iconForFileType: folder ? NSFileTypeForHFSTypeCode('fldr') : [name pathExtension]]; else { name = [NSString stringWithFormat: NSLocalizedString(@"%d Torrent Files", "Drag overlay -> torrents"), count]; secondString = [secondString stringByAppendingString: @" Total"]; + icon = [NSImage imageNamed: @"TransmissionDocument.icns"]; } [[self contentView] setOverlay: icon mainLine: name subLine: secondString];