Commit 74fb9b65 authored by Felix Paul Kühne's avatar Felix Paul Kühne

mac windowless: improve info screen and cleanup

parent 8ad22f16
/***************************************************************************** /*****************************************************************************
* vlcwindowless_mac.cpp: VLC NPAPI windowless plugin for Mac * vlcwindowless_mac.cpp: VLC NPAPI windowless plugin for Mac
***************************************************************************** *****************************************************************************
* Copyright (C) 2012 VLC Authors and VideoLAN * Copyright (C) 2012-2013 VLC Authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Felix Paul Kühne <fkuehne # videolan # org> * Authors: Felix Paul Kühne <fkuehne # videolan # org>
...@@ -36,12 +36,8 @@ VlcWindowlessMac::~VlcWindowlessMac() ...@@ -36,12 +36,8 @@ VlcWindowlessMac::~VlcWindowlessMac()
} }
void VlcWindowlessMac::drawBackground(NPCocoaEvent *cocoaEvent) void VlcWindowlessMac::drawBackground(CGContextRef cgContext)
{ {
CGContextRef cgContext = cocoaEvent->data.draw.context;
if (!cgContext)
return;
float windowWidth = npwindow.width; float windowWidth = npwindow.width;
float windowHeight = npwindow.height; float windowHeight = npwindow.height;
...@@ -76,24 +72,58 @@ void VlcWindowlessMac::drawNoPlayback(CGContextRef cgContext) ...@@ -76,24 +72,58 @@ void VlcWindowlessMac::drawNoPlayback(CGContextRef cgContext)
// draw a gray background // draw a gray background
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight)); CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetGrayFillColor(cgContext, 0.5, 1.); CGContextSetGrayFillColor(cgContext, .5, 1.);
CGContextDrawPath(cgContext, kCGPathFill); CGContextDrawPath(cgContext, kCGPathFill);
// draw info text // draw info text
CGContextSetRGBStrokeColor(cgContext, 0, 0, 0, .5); CGContextSetGrayStrokeColor(cgContext, .7, 1.);
CGContextSetTextDrawingMode(cgContext, kCGTextFillStroke); CGContextSetTextDrawingMode(cgContext, kCGTextFillStroke);
CFStringRef keys[] = { kCTFontAttributeName }; CGContextSetGrayFillColor(cgContext, 1., 1.);
CFTypeRef values[] = { CTFontCreateWithName(CFSTR("Helvetica"),16,NULL) }; CFStringRef keys[2];
keys[0] = kCTFontAttributeName;
keys[1] = kCTForegroundColorFromContextAttributeName;
CFTypeRef values[2];
values[0] = CTFontCreateWithName(CFSTR("Helvetica"),18,NULL);
values[1] = kCFBooleanTrue;
CFDictionaryRef stylesDict = CFDictionaryCreate(kCFAllocatorDefault, CFDictionaryRef stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&keys, (const void **)&keys,
(const void **)&values, (const void **)&values,
1, NULL, NULL); 2, NULL, NULL);
CFAttributedStringRef attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("VLC Web Plugin"), stylesDict); CFAttributedStringRef attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("VLC Multimedia Plug-in"), stylesDict);
CTLineRef textTine = CTLineCreateWithAttributedString(attRef); CTLineRef textLine = CTLineCreateWithAttributedString(attRef);
CGRect textRect = CTLineGetImageBounds(textTine, cgContext); CGRect textRect = CTLineGetImageBounds(textLine, cgContext);
CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2), ((windowHeight - textRect.size.height) / 2)); CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2), ((windowHeight - textRect.size.height) / 2));
CTLineDraw(textTine, cgContext); CTLineDraw(textLine, cgContext);
CFRelease(textTine); CFRelease(textLine);
CFRelease(attRef);
// print smaller text from here
CFRelease(stylesDict);
values[0] = CTFontCreateWithName(CFSTR("Helvetica"),14,NULL);
stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&keys,
(const void **)&values,
2, NULL, NULL);
CGContextSetGrayFillColor(cgContext, .8, 1.);
// draw version string
attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithCString(kCFAllocatorDefault, libvlc_get_version(), kCFStringEncodingUTF8), stylesDict);
textLine = CTLineCreateWithAttributedString(attRef);
textRect = CTLineGetImageBounds(textLine, cgContext);
CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2), ((windowHeight - textRect.size.height) / 2) - 25.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
// expose drawing model
attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("windowless output mode using CoreGraphics"), stylesDict);
textLine = CTLineCreateWithAttributedString(attRef);
textRect = CTLineGetImageBounds(textLine, cgContext);
CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2), ((windowHeight - textRect.size.height) / 2) - 45.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
CFRelease(stylesDict);
CGContextRestoreGState(cgContext); CGContextRestoreGState(cgContext);
} }
...@@ -137,7 +167,7 @@ bool VlcWindowlessMac::handle_event(void *event) ...@@ -137,7 +167,7 @@ bool VlcWindowlessMac::handle_event(void *event)
return true; return true;
} }
drawBackground(cocoaEvent); drawBackground(cgContext);
if(!VlcPluginBase::player_has_vout()) if(!VlcPluginBase::player_has_vout())
return true; return true;
......
/***************************************************************************** /*****************************************************************************
* vlcwindowsless_mac.h: VLC NPAPI windowless plugin for Mac * vlcwindowsless_mac.h: VLC NPAPI windowless plugin for Mac
***************************************************************************** *****************************************************************************
* Copyright (C) 2012 VLC Authors and VideoLAN * Copyright (C) 2012-2013 VLC Authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Felix Paul Kühne <fkuehne # videolan # org> * Authors: Felix Paul Kühne <fkuehne # videolan # org>
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
bool handle_event(void *event); bool handle_event(void *event);
protected: protected:
void drawBackground(NPCocoaEvent *cocoaEvent); void drawBackground(CGContextRef cgContext);
void drawNoPlayback(CGContextRef cgContext); void drawNoPlayback(CGContextRef cgContext);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment