Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add faux dropshadow similar to the one discussed on the mailing list …

  • Loading branch information...
commit 3f609d05ff517d3988f1a0774c6afefd8ba9521b 1 parent 439e2de
@jmoiron authored
Showing with 23 additions and 1 deletion.
  1. +23 −1 src/MacVim/MMCoreTextView.m
View
24 src/MacVim/MMCoreTextView.m
@@ -1066,6 +1066,21 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
float y = frame.size.height - insetSize.height - (1+row)*cellSize.height;
float w = cellSize.width;
+ /* shadow calculations */
+ float darken_factor = 20 / 100.0;
+ int ishadow = 0;
+ CGFloat r, g, b, a;
+ CGFloat h, s, v, a2;
+
+ NSColor *c = [NSColor colorWithCalibratedRed:RED(bg) green:GREEN(bg) blue:BLUE(bg) alpha:ALPHA(bg)];
+ [c getHue:&h saturation:&s brightness:&v alpha:&a2];
+ v = (v - darken_factor) > 0 ? (v - darken_factor) : 0;
+ NSColor *shadow = [NSColor colorWithCalibratedHue:h saturation:s brightness:v alpha:a2];
+ // use shadowColor?
+ [shadow getRed:&r green:&g blue:&b alpha:&a];
+
+ ishadow = ((int)(b*255)) | ((int)(g*255))<<8 | ((int)(r*255))<<16 | 0xff000000;
+
if (flags & DRAW_WIDE) {
// NOTE: It is assumed that either all characters in 'chars' are wide
// or all are normal width.
@@ -1132,7 +1147,6 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
CGContextSetTextDrawingMode(context, kCGTextFill);
- CGContextSetRGBFillColor(context, RED(fg), GREEN(fg), BLUE(fg), ALPHA(fg));
CGContextSetFontSize(context, [font pointSize]);
NSUInteger i;
@@ -1156,6 +1170,14 @@ - (void)drawString:(const UniChar *)chars length:(UniCharCount)length
}
}
+
+ /* Draw with negative x/y offsets for a drop shadow */
+ CGContextSetRGBFillColor(context, RED(ishadow), GREEN(ishadow), BLUE(ishadow), ALPHA(ishadow));
+ recurseDraw(chars, glyphs, advances, length, context, fontRef, x-1,
+ y+fontDescent-1);
+
+ CGContextSetRGBFillColor(context, RED(fg), GREEN(fg), BLUE(fg), ALPHA(fg));
+
recurseDraw(chars, glyphs, advances, length, context, fontRef, x,
y+fontDescent);
Please sign in to comment.
Something went wrong with that request. Please try again.