From: Felix Domke Date: Sun, 17 Apr 2005 20:01:28 +0000 (+0000) Subject: - load palette from png X-Git-Tag: 2.6.0~5910 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/78c828aae07db0b15a66577d9230cb848fe536fa - load palette from png - named color support --- diff --git a/components.py b/components.py index abf25f20..deb3760c 100644 --- a/components.py +++ b/components.py @@ -348,7 +348,8 @@ class ServiceScan: print "*** warning *** scan was not finished!" def isDone(self): - return self.state == self.Done + print "state is %d " % (self.state) + return self.state == self.Done or self.state == self.Error class ActionMap: def __init__(self, contexts = [ ], actions = { }, prio=0): @@ -406,12 +407,12 @@ class EventInfo(PerServiceDisplay): def __init__(self, navcore, now_or_next): # listen to evUpdatedEventInfo and evStopService # note that evStopService will be called once to establish a known state + self.now_or_next = now_or_next PerServiceDisplay.__init__(self, navcore, { pNavigation.evUpdatedEventInfo: self.ourEvent, pNavigation.evStopService: self.stopEvent }) - self.now_or_next = now_or_next def ourEvent(self): info = iServiceInformationPtr() @@ -428,7 +429,8 @@ class EventInfo(PerServiceDisplay): print "new event info in EventInfo! yeah!" def stopEvent(self): - self.setText("waiting for event data..."); + self.setText( + ("waiting for event data...", "", "--:--", "--:--")[self.now_or_next]); class ServiceName(PerServiceDisplay): def __init__(self, navcore): diff --git a/lib/gdi/gpixmap.cpp b/lib/gdi/gpixmap.cpp index e9c469c4..9e8219a5 100644 --- a/lib/gdi/gpixmap.cpp +++ b/lib/gdi/gpixmap.cpp @@ -388,6 +388,8 @@ gColor gPalette::findColor(const gRGB &rgb) const ttd+=td; if (ttd>=difference) continue; + if (!ttd) + return t; difference=ttd; best_choice=t; } diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index 9cb1a072..756ed9b7 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -240,6 +240,12 @@ void gPainter::setPalette(gRGB *colors, int start, int len) m_rc->submit(o); } +void gPainter::setPalette(gPixmap *source) +{ + ASSERT(source); + setPalette(source->surface->clut.data, source->surface->clut.start, source->surface->clut.colors); +} + void gPainter::mergePalette(gPixmap *target) { gOpcode o; diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h index 57439178..53bf7f09 100644 --- a/lib/gdi/grc.h +++ b/lib/gdi/grc.h @@ -215,6 +215,7 @@ public: void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0); void setPalette(gRGB *colors, int start=0, int len=256); + void setPalette(gPixmap *source); void mergePalette(gPixmap *target); void line(ePoint start, ePoint end); diff --git a/lib/gui/ewidgetdesktop.cpp b/lib/gui/ewidgetdesktop.cpp index 8c489eb3..24fb334b 100644 --- a/lib/gui/ewidgetdesktop.cpp +++ b/lib/gui/ewidgetdesktop.cpp @@ -55,7 +55,7 @@ void eWidgetDesktop::invalidate(const gRegion ®ion) m_dirty_region |= region; } -void eWidgetDesktop::setBackgroundColor(gColor col) +void eWidgetDesktop::setBackgroundColor(gRGB col) { m_background_color = col; @@ -70,6 +70,13 @@ void eWidgetDesktop::setBackgroundColor(gColor col) } } +void eWidgetDesktop::setPalette(gPixmap &pm) +{ + ASSERT(m_dc); + gPainter painter(m_dc); + painter.setPalette(&pm); +} + void eWidgetDesktop::paint() { gPainter painter(m_dc); diff --git a/lib/gui/ewidgetdesktop.h b/lib/gui/ewidgetdesktop.h index 22914ec5..c917e36a 100644 --- a/lib/gui/ewidgetdesktop.h +++ b/lib/gui/ewidgetdesktop.h @@ -15,7 +15,7 @@ public: // weil debug gRegion m_dirty_region; gRegion m_background_region; ePtr m_dc; - gColor m_background_color; + gRGB m_background_color; public: eWidgetDesktop(eSize screen); ~eWidgetDesktop(); @@ -27,7 +27,9 @@ public: void paint(); void setDC(gDC *dc); - void setBackgroundColor(gColor col); + void setBackgroundColor(gRGB col); + + void setPalette(gPixmap &pm); void setRedrawTask(eMainloop &ml); diff --git a/lib/gui/ewindowstyleskinned.cpp b/lib/gui/ewindowstyleskinned.cpp index a3152e5f..55092e1d 100644 --- a/lib/gui/ewindowstyleskinned.cpp +++ b/lib/gui/ewindowstyleskinned.cpp @@ -8,7 +8,9 @@ DEFINE_REF(eWindowStyleSkinned); eWindowStyleSkinned::eWindowStyleSkinned() { - m_background_color = gRGB(0x808080); + // m_background_color = gRGB(0x808080); + + // TODO: initialize colors!! } void eWindowStyleSkinned::handleNewSize(eWindow *wnd, eSize &size, eSize &offset) @@ -37,7 +39,7 @@ void eWindowStyleSkinned::paintWindowDecoration(eWindow *wnd, gPainter &painter, void eWindowStyleSkinned::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size) { - painter.setBackgroundColor(m_background_color); + painter.setBackgroundColor(m_color[colBackground]); painter.clear(); } @@ -46,19 +48,19 @@ void eWindowStyleSkinned::setStyle(gPainter &painter, int what) switch (what) { case styleLabel: - painter.setForegroundColor(gColor(0x1F)); + painter.setForegroundColor(m_color[colLabelForeground]); break; case styleListboxSelected: - painter.setForegroundColor(gColor(0x1F)); - painter.setBackgroundColor(gColor(0x1A)); + painter.setForegroundColor(m_color[colListboxSelectedForeground]); + painter.setBackgroundColor(m_color[colListboxSelectedBackground]); break; case styleListboxNormal: - painter.setForegroundColor(gColor(0x1C)); - painter.setBackgroundColor(m_background_color); + painter.setForegroundColor(m_color[colListboxForeground]); + painter.setBackgroundColor(m_color[colListboxBackground]); break; case styleListboxMarked: - painter.setForegroundColor(gColor(0x2F)); - painter.setBackgroundColor(gColor(0x2A)); + painter.setForegroundColor(m_color[colListboxMarkedForeground]); + painter.setBackgroundColor(m_color[colListboxMarkedBackground]); break; } } @@ -240,9 +242,9 @@ void eWindowStyleSkinned::setPixmap(int bs, int bp, gPixmap &pixmap) m_border[bs].m_border_right, m_border[bs].m_border_bottom); } -void eWindowStyleSkinned::setDefaultBackgroundColor(const gRGB &back) +void eWindowStyleSkinned::setColor(int what, const gRGB &col) { - m_background_color = back; - eDebug("set default background color!"); + if ((what < colMax) && (what >= 0)) + m_color[what] = col; } diff --git a/lib/gui/ewindowstyleskinned.h b/lib/gui/ewindowstyleskinned.h index 79557386..bc9c0549 100644 --- a/lib/gui/ewindowstyleskinned.h +++ b/lib/gui/ewindowstyleskinned.h @@ -52,7 +52,19 @@ public: void setPixmap(int bs, int bp, gPixmap &pixmap); - void setDefaultBackgroundColor(const gRGB &back); + enum { + colBackground, + colLabelForeground, + colListboxBackground, + colListboxForeground, + colListboxSelectedBackground, + colListboxSelectedForeground, + colListboxMarkedBackground, + colListboxMarkedForeground, + colMax + }; + + void setColor(int what, const gRGB &back); private: struct borderSet @@ -63,7 +75,7 @@ private: borderSet m_border[bsMax]; - gRGB m_background_color; + gRGB m_color[colMax]; void drawBorder(gPainter &painter, const eRect &size, struct borderSet &border, int where); }; diff --git a/screens.py b/screens.py index 77d064f5..999ad4bf 100644 --- a/screens.py +++ b/screens.py @@ -162,6 +162,7 @@ class clockDisplay(Screen): class serviceScan(Screen): def ok(self): + print "ok" if self["scan"].isDone(): self.close() diff --git a/skin.py b/skin.py index 73d4b02d..2986a447 100644 --- a/skin.py +++ b/skin.py @@ -2,6 +2,9 @@ from enigma import * import xml.dom.minidom from xml.dom import EMPTY_NAMESPACE + +colorNames = dict() + def dump(x, i=0): print " " * i + str(x) try: @@ -12,8 +15,21 @@ def dump(x, i=0): dom = xml.dom.minidom.parseString( """ + + + + + + - + + + + + + + + @@ -36,14 +52,14 @@ dom = xml.dom.minidom.parseString( - + - - - - - - + + + + + + @@ -86,7 +102,10 @@ def parseFont(str): def parseColor(str): if str[0] != '#': - raise "color must be #aarrggbb" + try: + return colorNames[str] + except: + raise ("color '%s' must be #aarrggbb or valid named color" % (str)) return gRGB(int(str[1:], 0x10)) def applyAttributes(guiObject, node, desktop): @@ -168,6 +187,16 @@ def loadSkin(): skin = dom.childNodes[0] assert skin.tagName == "skin", "root element in skin must be 'skin'!" + for c in elementsWithTag(skin.childNodes, "colors"): + for color in elementsWithTag(c.childNodes, "color"): + name = str(color.getAttribute("name")) + color = str(color.getAttribute("value")) + + if not len(color): + raise ("need color and name, got %s %s" % (name, color)) + + colorNames[name] = parseColor(color) + for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"): style = eWindowStyleSkinned() @@ -183,10 +212,10 @@ def loadSkin(): type = str(color.getAttribute("name")) color = parseColor(color.getAttribute("color")) - if type == "defaultBackground": - style.setDefaultBackgroundColor(color) - else: - raise "unknown color %s" % (type) + try: + style.setColor(eWindowStyleSkinned.__dict__["col" + type], color) + except: + raise ("Unknown color %s" % (type)) x = eWindowStyleManagerPtr() eWindowStyleManager.getInstance(x)