transmission/macosx/TorrentCell.mm

55 lines
1.7 KiB
Plaintext
Raw Normal View History

// This file Copyright © Transmission authors and contributors.
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.
2007-09-16 01:02:06 +00:00
#import "TorrentCell.h"
#import "ProgressBarView.h"
#import "ProgressGradients.h"
2009-10-11 03:36:50 +00:00
#import "Torrent.h"
#import "NSImageAdditions.h"
static CGFloat const kPriorityIconWidth = 12.0;
2007-09-16 01:02:06 +00:00
@implementation TorrentCell
- (void)drawRect:(NSRect)dirtyRect
2007-09-16 01:02:06 +00:00
{
if (self.fTorrentTableView)
{
Torrent* torrent = (Torrent*)self.objectValue;
// draw progress bar
NSRect barRect = self.fTorrentProgressBarView.frame;
ProgressBarView* progressBar = [[ProgressBarView alloc] init];
[progressBar drawBarInRect:barRect forTableView:self.fTorrentTableView withTorrent:torrent];
// set priority icon
if (torrent.priority != TR_PRI_NORMAL)
{
NSColor* priorityColor = self.backgroundStyle == NSBackgroundStyleEmphasized ? NSColor.whiteColor : NSColor.labelColor;
NSImage* priorityImage = [[NSImage imageNamed:(torrent.priority == TR_PRI_HIGH ? @"PriorityHighTemplate" : @"PriorityLowTemplate")]
imageWithColor:priorityColor];
self.fTorrentPriorityView.image = priorityImage;
self.fStackView.spacing = 4;
self.fTorrentPriorityViewWidthConstraint.constant = kPriorityIconWidth;
}
else
{
self.fTorrentPriorityView.image = nil;
self.fStackView.spacing = 0;
self.fTorrentPriorityViewWidthConstraint.constant = 0;
}
}
[super drawRect:dirtyRect];
}
// otherwise progress bar is inverted
- (BOOL)isFlipped
{
return YES;
}
2007-09-16 01:02:06 +00:00
@end