2023-11-01 21:11:11 +00:00
|
|
|
// This file Copyright © Transmission authors and contributors.
|
2022-01-20 18:27:56 +00:00
|
|
|
// 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"
|
2023-06-27 19:40:44 +00:00
|
|
|
#import "ProgressBarView.h"
|
2008-10-31 00:13:50 +00:00
|
|
|
#import "ProgressGradients.h"
|
2009-10-11 03:36:50 +00:00
|
|
|
#import "Torrent.h"
|
2023-08-13 19:37:42 +00:00
|
|
|
#import "NSImageAdditions.h"
|
|
|
|
|
|
|
|
static CGFloat const kPriorityIconWidth = 12.0;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
@implementation TorrentCell
|
|
|
|
|
2023-06-27 19:40:44 +00:00
|
|
|
- (void)drawRect:(NSRect)dirtyRect
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2023-06-27 19:40:44 +00:00
|
|
|
if (self.fTorrentTableView)
|
2017-01-24 17:53:16 +00:00
|
|
|
{
|
2023-06-27 19:40:44 +00:00
|
|
|
Torrent* torrent = (Torrent*)self.objectValue;
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2023-09-02 01:41:03 +00:00
|
|
|
// draw progress bar
|
|
|
|
NSRect barRect = self.fTorrentProgressBarView.frame;
|
|
|
|
ProgressBarView* progressBar = [[ProgressBarView alloc] init];
|
2023-06-27 19:40:44 +00:00
|
|
|
[progressBar drawBarInRect:barRect forTableView:self.fTorrentTableView withTorrent:torrent];
|
2023-08-13 19:37:42 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2021-08-15 09:41:48 +00:00
|
|
|
}
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2023-06-27 19:40:44 +00:00
|
|
|
[super drawRect:dirtyRect];
|
2008-01-14 18:02:08 +00:00
|
|
|
}
|
|
|
|
|
2023-09-02 01:41:03 +00:00
|
|
|
// otherwise progress bar is inverted
|
2023-06-27 19:40:44 +00:00
|
|
|
- (BOOL)isFlipped
|
2008-01-14 18:02:08 +00:00
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
@end
|