diff options
author | Max <post@wickenrode.com> | 2015-02-15 22:05:37 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-02-15 22:05:37 +0100 |
commit | 2fda43e6a54c0c7532d80b9f3f86987ceb772342 (patch) | |
tree | 77c091f0378767a09388f695ca8752d5d558b9f9 | |
parent | 3d18994b788dc9563bba804e2eec56cd035bae09 (diff) | |
download | sequelpro-2fda43e6a54c0c7532d80b9f3f86987ceb772342.tar.gz sequelpro-2fda43e6a54c0c7532d80b9f3f86987ceb772342.tar.bz2 sequelpro-2fda43e6a54c0c7532d80b9f3f86987ceb772342.zip |
Refined the look of $(see last commit) on systems < 10.10 a bit
-rw-r--r-- | Source/SPFavoriteTextFieldCell.m | 42 |
1 files changed, 42 insertions, 0 deletions
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]; } } |