Permalink
Browse files

Refined the look of $(see last commit) on systems < 10.10 a bit

  • Loading branch information...
dmoagx committed Feb 15, 2015
1 parent 3d18994 commit 2fda43e6a54c0c7532d80b9f3f86987ceb772342
Showing with 42 additions and 0 deletions.
  1. +42 −0 Source/SPFavoriteTextFieldCell.m
@@ -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];
CGContextEndTransparencyLayer(context);
}
CGContextEndTransparencyLayer(context);
[NSGraphicsContext restoreGraphicsState];
[shadow release];
}
}

0 comments on commit 2fda43e

Please sign in to comment.