Skip to content


Refined the look of $(see last commit) on systems < 10.10 a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed Feb 15, 2015
1 parent 3d18994 commit 2fda43e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Source/SPFavoriteTextFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,54 @@ - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
[bg fill];
else {
// Draw main background gradient
NSGradient * gradient = [[NSGradient alloc] initWithColorsAndLocations:
[labelColor highlightWithLevel:0.33], 0.0,
labelColor, 0.5,
[labelColor shadowWithLevel:0.15], 1.0, nil];
[gradient drawInBezierPath:bg angle:90.0];
[gradient release];

//replace the shadow color of the highlighted item (the default is dark blue)
if([self isHighlighted]) {
NSMutableAttributedString *mas = [[self attributedStringValue] mutableCopy];
NSShadow *strShadow = [mas attribute:NSShadowAttributeName atIndex:0 effectiveRange:NULL];
if(strShadow) {
[strShadow setShadowColor:[labelColor shadowWithLevel:0.4]];
[self setAttributedStringValue:mas];
[mas release];

// Add a little border at the top half (technically this is an inner shadow)
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];

NSShadow* shadow = [[NSShadow alloc] init];
[shadow setShadowColor:labelColor];
[shadow setShadowOffset: NSMakeSize(0.1, -1.2)];
[shadow setShadowBlurRadius: 1];

[NSGraphicsContext saveGraphicsState];
NSRectClip([bg bounds]);
CGContextSetShadowWithColor(context, CGSizeZero, 0, NULL);

CGContextSetAlpha(context, [[shadow shadowColor] alphaComponent]);
CGContextBeginTransparencyLayer(context, NULL);
[shadow set];

CGContextSetBlendMode(context, kCGBlendModeSourceOut);
CGContextBeginTransparencyLayer(context, NULL);

[[shadow shadowColor] setFill];
[bg fill];

[NSGraphicsContext restoreGraphicsState];

[shadow release];

Expand Down

0 comments on commit 2fda43e

Please sign in to comment.