Commit 1cf8ef54 authored by Felix Paul Kühne's avatar Felix Paul Kühne

add new optional element 'branding' to disable any VLC branding displayed in...

add new optional element 'branding' to disable any VLC branding displayed in the plugin drawing context
parent 53514919
/*****************************************************************************
* Copyright 2002-2011 VideoLAN and VLC authors
* Copyright (C) 2002-2014 VideoLAN and VLC authors
* $Id$
*
* Authors: Sergey Radionov <rsatom@gmail.com>
* Felix Paul Kühne <fkuehne # videolan.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
......@@ -54,7 +55,8 @@ enum vlc_player_option_e
po_show_toolbar,
po_enable_fullscreen,
po_bg_text,
po_bg_color
po_bg_color,
po_enable_branding
};
class vlc_player_options
......@@ -62,7 +64,7 @@ class vlc_player_options
public:
vlc_player_options()
:_autoplay(true), _show_toolbar(true), _enable_fullscreen(true),
_bg_color(/*black*/"#000000")
_bg_color(/*black*/"#000000"), _enable_branding(true)
{}
void set_autoplay(bool ap){
......@@ -102,12 +104,20 @@ public:
return _bg_color;
}
void set_enable_branding(bool st){
_enable_branding = st;
on_option_change(po_enable_branding);
}
bool get_enable_branding() const
{return _enable_branding;}
virtual void on_option_change(vlc_player_option_e ){};
private:
bool _autoplay;
bool _show_toolbar;
bool _enable_fullscreen;
bool _enable_branding;
std::string _bg_text;
//background color format is "#rrggbb"
std::string _bg_color;
......
......@@ -192,6 +192,10 @@ NPError VlcPluginBase::init(int argc, char* const argn[], char* const argv[])
{
set_bg_color( argv[i] );
}
else if( !strcmp( argn[i], "branding" ) )
{
set_enable_branding( boolValue(argv[i]) );
}
}
libvlc_instance = libvlc_new(ppsz_argc, ppsz_argv);
......
......@@ -33,8 +33,6 @@
#include <QuartzCore/QuartzCore.h>
#include <AppKit/AppKit.h>
#define SHOW_BRANDING 1
@interface VLCNoMediaLayer : CALayer {
VlcPluginMac *_cppPlugin;
}
......@@ -499,98 +497,18 @@ bool VlcPluginMac::handle_event(void *event)
HTMLColor2RGB(self.cppPlugin->get_options().get_bg_color().c_str(), &r, &g, &b);
backgroundColor = CGColorCreateGenericRGB(r, g, b, 1.);
#if SHOW_BRANDING
// draw background
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
// draw gradient
CGImageRef gradient = createImageNamed(@"gradient");
CGContextDrawImage(cgContext, CGRectMake(0., 0., windowWidth, 150.), gradient);
CGImageRelease(gradient);
// draw info text
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, CFSTR("VLC Web Plugin"), stylesDict);
CTLineRef textLine = CTLineCreateWithAttributedString(attRef);
CGContextSetTextPosition(cgContext, 25., 60.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
// print smaller text from here
CFRelease(stylesDict);
values[0] = CTFontCreateWithName(CFSTR("Helvetica"),12,NULL);
stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&keys,
(const void **)&values,
2, NULL, NULL);
// draw version string
CFStringRef arch;
#ifdef __x86_64__
arch = CFSTR("64-bit");
#else
arch = CFSTR("32-bit");
#endif
attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s — windowed mode — %@"), libvlc_get_version(), arch), stylesDict);
textLine = CTLineCreateWithAttributedString(attRef);
CGContextSetTextPosition(cgContext, 25., 40.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
CFRelease(stylesDict);
// draw cone
CGImageRef cone = createImageNamed(@"cone");
CGFloat coneWidth = CGImageGetWidth(cone);
CGFloat coneHeight = CGImageGetHeight(cone);
if (windowHeight <= 320.) {
coneWidth = coneWidth / 2.;
coneHeight = coneHeight / 2.;
}
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 = self.cppPlugin->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
// draw a background colored rect
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
const char *text = self.cppPlugin->get_options().get_bg_text().c_str();
if (text != NULL) {
if (self.cppPlugin->get_options().get_enable_branding()) {
// draw background
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
// draw gradient
CGImageRef gradient = createImageNamed(@"gradient");
CGContextDrawImage(cgContext, CGRectMake(0., 0., windowWidth, 150.), gradient);
CGImageRelease(gradient);
// draw info text
CGContextSetGrayStrokeColor(cgContext, .95, 1.);
CGContextSetTextDrawingMode(cgContext, kCGTextFill);
CGContextSetGrayFillColor(cgContext, 1., 1.);
......@@ -604,16 +522,96 @@ bool VlcPluginMac::handle_event(void *event)
(const void **)&keys,
(const void **)&values,
2, NULL, NULL);
CFAttributedStringRef attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithCString(kCFAllocatorDefault, text, kCFStringEncodingUTF8), stylesDict);
CFAttributedStringRef attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFSTR("VLC Web Plugin"), stylesDict);
CTLineRef textLine = CTLineCreateWithAttributedString(attRef);
CGRect textRect = CTLineGetImageBounds(textLine, cgContext);
CGContextSetTextPosition(cgContext, ((windowWidth - textRect.size.width) / 2.), (windowHeight / 2.));
CGContextSetTextPosition(cgContext, 25., 60.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
// print smaller text from here
CFRelease(stylesDict);
values[0] = CTFontCreateWithName(CFSTR("Helvetica"),12,NULL);
stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&keys,
(const void **)&values,
2, NULL, NULL);
// draw version string
CFStringRef arch;
#ifdef __x86_64__
arch = CFSTR("64-bit");
#else
arch = CFSTR("32-bit");
#endif
attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s — windowed mode — %@"), libvlc_get_version(), arch), stylesDict);
textLine = CTLineCreateWithAttributedString(attRef);
CGContextSetTextPosition(cgContext, 25., 40.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
CFRelease(stylesDict);
// draw cone
CGImageRef cone = createImageNamed(@"cone");
CGFloat coneWidth = CGImageGetWidth(cone);
CGFloat coneHeight = CGImageGetHeight(cone);
if (windowHeight <= 320.) {
coneWidth = coneWidth / 2.;
coneHeight = coneHeight / 2.;
}
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 = self.cppPlugin->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 {
// draw a background colored rect
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
const char *text = self.cppPlugin->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);
}
}
#endif
CGColorRelease(backgroundColor);
CGContextRestoreGState(cgContext);
......
......@@ -80,77 +80,77 @@ void VlcWindowlessMac::drawNoPlayback(CGContextRef cgContext)
HTMLColor2RGB(get_options().get_bg_color().c_str(), &r, &g, &b);
backgroundColor = CGColorCreateGenericRGB(r, g, b, 1.);
#if SHOW_BRANDING
// draw background
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
// draw gradient
CGImageRef gradient = createImageNamed(CFSTR("gradient"));
CGContextDrawImage(cgContext, CGRectMake(0., 0., windowWidth, 150.), gradient);
CGImageRelease(gradient);
// draw info text
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, CFSTR("VLC Web Plugin"), stylesDict);
CTLineRef textLine = CTLineCreateWithAttributedString(attRef);
CGContextSetTextPosition(cgContext, 25., 45.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
// print smaller text from here
CFRelease(stylesDict);
values[0] = CTFontCreateWithName(CFSTR("Helvetica"),12,NULL);
stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&keys,
(const void **)&values,
2, NULL, NULL);
// draw version string
CFStringRef arch;
#ifdef __x86_64__
arch = CFSTR("64-bit");
#else
arch = CFSTR("32-bit");
#endif
attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s — windowless mode — %@"), libvlc_get_version(), arch), stylesDict);
textLine = CTLineCreateWithAttributedString(attRef);
CGContextSetTextPosition(cgContext, 25., 25.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
CFRelease(stylesDict);
// draw cone
CGImageRef cone = createImageNamed(CFSTR("cone"));
CGFloat coneWidth = CGImageGetWidth(cone);
CGFloat coneHeight = CGImageGetHeight(cone);
if (windowHeight <= 320.) {
coneWidth = coneWidth / 2.;
coneHeight = coneHeight / 2.;
if (get_options().get_enable_branding()) {
// draw background
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
// draw gradient
CGImageRef gradient = createImageNamed(CFSTR("gradient"));
CGContextDrawImage(cgContext, CGRectMake(0., 0., windowWidth, 150.), gradient);
CGImageRelease(gradient);
// draw info text
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, CFSTR("VLC Web Plugin"), stylesDict);
CTLineRef textLine = CTLineCreateWithAttributedString(attRef);
CGContextSetTextPosition(cgContext, 25., 45.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
// print smaller text from here
CFRelease(stylesDict);
values[0] = CTFontCreateWithName(CFSTR("Helvetica"),12,NULL);
stylesDict = CFDictionaryCreate(kCFAllocatorDefault,
(const void **)&keys,
(const void **)&values,
2, NULL, NULL);
// draw version string
CFStringRef arch;
#ifdef __x86_64__
arch = CFSTR("64-bit");
#else
arch = CFSTR("32-bit");
#endif
attRef = CFAttributedStringCreate(kCFAllocatorDefault, CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s — windowless mode — %@"), libvlc_get_version(), arch), stylesDict);
textLine = CTLineCreateWithAttributedString(attRef);
CGContextSetTextPosition(cgContext, 25., 25.);
CTLineDraw(textLine, cgContext);
CFRelease(textLine);
CFRelease(attRef);
CFRelease(stylesDict);
// draw cone
CGImageRef cone = createImageNamed(CFSTR("cone"));
CGFloat coneWidth = CGImageGetWidth(cone);
CGFloat coneHeight = CGImageGetHeight(cone);
if (windowHeight <= 320.) {
coneWidth = coneWidth / 2.;
coneHeight = coneHeight / 2.;
}
CGContextDrawImage(cgContext, CGRectMake((windowWidth - coneWidth) / 2., (windowHeight - coneHeight) / 2., coneWidth, coneHeight), cone);
CGImageRelease(cone);
} else {
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
}
CGContextDrawImage(cgContext, CGRectMake((windowWidth - coneWidth) / 2., (windowHeight - coneHeight) / 2., coneWidth, coneHeight), cone);
CGImageRelease(cone);
#else
CGContextAddRect(cgContext, CGRectMake(0, 0, windowWidth, windowHeight));
CGContextSetFillColorWithColor(cgContext, backgroundColor);
CGContextDrawPath(cgContext, kCGPathFill);
#endif
CGColorRelease(backgroundColor);
CGContextRestoreGState(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