Skip to content

Commit

Permalink
Merge pull request #1537 from mrcarlberg/cptableview_selection_radius
Browse files Browse the repository at this point in the history
Added a themed attribute for round rect selection of rows. [+1]
  • Loading branch information
primalmotion committed Jun 14, 2012
2 parents f8df87e + 49adcd8 commit 5219977
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions AppKit/CPTableView.j
Expand Up @@ -257,8 +257,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
*/
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[[CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null]]
forKeys:["alternating-row-colors", "grid-color", "highlighted-grid-color", "selection-color", "sourcelist-selection-color", "sort-image", "sort-image-reversed"]];
return [CPDictionary dictionaryWithObjects:[[CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null], [CPNull null]]
forKeys:["alternating-row-colors", "grid-color", "highlighted-grid-color", "selection-color", "sourcelist-selection-color", "sort-image", "sort-image-reversed", "selection-radius"]];
}

- (id)initWithFrame:(CGRect)aFrame
Expand Down Expand Up @@ -3773,7 +3773,25 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
CGContextStrokePath(context);
}
else
CGContextAddRect(context, rowRect);
{
var radius = [self currentValueForThemeAttribute:@"selection-radius"];

if (radius > 0)
{
var minX = CGRectGetMinX(rowRect),
maxX = CGRectGetMaxX(rowRect),
minY = CGRectGetMinY(rowRect),
maxY = CGRectGetMaxY(rowRect);

CGContextMoveToPoint(context, minX + radius, minY);
CGContextAddArcToPoint(context, maxX, minY, maxX, minY + radius, radius);
CGContextAddArcToPoint(context, maxX, maxY, maxX - radius, maxY, radius);
CGContextAddArcToPoint(context, minX, maxY, minX, maxY - radius, radius);
CGContextAddArcToPoint(context, minX, minY, minX + radius, minY, radius);
}
else
CGContextAddRect(context, rowRect);
}
}

CGContextClosePath(context);
Expand Down

0 comments on commit 5219977

Please sign in to comment.