add support for render pixmaps with transparent background
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 28 Nov 2005 00:38:00 +0000 (00:38 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 28 Nov 2005 00:38:00 +0000 (00:38 +0000)
use in skin for ePixmaps alphatest="on"

lib/gdi/grc.h
lib/gui/epixmap.cpp
lib/gui/epixmap.h
skin.py

index 8224348..e277db3 100644 (file)
@@ -220,7 +220,12 @@ public:
        void fill(const gRegion &area);
        
        void clear();
-       
+
+       enum
+       {
+               BT_ALPHATEST = 1
+       };
+
        void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
 
        void setPalette(gRGB *colors, int start=0, int len=256);
index e4e4acc..3a377f1 100644 (file)
@@ -2,10 +2,16 @@
 #include <lib/gdi/epng.h>
 #include <lib/gui/ewidgetdesktop.h>
 
-ePixmap::ePixmap(eWidget *parent): eWidget(parent)
+ePixmap::ePixmap(eWidget *parent)
+       :eWidget(parent), m_alphatest(false)
 {
 }
 
+void ePixmap::setAlphatest(bool alphatest)
+{
+       m_alphatest = alphatest;
+}
+
 void ePixmap::setPixmap(gPixmap *pixmap)
 {
        m_pixmap = pixmap;
@@ -35,7 +41,7 @@ int ePixmap::event(int event, void *data, void *data2)
                
                gPainter &painter = *(gPainter*)data2;
                if (m_pixmap)
-                       painter.blit(m_pixmap, ePoint(0, 0));
+                       painter.blit(m_pixmap, ePoint(0, 0), eRect(), m_alphatest?gPainter::BT_ALPHATEST:0);
                
                return 0;
        }
index 220db1f..ce1e7a5 100644 (file)
@@ -5,11 +5,13 @@
 
 class ePixmap: public eWidget
 {
+       bool m_alphatest;
 public:
        ePixmap(eWidget *parent);
        
        void setPixmap(gPixmap *pixmap);
        void setPixmapFromFile(const char *filename);
+       void setAlphatest(bool alphatest);
 protected:
        ePtr<gPixmap> m_pixmap;
        int event(int event, void *data=0, void *data2=0);
diff --git a/skin.py b/skin.py
index dc78c19..f5a6718 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -82,6 +82,11 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                        desktop.makeCompatiblePixmap(ptr)
                        guiObject.setPixmap(ptr)
                        # guiObject.setPixmapFromFile(value)
+               elif attrib == "alphatest": # used by ePixmap
+                       guiObject.setAlphatest(
+                               { "on": True,
+                                 "off": False
+                               }[value])
                elif attrib == "orientation": # used by eSlider
                        try:
                                guiObject.setOrientation(