From 2fda43e6a54c0c7532d80b9f3f86987ceb772342 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 15 Feb 2015 22:05:37 +0100 Subject: Refined the look of $(see last commit) on systems < 10.10 a bit --- Source/SPFavoriteTextFieldCell.m | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'Source') diff --git a/Source/SPFavoriteTextFieldCell.m b/Source/SPFavoriteTextFieldCell.m index 00c05da1..cf9f6a05 100644 --- a/Source/SPFavoriteTextFieldCell.m +++ b/Source/SPFavoriteTextFieldCell.m @@ -90,12 +90,54 @@ extern BOOL isOSAtLeast10_10_0(void); [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]; } } -- cgit v1.2.3