| 1 |
#import "JVSideOutlineView.h" |
|---|
| 2 |
|
|---|
| 3 |
static void gradientInterpolate( void *info, float const *inData, float *outData ) { |
|---|
| 4 |
static float light[4] = { 0.67843137, 0.73333333, 0.81568627, 1. }; |
|---|
| 5 |
static float dark[4] = { 0.59607843, 0.66666667, 0.76862745, 1. }; |
|---|
| 6 |
float a = inData[0]; |
|---|
| 7 |
int i = 0; |
|---|
| 8 |
|
|---|
| 9 |
for( i = 0; i < 4; i++ ) |
|---|
| 10 |
outData[i] = ( 1. - a ) * dark[i] + a * light[i]; |
|---|
| 11 |
} |
|---|
| 12 |
|
|---|
| 13 |
@interface NSOutlineView (NSOutlineViewPrivate) |
|---|
| 14 |
- (NSColor *) _highlightColorForCell:(NSCell *) cell; |
|---|
| 15 |
- (void) _highlightRow:(int) row clipRect:(NSRect) clip; |
|---|
| 16 |
@end |
|---|
| 17 |
|
|---|
| 18 |
@implementation JVSideOutlineView |
|---|
| 19 |
- (NSColor *) _highlightColorForCell:(NSCell *) cell { |
|---|
| 20 |
if( floor( NSAppKitVersionNumber ) > NSAppKitVersionNumber10_4 && [super respondsToSelector:_cmd] ) |
|---|
| 21 |
return [super _highlightColorForCell:cell]; |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
return nil; |
|---|
| 25 |
} |
|---|
| 26 |
|
|---|
| 27 |
- (void) _highlightRow:(int) row clipRect:(NSRect) clip { |
|---|
| 28 |
if( floor( NSAppKitVersionNumber ) > NSAppKitVersionNumber10_4 && [super respondsToSelector:_cmd] ) |
|---|
| 29 |
return [super _highlightRow:row clipRect:clip]; |
|---|
| 30 |
|
|---|
| 31 |
NSRect highlight = [self rectOfRow:row]; |
|---|
| 32 |
|
|---|
| 33 |
struct CGFunctionCallbacks callbacks = { 0, gradientInterpolate, NULL }; |
|---|
| 34 |
CGFunctionRef function = CGFunctionCreate( NULL, 1, NULL, 4, NULL, &callbacks ); |
|---|
| 35 |
CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); |
|---|
| 36 |
|
|---|
| 37 |
CGShadingRef shading = CGShadingCreateAxial( cspace, CGPointMake( NSMinX( highlight ), NSMaxY( highlight ) ), CGPointMake( NSMinX( highlight ), NSMinY( highlight ) ), function, false, false ); |
|---|
| 38 |
CGContextDrawShading( [[NSGraphicsContext currentContext] graphicsPort], shading ); |
|---|
| 39 |
|
|---|
| 40 |
CGShadingRelease( shading ); |
|---|
| 41 |
CGColorSpaceRelease( cspace ); |
|---|
| 42 |
CGFunctionRelease( function ); |
|---|
| 43 |
|
|---|
| 44 |
static NSColor *rowBottomLine = nil; |
|---|
| 45 |
if( ! rowBottomLine ) |
|---|
| 46 |
rowBottomLine = [[NSColor colorWithCalibratedRed:( 140. / 255. ) green:( 152. / 255. ) blue:( 176. / 255. ) alpha:1.] retain]; |
|---|
| 47 |
|
|---|
| 48 |
[rowBottomLine set]; |
|---|
| 49 |
|
|---|
| 50 |
NSRect bottomLine = NSMakeRect( NSMinX( highlight ), NSMaxY( highlight ) - 1., NSWidth( highlight ), 1. ); |
|---|
| 51 |
NSRectFill( bottomLine ); |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
- (void) drawBackgroundInClipRect:(NSRect) clipRect { |
|---|
| 55 |
if( floor( NSAppKitVersionNumber ) > NSAppKitVersionNumber10_4 && [super respondsToSelector:_cmd] ) |
|---|
| 56 |
return [super drawBackgroundInClipRect:clipRect]; |
|---|
| 57 |
|
|---|
| 58 |
static NSColor *backgroundColor = nil; |
|---|
| 59 |
if( ! backgroundColor ) |
|---|
| 60 |
backgroundColor = [[NSColor colorWithCalibratedRed:( 229. / 255. ) green:( 237. / 255. ) blue:( 247. / 255. ) alpha:1.] retain]; |
|---|
| 61 |
|
|---|
| 62 |
[backgroundColor set]; |
|---|
| 63 |
NSRectFill( clipRect ); |
|---|
| 64 |
} |
|---|
| 65 |
@end |
|---|