From 3f71f581949b23c013b07a266e9aae0edd102a53 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 27 May 2009 23:45:01 +0200 Subject: [PATCH] make subtitle font styles skinnable --- data/skin.xml | 8 ++++++++ lib/gui/esubtitle.cpp | 49 ++++++++++++++++++++++++++++++---------------- lib/gui/esubtitle.h | 24 ++++++++++++++++++++--- lib/python/enigma_python.i | 2 ++ skin.py | 35 ++++++++++++++++++++++++++------- tests/enigma.py | 1 + 6 files changed, 92 insertions(+), 27 deletions(-) diff --git a/data/skin.xml b/data/skin.xml index ca1e97d..1592330 100755 --- a/data/skin.xml +++ b/data/skin.xml @@ -69,6 +69,14 @@ + + + + + + + + diff --git a/lib/gui/esubtitle.cpp b/lib/gui/esubtitle.cpp index ca5c20d..376fa24 100644 --- a/lib/gui/esubtitle.cpp +++ b/lib/gui/esubtitle.cpp @@ -10,6 +10,8 @@ .... */ +eSubtitleWidget::eSubtitleStyle eSubtitleWidget::subtitleStyles[Subtitle_MAX]; + eSubtitleWidget::eSubtitleWidget(eWidget *parent) : eWidget(parent), m_hide_subtitles_timer(eTimer::create(eApp)) { @@ -131,42 +133,42 @@ int eSubtitleWidget::event(int event, void *data, void *data2) else if (m_page_ok) { int elements = m_page.m_elements.size(); - ePtr font = new gFont("Regular", 38); - painter.setFont(font); + painter.setFont(subtitleStyles[Subtitle_TTX].font); for (int i=0; i font = new gFont("Regular", 38); + subfont_t face; + for (int i=0; i &pixmap, gRegion changed); + + typedef enum { Subtitle_TTX, Subtitle_Regular, Subtitle_Bold, Subtitle_Italic, Subtitle_MAX } subfont_t; + struct eSubtitleStyle + { + subfont_t face; + int have_foreground_color, have_shadow_color; + gRGB foreground_color, shadow_color; + ePoint shadow_offset; + ePtr font; + }; + + static void setFontStyle(subfont_t face, gFont *font, int autoColor, const gRGB &col, const gRGB &shadowCol, const ePoint &shadowOffset); + protected: int event(int event, void *data=0, void *data2=0); - private: int m_page_ok; eDVBTeletextSubtitlePage m_page; @@ -56,6 +72,8 @@ private: gRegion m_visible_region; + static eSubtitleStyle subtitleStyles[Subtitle_MAX]; + ePtr m_pixmap; // pixmap to paint on next evtPaint }; diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index fe0e71e..2fec2ff 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -69,6 +69,7 @@ is usually caused by not marking PSignals as immutable. #include #include #include +#include #include #include #include @@ -183,6 +184,7 @@ typedef long time_t; %include %include %include +%include %include %include %include diff --git a/skin.py b/skin.py index a37716f..d44e503 100644 --- a/skin.py +++ b/skin.py @@ -6,7 +6,6 @@ from os import path profile("LOAD:enigma_skin") from enigma import eSize, ePoint, gFont, eWindow, eLabel, ePixmap, eWindowStyleManager, \ addFont, gRGB, eWindowStyleSkinned - from Components.config import ConfigSubsection, ConfigText, config from Components.Converter.Converter import Converter from Components.Sources.Source import Source, ObsoleteSource @@ -298,6 +297,28 @@ def loadSingleSkinData(desktop, skin, path_prefix): addFont(resolved_font, name, scale, is_replacement) #print "Font: ", resolved_font, name, scale, is_replacement + for c in skin.findall("subtitles"): + from enigma import eWidget, eSubtitleWidget + scale = ((1,1),(1,1)) + for substyle in c.findall("sub"): + get_attr = substyle.attrib.get + font = parseFont(get_attr("font"), scale) + col = get_attr("foregroundColor") + if col: + foregroundColor = parseColor(col) + haveColor = 1 + else: + foregroundColor = gRGB(0xFFFFFF) + haveColor = 0 + col = get_attr("shadowColor") + if col: + shadowColor = parseColor(col) + else: + shadowColor = gRGB(0) + shadowOffset = parsePosition(get_attr("shadowOffset"), scale) + face = eval("eSubtitleWidget.%s" % get_attr("name")) + eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset) + for windowstyle in skin.findall("windowstyle"): style = eWindowStyleSkinned() id = windowstyle.attrib.get("id") @@ -333,12 +354,12 @@ def loadSingleSkinData(desktop, skin, path_prefix): for color in windowstyle.findall("color"): get_attr = color.attrib.get - type = get_attr("name") + colorType = get_attr("name") color = parseColor(get_attr("color")) try: - style.setColor(eWindowStyleSkinned.__dict__["col" + type], color) + style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color) except: - raise SkinError("Unknown color %s" % (type)) + raise SkinError("Unknown color %s" % (colorType)) #pass #print " color:", type, color @@ -528,15 +549,15 @@ def readSkin(screen, skin, names, desktop): #print "Found code:" #print codeText - type = widget.attrib.get('type') + widgetType = widget.attrib.get('type') code = compile(codeText, "skin applet", "exec") - if type == "onLayoutFinish": + if widgetType == "onLayoutFinish": screen.onLayoutFinish.append(code) #print "onLayoutFinish = ", codeText else: - raise SkinError("applet type '%s' unknown!" % type) + raise SkinError("applet type '%s' unknown!" % widgetType) #print "applet type '%s' unknown!" % type continue diff --git a/tests/enigma.py b/tests/enigma.py index 2bf2a59..e82aa49 100644 --- a/tests/enigma.py +++ b/tests/enigma.py @@ -96,6 +96,7 @@ eWindowStyleSkinned = None eButton = None eListboxPythonStringContent = None eListbox = None +eSubtitleWidget = None class eEPGCache: @classmethod -- 2.7.4