1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-03 05:25:52 +00:00

clean up the table text coloring code; trivial cleanup

This commit is contained in:
Mitchell Livingston 2009-01-02 01:10:54 +00:00
parent 2eb2dacd50
commit b97fa09270
6 changed files with 21 additions and 21 deletions

View file

@ -37,7 +37,7 @@
- (id) initWithFrame: (NSRect) frame lib: (tr_session *) lib; - (id) initWithFrame: (NSRect) frame lib: (tr_session *) lib;
- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate; - (void) displayRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate;
- (void) setQuitting; - (void) setQuitting;
@end @end

View file

@ -54,15 +54,15 @@
[super dealloc]; [super dealloc];
} }
- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate - (void) displayRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
{ {
//only needs update if the badges were displayed or are displayed now //only needs update if the badges were displayed or are displayed now
if (fDownloadRate == downloadRate && fUploadRate == uploadRate) if (fDownloadRate == downloadRate && fUploadRate == uploadRate)
return NO; return;
fDownloadRate = downloadRate; fDownloadRate = downloadRate;
fUploadRate = uploadRate; fUploadRate = uploadRate;
return YES; [self display];
} }
- (void) setQuitting - (void) setQuitting

View file

@ -56,13 +56,11 @@
- (void) updateBadge - (void) updateBadge
{ {
float downloadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"] float downloadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeDownloadRate"]
? tr_sessionGetPieceSpeed(fLib, TR_DOWN) : 0.0f; ? tr_sessionGetPieceSpeed(fLib, TR_DOWN) : 0.0;
float uploadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"] float uploadRate = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"]
? tr_sessionGetPieceSpeed(fLib, TR_UP) : 0.0f; ? tr_sessionGetPieceSpeed(fLib, TR_UP) : 0.0;
//only update if the badged values change [(BadgeView *)[[NSApp dockTile] contentView] displayRatesWithDownload: downloadRate upload: uploadRate];
if ([(BadgeView *)[[NSApp dockTile] contentView] setRatesWithDownload: downloadRate upload: uploadRate])
[[NSApp dockTile] display];
} }
- (void) incrementCompleted - (void) incrementCompleted

View file

@ -139,21 +139,24 @@
//icon //icon
[[self image] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0]; [[self image] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
//title NSColor * titleColor, * statusColor;
NSColor * specialColor = nil; if ([self backgroundStyle] == NSBackgroundStyleDark)
if ([self isHighlighted] titleColor = statusColor = [NSColor whiteColor];
&& [[self highlightColorWithFrame: cellFrame inView: controlView] isEqual: [NSColor alternateSelectedControlColor]])
specialColor = [NSColor whiteColor];
else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles: [(FileListNode *)[self objectValue] indexes]] == NSOffState) else if ([[(FileOutlineView *)[self controlView] torrent] checkForFiles: [(FileListNode *)[self objectValue] indexes]] == NSOffState)
specialColor = [NSColor disabledControlTextColor]; titleColor = statusColor = [NSColor disabledControlTextColor];
else; else
{
titleColor = [NSColor controlTextColor];
statusColor = [NSColor darkGrayColor];
}
NSAttributedString * titleString = [self attributedTitleWithColor: specialColor ? specialColor : [NSColor controlTextColor]]; //title
NSAttributedString * titleString = [self attributedTitleWithColor: titleColor];
NSRect titleRect = [self rectForTitleWithString: titleString inBounds: cellFrame]; NSRect titleRect = [self rectForTitleWithString: titleString inBounds: cellFrame];
[titleString drawInRect: titleRect]; [titleString drawInRect: titleRect];
//status //status
NSAttributedString * statusString = [self attributedStatusWithColor: specialColor ? specialColor : [NSColor darkGrayColor]]; NSAttributedString * statusString = [self attributedStatusWithColor: statusColor];
NSRect statusRect = [self rectForStatusWithString: statusString withTitleRect: titleRect inBounds: cellFrame]; NSRect statusRect = [self rectForStatusWithString: statusString withTitleRect: titleRect inBounds: cellFrame];
[statusString drawInRect: statusRect]; [statusString drawInRect: statusRect];
} }

View file

@ -366,7 +366,7 @@ GroupsController * fGroupsInstance = nil;
if ([self torrent: torrent doesMatchRulesForGroupAtIndex: row]) if ([self torrent: torrent doesMatchRulesForGroupAtIndex: row])
return row; return row;
} }
return -1; // Default to no group return -1;
} }
@end @end

View file

@ -432,8 +432,7 @@
//text color //text color
NSColor * titleColor, * statusColor; NSColor * titleColor, * statusColor;
if ([self isHighlighted] if ([self backgroundStyle] == NSBackgroundStyleDark)
&& [[self highlightColorWithFrame: cellFrame inView: controlView] isEqual: [NSColor alternateSelectedControlColor]])
{ {
titleColor = [NSColor whiteColor]; titleColor = [NSColor whiteColor];
statusColor = [NSColor whiteColor]; statusColor = [NSColor whiteColor];