1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-04 02:28:03 +00:00

simplify group coloring

This commit is contained in:
Mitchell Livingston 2007-12-18 17:05:49 +00:00
parent 8ea3a88f43
commit 573aaface1
3 changed files with 12 additions and 20 deletions

View file

@ -38,7 +38,7 @@
+ (GroupsWindowController *) groupsController;
- (NSColor *) colorForIndex: (int) index;
- (CTGradient *) gradientForIndex: (int) index;
- (int) orderValueForIndex: (int) index;

View file

@ -40,7 +40,7 @@ typedef enum
- (void) saveGroups;
- (CTGradient *) gradientForPreviewColor: (NSColor *) color;
- (CTGradient *) gradientForColor: (NSColor *) color;
- (void) changeColor: (id) sender;
@end
@ -133,7 +133,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[super dealloc];
}
- (NSColor *) colorForIndex: (int) index
- (CTGradient *) gradientForIndex: (int) index
{
if (index < 0)
return nil;
@ -142,7 +142,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
NSDictionary * dict;
while ((dict = [enumerator nextObject]))
if ([[dict objectForKey: @"Index"] intValue] == index)
return [dict objectForKey: @"Color"];
return [self gradientForColor: [dict objectForKey: @"Color"]];
return nil;
}
@ -168,7 +168,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
{
NSString * identifier = [tableColumn identifier];
if ([identifier isEqualToString: @"Color"])
return [self gradientForPreviewColor: [[fGroups objectAtIndex: row] objectForKey: @"Color"]];
return [self gradientForColor: [[fGroups objectAtIndex: row] objectForKey: @"Color"]];
else
return [[fGroups objectAtIndex: row] objectForKey: @"Name"];
}
@ -351,7 +351,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
NSImage * icon = [[NSImage alloc] initWithSize: [bp bounds].size];
[icon lockFocus];
[[self gradientForPreviewColor: [dict objectForKey: @"Color"]] fillBezierPath: bp angle: 270.0];
[[self gradientForColor: [dict objectForKey: @"Color"]] fillBezierPath: bp angle: 270.0];
[icon unlockFocus];
[item setImage: icon];
@ -375,7 +375,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[[NSUserDefaults standardUserDefaults] setObject: [NSArchiver archivedDataWithRootObject: fGroups] forKey: @"Groups"];
}
- (CTGradient *) gradientForPreviewColor: (NSColor *) color
- (CTGradient *) gradientForColor: (NSColor *) color
{
return [CTGradient gradientWithBeginningColor: [color blendedColorWithFraction: 0.7 ofColor: [NSColor whiteColor]]
endingColor: [color blendedColorWithFraction: 0.2 ofColor: [NSColor whiteColor]]];

View file

@ -207,20 +207,13 @@
BOOL minimal = [fDefaults boolForKey: @"SmallView"];
//group coloring
NSRect iconRect = [self iconRectForBounds: cellFrame];
int groupValue = [torrent groupValue];
if (groupValue != -1)
{
NSRect groupRect = cellFrame;
groupRect.size.width = minimal ? WIDTH_GROUP_MIN : WIDTH_GROUP;
groupRect.origin.x -= 1.0;
groupRect.size.height += 1.0;
groupRect.origin.y -= 1.0;
NSColor * color = [[[GroupsWindowController groupsController] colorForIndex: groupValue]
blendedColorWithFraction: 0.3 ofColor: [NSColor whiteColor]];
CTGradient * gradient = [CTGradient gradientWithBeginningColor: color endingColor: [color colorWithAlphaComponent: 0.0]];
[gradient fillRect: groupRect angle: 0.0];
}
[[[GroupsWindowController groupsController] gradientForIndex: groupValue] fillBezierPath:
[NSBezierPath bezierPathWithRoundedRect: NSInsetRect(iconRect, -2.0, -2.0) radius: 6.0] angle: 90.0];
//error image
BOOL error = [torrent isError];
@ -232,7 +225,6 @@
//icon
NSImage * icon = minimal && error ? fErrorImage : [torrent icon];
NSRect iconRect = [self iconRectForBounds: cellFrame];
[icon drawInRect: iconRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
if (error && !minimal)