Skip to content

Commit 2fda43e

Browse files
committed
Refined the look of $(see last commit) on systems < 10.10 a bit
1 parent 3d18994 commit 2fda43e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Source/SPFavoriteTextFieldCell.m

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,54 @@ - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
9090
[bg fill];
9191
}
9292
else {
93+
// Draw main background gradient
9394
NSGradient * gradient = [[NSGradient alloc] initWithColorsAndLocations:
9495
[labelColor highlightWithLevel:0.33], 0.0,
9596
labelColor, 0.5,
9697
[labelColor shadowWithLevel:0.15], 1.0, nil];
9798
[gradient drawInBezierPath:bg angle:90.0];
9899
[gradient release];
100+
101+
//replace the shadow color of the highlighted item (the default is dark blue)
102+
if([self isHighlighted]) {
103+
NSMutableAttributedString *mas = [[self attributedStringValue] mutableCopy];
104+
NSShadow *strShadow = [mas attribute:NSShadowAttributeName atIndex:0 effectiveRange:NULL];
105+
if(strShadow) {
106+
[strShadow setShadowColor:[labelColor shadowWithLevel:0.4]];
107+
[self setAttributedStringValue:mas];
108+
}
109+
[mas release];
110+
}
111+
112+
// Add a little border at the top half (technically this is an inner shadow)
113+
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
114+
115+
NSShadow* shadow = [[NSShadow alloc] init];
116+
[shadow setShadowColor:labelColor];
117+
[shadow setShadowOffset: NSMakeSize(0.1, -1.2)];
118+
[shadow setShadowBlurRadius: 1];
119+
120+
[NSGraphicsContext saveGraphicsState];
121+
NSRectClip([bg bounds]);
122+
CGContextSetShadowWithColor(context, CGSizeZero, 0, NULL);
123+
124+
CGContextSetAlpha(context, [[shadow shadowColor] alphaComponent]);
125+
CGContextBeginTransparencyLayer(context, NULL);
126+
{
127+
[shadow set];
128+
129+
CGContextSetBlendMode(context, kCGBlendModeSourceOut);
130+
CGContextBeginTransparencyLayer(context, NULL);
131+
132+
[[shadow shadowColor] setFill];
133+
[bg fill];
134+
135+
CGContextEndTransparencyLayer(context);
136+
}
137+
CGContextEndTransparencyLayer(context);
138+
[NSGraphicsContext restoreGraphicsState];
139+
140+
[shadow release];
99141
}
100142
}
101143

0 commit comments

Comments
 (0)