From 183260d9e3d23b1cffaa12bc4de5b869f796b12d Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Fri, 11 May 2012 16:14:14 +0200 Subject: [PATCH 1/3] Added a themed attribute for round rect selection of rows. Selections in the tableview can now have round corners. The default is a regular rect, but if the selecction radius is changed. Nice good looking round rect selections will appear. --- AppKit/CPTableView.j | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 38b86ff85..d33f62dc1 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -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 @@ -794,6 +794,26 @@ NOT YET IMPLEMENTED return [self currentValueForThemeAttribute:@"selection-color"]; } +/*! + Sets the highlight radius for a row or column selection. + + @param aRadius a int +*/ +- (void)setSelectionHighlightRadius:(int)aRadius +{ + [self setValue:aRadius forThemeAttribute:"selection-radius"]; + + [self setNeedsDisplay:YES]; +} + +/*! + Returns the highlight radius for a row or column selection. +*/ +- (int)selectionHighlightRadius +{ + return [self currentValueForThemeAttribute:@"selection-radius"]; +} + /*! Sets the highlight gradient for a row or column selection @@ -3773,7 +3793,24 @@ Your delegate can implement this method to avoid subclassing the tableview to ad CGContextStrokePath(context); } else - CGContextAddRect(context, rowRect); + { + var radius = [self selectionHighlightRadius]; + 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); From 8e785c22108ebdca90cc380fbe010f564da5eedc Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Fri, 25 May 2012 10:47:07 +0200 Subject: [PATCH 2/3] Removed set and get methods and blank line before if added. --- AppKit/CPTableView.j | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index d33f62dc1..39bd69836 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -794,26 +794,6 @@ NOT YET IMPLEMENTED return [self currentValueForThemeAttribute:@"selection-color"]; } -/*! - Sets the highlight radius for a row or column selection. - - @param aRadius a int -*/ -- (void)setSelectionHighlightRadius:(int)aRadius -{ - [self setValue:aRadius forThemeAttribute:"selection-radius"]; - - [self setNeedsDisplay:YES]; -} - -/*! - Returns the highlight radius for a row or column selection. -*/ -- (int)selectionHighlightRadius -{ - return [self currentValueForThemeAttribute:@"selection-radius"]; -} - /*! Sets the highlight gradient for a row or column selection @@ -3794,7 +3774,8 @@ Your delegate can implement this method to avoid subclassing the tableview to ad } else { - var radius = [self selectionHighlightRadius]; + var radius = [self currentValueForThemeAttribute:@"selection-radius"]; + if (radius > 0) { var minX = CGRectGetMinX(rowRect), From 49adcd85fcf7ee6d7be030b53aefe72ca0ee4f9f Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Fri, 25 May 2012 10:54:10 +0200 Subject: [PATCH 3/3] Removed useless space after capp_lint warning --- AppKit/CPTableView.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 39bd69836..da047e411 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -3782,7 +3782,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad 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);