[vlc-commits] mac plugin: center and style dummy text
Felix Paul Kühne
git at videolan.org
Sun Dec 30 23:37:45 CET 2012
npapi-vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Dec 30 23:37:20 2012 +0100| [32c8e5cdfb9c7702d6c63b8b074e24b94c8c00b0] | committer: Felix Paul Kühne
mac plugin: center and style dummy text
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=32c8e5cdfb9c7702d6c63b8b074e24b94c8c00b0
---
npapi/vlcplugin_mac.cpp | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/npapi/vlcplugin_mac.cpp b/npapi/vlcplugin_mac.cpp
index 67706cf..9eb0226 100644
--- a/npapi/vlcplugin_mac.cpp
+++ b/npapi/vlcplugin_mac.cpp
@@ -155,12 +155,19 @@ bool VlcPluginMac::handle_event(void *event)
CGContextSetGrayFillColor(cgContext, 0.5, 1.);
CGContextDrawPath(cgContext, kCGPathFill);
- // draw dummy text, needs improvement
- CGContextSetRGBStrokeColor(cgContext, 0, 0, 0, .5 );
- CGContextSetTextDrawingMode(cgContext, kCGTextFillStroke );
- CFAttributedStringRef attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("VLC Web Plugin"), NULL );
+ // draw info text
+ CGContextSetRGBStrokeColor(cgContext, 0, 0, 0, .5);
+ CGContextSetTextDrawingMode(cgContext, kCGTextFillStroke);
+ CFStringRef keys[] = { kCTFontAttributeName };
+ CFTypeRef values[] = { CTFontCreateWithName(CFSTR("Helvetica"),16,NULL) };
+ CFDictionaryRef stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
+ (const void **)&keys,
+ (const void **)&values,
+ 1, NULL, NULL);
+ CFAttributedStringRef attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("VLC Web Plugin"), stylesDict);
CTLineRef textTine = CTLineCreateWithAttributedString(attRef);
- CGContextSetTextPosition(cgContext, 200, 200 );
+ CGRect textRect = CTLineGetImageBounds(textTine, cgContext);
+ CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2), ((windowHeight - textRect.size.height) / 2));
CTLineDraw(textTine, cgContext);
CFRelease(textTine);
More information about the vlc-commits
mailing list