[vlc-commits] windowless mac plugin: add support for the optional 'text' element
Felix Paul Kühne
git at videolan.org
Mon Feb 17 23:38:41 CET 2014
npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Feb 17 23:38:44 2014 +0100| [9abc5496dbee58d07d64bfb065ddc28a08138c0d] | committer: Felix Paul Kühne
windowless mac plugin: add support for the optional 'text' element
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=9abc5496dbee58d07d64bfb065ddc28a08138c0d
---
npapi/vlcwindowless_mac.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/npapi/vlcwindowless_mac.cpp b/npapi/vlcwindowless_mac.cpp
index 5914f3f..6e1dae7 100644
--- a/npapi/vlcwindowless_mac.cpp
+++ b/npapi/vlcwindowless_mac.cpp
@@ -146,10 +146,53 @@ void VlcWindowlessMac::drawNoPlayback(CGContextRef cgContext)
}
CGContextDrawImage(cgContext, CGRectMake((windowWidth - coneWidth) / 2., (windowHeight - coneHeight) / 2., coneWidth, coneHeight), cone);
CGImageRelease(cone);
+
+ // draw custom text
+ values[0] = CTFontCreateWithName(CFSTR("Helvetica"),14,NULL);
+ stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
+ (const void **)&keys,
+ (const void **)&values,
+ 2, NULL, NULL);
+ const char *text = get_options().get_bg_text().c_str();
+ if (text != NULL) {
+ attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithCString(kCFAllocatorDefault, text, kCFStringEncodingUTF8), stylesDict);
+ textLine = CTLineCreateWithAttributedString(attRef);
+ CGRect textRect = CTLineGetImageBounds(textLine, cgContext);
+ CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2.), (windowHeight / 2.) + (coneHeight / 2.) + textRect.size.height + 50.);
+ CTLineDraw(textLine, cgContext);
+ CFRelease(textLine);
+ CFRelease(attRef);
+ }
+ CFRelease(stylesDict);
} else {
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
+
+ const char *text = get_options().get_bg_text().c_str();
+ if (text != NULL) {
+ CGContextSetGrayStrokeColor(cgContext, .95, 1.);
+ CGContextSetTextDrawingMode(cgContext, kCGTextFill);
+ CGContextSetGrayFillColor(cgContext, 1., 1.);
+ CFStringRef keys[2];
+ keys[0] = kCTFontAttributeName;
+ keys[1] = kCTForegroundColorFromContextAttributeName;
+ CFTypeRef values[2];
+ values[0] = CTFontCreateWithName(CFSTR("Helvetica Neue Light"),18,NULL);
+ values[1] = kCFBooleanTrue;
+ CFDictionaryRef stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
+ (const void **)&keys,
+ (const void **)&values,
+ 2, NULL, NULL);
+ CFAttributedStringRef attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithCString(kCFAllocatorDefault, text, kCFStringEncodingUTF8), stylesDict);
+ CTLineRef textLine = CTLineCreateWithAttributedString(attRef);
+ CGRect textRect = CTLineGetImageBounds(textLine, cgContext);
+ CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2.), (windowHeight / 2.));
+ CTLineDraw(textLine, cgContext);
+ CFRelease(textLine);
+ CFRelease(attRef);
+ CFRelease(stylesDict);
+ }
}
CGColorRelease(backgroundColor);
More information about the vlc-commits
mailing list