gui: add transparent widgets
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 28 Nov 2005 02:32:59 +0000 (02:32 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 28 Nov 2005 02:32:59 +0000 (02:32 +0000)
data/skin.xml
lib/gui/ewidget.cpp
lib/gui/ewidget.h
lib/gui/ewidgetdesktop.cpp
skin.py

index f36874b2341f2d4ec7dd4b0c33d06f70b7fa18c4..1aa5da0928313af52324d0d9b3feb138df1af4dd 100644 (file)
@@ -32,7 +32,7 @@
                                <pixmap pos="bpBottom"      filename="/usr/share/enigma2/b_w_b.png"  />
                                <pixmap pos="bpBottomRight" filename="/usr/share/enigma2/b_w_br.png" />
                        </borderset>
-               </windowstyle> """ """
+               </windowstyle>
                <screen name="Standby" flags="wfNoBorder" position="0,0" size="720,576" title="Standby">
                </screen>
                <screen name="Menu" position="210,150" size="300,235" title="Main menu">
                        <widget name="theClock" position="10,60" size="280,50" />
                </screen>
                <screen name="InfoBar" flags="wfNoBorder" position="0,380" size="720,148" title="InfoBar">
-                       <ePixmap position="0,0" zPosition="1" size="720,148" pixmap="/usr/share/enigma2/info-bg.png" />
+                       <ePixmap position="0,0" zPosition="-1" size="720,148" pixmap="/usr/share/enigma2/info-bg.png" />
                                                
                        <widget name="BlinkingPoint" pixmap="/usr/share/enigma2/record.png" position="430,31" size="58,25" />
 
                        <widget name="Event_Next_Duration" position="555,98" size="70,26" font="Arial;22" backgroundColor="dark" />
 
                        <widget name="ButtonRed" pixmap="/usr/share/enigma2/button_red.png" position="210,132" size="27,12" />
-                       <widget name="ButtonRedText" position="240,132" size="75,22" font="Arial;13" backgroundColor="dark" />
+                       <widget name="ButtonRedText" position="240,132" size="75,22" font="Arial;13" backgroundColor="dark" transparent="1" />
                        <widget name="ButtonGreen" pixmap="/usr/share/enigma2/button_green.png" position="320,132" size="27,12" />
                        <widget name="ButtonYellow" pixmap="/usr/share/enigma2/button_yellow.png" position="430,132" size="27,12" />
                        <widget name="ButtonBlue" pixmap="/usr/share/enigma2/button_blue.png" position="540,132" size="27,12" />
index b047f5fb030efe84d5baede01e6e1f39fcc0db30..b4c24d86e10b9520e3df1cd3740c06c617e04a5a 100644 (file)
@@ -177,6 +177,14 @@ void eWidget::setZPosition(int z)
        insertIntoParent(); /* now at the new Z position */
 }
 
+void eWidget::setTransparent(int transp)
+{
+       if (transp)
+               m_vis |= wVisTransparent;
+       else
+               m_vis &=~wVisTransparent;
+}
+
 void eWidget::mayKillFocus()
 {
        setFocus(0);
@@ -224,14 +232,11 @@ void eWidget::doPaint(gPainter &painter, const gRegion &r)
        if (m_visible_with_childs.empty())
                return;
        
-       gRegion region = r;
+       gRegion region = r, childs = r;
                        /* we were in parent's space, now we are in local space */
        region.moveBy(-position());
        
        painter.moveOffset(position());
-               /* walk all childs */
-       for (ePtrList<eWidget>::iterator i(m_childs.begin()); i != m_childs.end(); ++i)
-               i->doPaint(painter, region);
        
                /* check if there's anything for us to paint */
        region &= m_visible_region;
@@ -241,6 +246,11 @@ void eWidget::doPaint(gPainter &painter, const gRegion &r)
                painter.resetClip(region);
                event(evtPaint, &region, &painter);
        }
+
+       childs.moveBy(-position());
+               /* walk all childs */
+       for (ePtrList<eWidget>::iterator i(m_childs.begin()); i != m_childs.end(); ++i)
+               i->doPaint(painter, childs);
        
        painter.moveOffset(-position());
 }
