mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
update macOS group indicators (#3183)
* update macOS group indicators proposal for updated Group indicators, inspired by Xcode, and ios Calendar. Discussion over here: https://github.com/transmission/transmission/issues/3058 * Update TorrentCell.mm resolve some pr isssues * Update TorrentCell.mm add a group indicator width definition
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
@property(nonatomic) BOOL hoverAction;
|
@property(nonatomic) BOOL hoverAction;
|
||||||
|
|
||||||
- (NSRect)iconRectForBounds:(NSRect)bounds;
|
- (NSRect)iconRectForBounds:(NSRect)bounds;
|
||||||
|
- (NSRect)actionRectForBounds:(NSRect)bounds;
|
||||||
|
|
||||||
- (void)addTrackingAreasForView:(NSView*)controlView
|
- (void)addTrackingAreasForView:(NSView*)controlView
|
||||||
inRect:(NSRect)cellFrame
|
inRect:(NSRect)cellFrame
|
||||||
|
|||||||
@@ -16,6 +16,10 @@
|
|||||||
#define IMAGE_SIZE_MIN 16.0
|
#define IMAGE_SIZE_MIN 16.0
|
||||||
#define ERROR_IMAGE_SIZE 20.0
|
#define ERROR_IMAGE_SIZE 20.0
|
||||||
|
|
||||||
|
#define GROUP_IMAGE_WIDTH 4.0
|
||||||
|
#define GROUP_INSET_REG 4.0
|
||||||
|
#define GROUP_PADDING_REG 22.0
|
||||||
|
|
||||||
#define NORMAL_BUTTON_WIDTH 14.0
|
#define NORMAL_BUTTON_WIDTH 14.0
|
||||||
#define ACTION_BUTTON_WIDTH 16.0
|
#define ACTION_BUTTON_WIDTH 16.0
|
||||||
|
|
||||||
@@ -126,6 +130,16 @@
|
|||||||
return NSMakeRect(NSMinX(bounds) + PADDING_HORIZONTAL, ceil(NSMidY(bounds) - imageSize * 0.5), imageSize, imageSize);
|
return NSMakeRect(NSMinX(bounds) + PADDING_HORIZONTAL, ceil(NSMidY(bounds) - imageSize * 0.5), imageSize, imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSRect)actionRectForBounds:(NSRect)bounds
|
||||||
|
{
|
||||||
|
BOOL const minimal = [self.fDefaults boolForKey:@"SmallView"];
|
||||||
|
|
||||||
|
NSRect iconRect = [self iconRectForBounds:bounds];
|
||||||
|
iconRect.origin.x += minimal ? 0.0 : GROUP_INSET_REG * 2 + GROUP_IMAGE_WIDTH;
|
||||||
|
|
||||||
|
return iconRect;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSCellHitResult)hitTestForEvent:(NSEvent*)event inRect:(NSRect)cellFrame ofView:(NSView*)controlView
|
- (NSCellHitResult)hitTestForEvent:(NSEvent*)event inRect:(NSRect)cellFrame ofView:(NSView*)controlView
|
||||||
{
|
{
|
||||||
NSPoint point = [controlView convertPoint:event.locationInWindow fromView:nil];
|
NSPoint point = [controlView convertPoint:event.locationInWindow fromView:nil];
|
||||||
@@ -271,7 +285,7 @@
|
|||||||
[controlView addTrackingArea:area];
|
[controlView addTrackingArea:area];
|
||||||
|
|
||||||
//action button
|
//action button
|
||||||
NSRect actionButtonRect = [self iconRectForBounds:cellFrame]; //use the whole icon
|
NSRect actionButtonRect = [self actionRectForBounds:cellFrame];
|
||||||
NSTrackingAreaOptions actionOptions = options;
|
NSTrackingAreaOptions actionOptions = options;
|
||||||
if (NSMouseInRect(mouseLocation, actionButtonRect, controlView.flipped))
|
if (NSMouseInRect(mouseLocation, actionButtonRect, controlView.flipped))
|
||||||
{
|
{
|
||||||
@@ -296,34 +310,35 @@
|
|||||||
[self drawBar:minimal ? [self barRectMinForBounds:cellFrame] : [self barRectRegForBounds:cellFrame]];
|
[self drawBar:minimal ? [self barRectMinForBounds:cellFrame] : [self barRectRegForBounds:cellFrame]];
|
||||||
|
|
||||||
//group coloring
|
//group coloring
|
||||||
NSRect const iconRect = [self iconRectForBounds:cellFrame];
|
NSRect const parentRect = [self iconRectForBounds:cellFrame];
|
||||||
|
NSRect iconRect = NSMakeRect(parentRect.origin.x, parentRect.origin.y, parentRect.size.width, parentRect.size.height);
|
||||||
|
iconRect.origin.x += minimal ? 0 : GROUP_INSET_REG * 3;
|
||||||
|
|
||||||
NSInteger const groupValue = torrent.groupValue;
|
NSInteger const groupValue = torrent.groupValue;
|
||||||
if (groupValue != -1)
|
if (groupValue != -1)
|
||||||
{
|
{
|
||||||
NSRect groupRect = NSInsetRect(iconRect, -1.0, -2.0);
|
NSRect groupRect = NSInsetRect(parentRect, -1.0, -2.0);
|
||||||
if (!minimal)
|
if (!minimal)
|
||||||
{
|
{
|
||||||
groupRect.size.height -= 1.0;
|
groupRect.size.height = cellFrame.size.height - (GROUP_INSET_REG * 4);
|
||||||
groupRect.origin.y -= 1.0;
|
groupRect.size.width = GROUP_INSET_REG;
|
||||||
|
groupRect.origin.y -= GROUP_INSET_REG * 2;
|
||||||
|
groupRect.origin.x += GROUP_INSET_REG;
|
||||||
}
|
}
|
||||||
CGFloat const radius = minimal ? 3.0 : 6.0;
|
CGFloat const radius = GROUP_INSET_REG / 2;
|
||||||
|
|
||||||
|
CGFloat fractionOfBlendedColor = 0.05;
|
||||||
NSColor *groupColor = [GroupsController.groups colorForIndex:groupValue],
|
NSColor *groupColor = [GroupsController.groups colorForIndex:groupValue],
|
||||||
*darkGroupColor = [groupColor blendedColorWithFraction:0.2 ofColor:NSColor.whiteColor];
|
*darkGroupColor = [groupColor blendedColorWithFraction:fractionOfBlendedColor ofColor:NSColor.controlTextColor];
|
||||||
|
|
||||||
//border
|
NSBezierPath* groupPath = [NSBezierPath bezierPathWithRoundedRect:groupRect xRadius:radius yRadius:radius];
|
||||||
NSBezierPath* bp = [NSBezierPath bezierPathWithRoundedRect:groupRect xRadius:radius yRadius:radius];
|
|
||||||
[darkGroupColor set];
|
|
||||||
bp.lineWidth = 2.0;
|
|
||||||
[bp stroke];
|
|
||||||
|
|
||||||
//inside
|
[groupPath setLineWidth:1.0];
|
||||||
bp = [NSBezierPath bezierPathWithRoundedRect:groupRect xRadius:radius yRadius:radius];
|
[darkGroupColor setStroke];
|
||||||
NSGradient* gradient = [[NSGradient alloc] initWithStartingColor:[groupColor blendedColorWithFraction:0.7
|
[groupPath stroke];
|
||||||
ofColor:NSColor.whiteColor]
|
|
||||||
endingColor:darkGroupColor];
|
[groupColor setFill];
|
||||||
[gradient drawInBezierPath:bp angle:90.0];
|
[groupPath fill];
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL const error = torrent.anyErrorOrWarning;
|
BOOL const error = torrent.anyErrorOrWarning;
|
||||||
@@ -458,8 +473,10 @@
|
|||||||
#warning image should use new gear
|
#warning image should use new gear
|
||||||
if (!self.fTracking && self.hoverAction)
|
if (!self.fTracking && self.hoverAction)
|
||||||
{
|
{
|
||||||
|
NSRect actionRect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, cellFrame.size.height);
|
||||||
|
actionRect.origin.x += minimal ? 0.0 : GROUP_INSET_REG * 3;
|
||||||
NSImage* actionImage = [NSImage imageNamed:@"ActionHover"];
|
NSImage* actionImage = [NSImage imageNamed:@"ActionHover"];
|
||||||
[actionImage drawInRect:[self actionButtonRectForBounds:cellFrame] fromRect:NSZeroRect
|
[actionImage drawInRect:[self actionButtonRectForBounds:actionRect] fromRect:NSZeroRect
|
||||||
operation:NSCompositingOperationSourceOver
|
operation:NSCompositingOperationSourceOver
|
||||||
fraction:1.0
|
fraction:1.0
|
||||||
respectFlipped:YES
|
respectFlipped:YES
|
||||||
@@ -745,6 +762,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
result.origin.x += GROUP_PADDING_REG;
|
||||||
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE;
|
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE;
|
||||||
result.size.width = rightBound - NSMinX(result) - PADDING_HORIZONTAL;
|
result.size.width = rightBound - NSMinX(result) - PADDING_HORIZONTAL;
|
||||||
}
|
}
|
||||||
@@ -762,7 +780,7 @@
|
|||||||
{
|
{
|
||||||
NSRect result;
|
NSRect result;
|
||||||
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS;
|
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS;
|
||||||
result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + GROUP_PADDING_REG + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||||
|
|
||||||
result.size.height = HEIGHT_STATUS;
|
result.size.height = HEIGHT_STATUS;
|
||||||
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
|
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
|
||||||
@@ -775,7 +793,7 @@
|
|||||||
NSRect result;
|
NSRect result;
|
||||||
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS +
|
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS +
|
||||||
PADDING_BETWEEN_PROGRESS_AND_BAR + BAR_HEIGHT + PADDING_BETWEEN_BAR_AND_STATUS;
|
PADDING_BETWEEN_PROGRESS_AND_BAR + BAR_HEIGHT + PADDING_BETWEEN_BAR_AND_STATUS;
|
||||||
result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + GROUP_PADDING_REG + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||||
|
|
||||||
result.size.height = HEIGHT_STATUS;
|
result.size.height = HEIGHT_STATUS;
|
||||||
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
|
result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL;
|
||||||
@@ -787,7 +805,7 @@
|
|||||||
{
|
{
|
||||||
NSRect result;
|
NSRect result;
|
||||||
result.size.height = BAR_HEIGHT;
|
result.size.height = BAR_HEIGHT;
|
||||||
result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_BAR;
|
result.origin.x = NSMinX(bounds) + PADDING_HORIZONTAL + GROUP_PADDING_REG + IMAGE_SIZE_REG + PADDING_BETWEEN_IMAGE_AND_BAR;
|
||||||
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS +
|
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE + PADDING_BETWEEN_TITLE_AND_PROGRESS + HEIGHT_STATUS +
|
||||||
PADDING_BETWEEN_PROGRESS_AND_BAR;
|
PADDING_BETWEEN_PROGRESS_AND_BAR;
|
||||||
|
|
||||||
|
|||||||
@@ -758,7 +758,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRect const rect = [self.fTorrentCell iconRectForBounds:[self rectOfRow:row]];
|
NSRect const rect = [self.fTorrentCell actionRectForBounds:[self rectOfRow:row]];
|
||||||
|
|
||||||
if (self.fActionPopoverShown)
|
if (self.fActionPopoverShown)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user