diff --git a/macosx/GroupsWindowController.h b/macosx/GroupsWindowController.h index 529084f8b..0289c6b82 100644 --- a/macosx/GroupsWindowController.h +++ b/macosx/GroupsWindowController.h @@ -38,7 +38,7 @@ + (GroupsWindowController *) groupsController; -- (NSColor *) colorForIndex: (int) index; +- (CTGradient *) gradientForIndex: (int) index; - (int) orderValueForIndex: (int) index; diff --git a/macosx/GroupsWindowController.m b/macosx/GroupsWindowController.m index 505b55dd6..bd8f2a54c 100644 --- a/macosx/GroupsWindowController.m +++ b/macosx/GroupsWindowController.m @@ -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]]]; diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 70f401329..0ab14fa01 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -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)