@@ -272,15 +282,18 @@ int eWidget::event(int event, void *data, void *data2)
                
 //             eDebug("eWidget::evtPaint");
 //             dumpRegion(*(gRegion*)data);
-               if (!m_have_background_color)
-               {
-                       ePtr<eWindowStyle> style;
-                       if (!getStyle(style))
-                               style->paintBackground(painter, ePoint(0, 0), size());
-               } else
+               if (!isTransparent())
                {
-                       painter.setBackgroundColor(m_background_color);
-                       painter.clear();
+                       if (!m_have_background_color)
+                       {
+                               ePtr<eWindowStyle> style;
+                               if (!getStyle(style))
+                                       style->paintBackground(painter, ePoint(0, 0), size());
+                       } else
+                       {
+                               painter.setBackgroundColor(m_background_color);
+                               painter.clear();
+                       }
                }
                break;
        }
index 879e5eaae002dec595df77c6a31378e517924332..db86fd10600be1af162b91abc7ca840caf760c03 100644 (file)
@@ -40,10 +40,13 @@ public:
        void clearBackgroundColor();
        
        void setZPosition(int z);
+       void setTransparent(int transp);
        
                /* untested code */
        int isVisible() { return (m_vis & wVisShow) && ((!m_parent) || m_parent->isVisible()); }
                /* ... */
+               
+       int isTransparent() { return m_vis & wVisTransparent; }
        
        eWidgetAnimation m_animation;
 private:
index afe1995cf16a65e6219af522691bd0042133dab6..c89cd270a0296226fba55039df2611597f0bf213 100644 (file)
@@ -51,10 +51,10 @@ void eWidgetDesktop::calcWidgetClipRegion(eWidget *widget, gRegion &parent_visib
                widget->m_visible_region = widget->m_clip_region;
                widget->m_visible_region.moveBy(widget->position());
                widget->m_visible_region &= parent_visible; // in parent space!
-                       /* TODO: check transparency here! */
 
-                       /* remove everything this widget will contain from parent's visible list */
-               parent_visible -= widget->m_visible_region; // will remove child regions too!
+               if (!widget->isTransparent())
+                               /* remove everything this widget will contain from parent's visible list, unless widget is transparent. */
+                       parent_visible -= widget->m_visible_region; // will remove child regions too!
 
                        /* now prepare for recursing to childs */
                widget->m_visible_region.moveBy(-widget->position());            // now in local space
@@ -63,11 +63,22 @@ void eWidgetDesktop::calcWidgetClipRegion(eWidget *widget, gRegion &parent_visib
 
        widget->m_visible_with_childs = widget->m_visible_region;
        
-       for (ePtrList<eWidget>::iterator i(widget->m_childs.begin()); i != widget->m_childs.end(); ++i)
-               if (i->m_vis & eWidget::wVisShow)
-                       calcWidgetClipRegion(*i, widget->m_visible_region);
-               else
-                       clearVisibility(*i);
+                       /* add childs in reverse (Z) order - we're going from front-to-bottom here. */
+       ePtrList<eWidget>::iterator i(widget->m_childs.end());
+       
+       for (;;)
+       {
+               if (i != widget->m_childs.end())
+               {
+                       if (i->m_vis & eWidget::wVisShow)
+                               calcWidgetClipRegion(*i, widget->m_visible_region);
+                       else
+                               clearVisibility(*i);
+               }
+               if (i == widget->m_childs.begin())
+                       break;
+               --i;
+       }
 }
 
 void eWidgetDesktop::recalcClipRegions(eWidget *root)
diff --git a/skin.py b/skin.py
index a40952041530cfe4428d6eeb5359ab0724896c5b..d11cce02f5ee6101cdf93547795ced9694a67675 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -128,6 +128,8 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                        guiObject.setForegroundColor(parseColor(value))
                elif attrib == "selectionDisabled":
                        guiObject.setSelectionEnable(0)
+               elif attrib == "transparent":
+                       guiObject.setTransparent(int(value))
                elif attrib != 'name':
                        print "unsupported attribute " + attrib + "=" + value
        except int: