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 8224348332440c19fd5f29bfa51609b4809e1448..e277db346fee874e6e27f381d270324e60be2ab9 100644 (file)
@@ -220,7 +220,12 @@ public:
        void fill(const gRegion &area);
        
        void clear();
        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);
        void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
 
        void setPalette(gRGB *colors, int start=0, int len=256);
index e4e4acc31300ac0f007ec8f6dcdddc65f24891c3..3a377f14c78ad5ee9280fb8870f18d34fd1f82b7 100644 (file)
@@ -2,10 +2,16 @@
 #include <lib/gdi/epng.h>
 #include <lib/gui/ewidgetdesktop.h>
 
 #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;
 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)
                
                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;
        }
                
                return 0;
        }
index 220db1ffc527b6eaede74848446ab6def4841337..ce1e7a56978757461bfd245a1a6a670796d80b50 100644 (file)
@@ -5,11 +5,13 @@
 
 class ePixmap: public eWidget
 {
 
 class ePixmap: public eWidget
 {
+       bool m_alphatest;
 public:
        ePixmap(eWidget *parent);
        
        void setPixmap(gPixmap *pixmap);
        void setPixmapFromFile(const char *filename);
 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);
 protected:
        ePtr<gPixmap> m_pixmap;
        int event(int event, void *data=0, void *data2=0);
diff --git a/skin.py b/skin.py
index dc78c1980b952c8e83baa9ee2b0c53916eb12ace..f5a67185af488c3e2a839642dcb06238d29a7e33 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)
                        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(
                elif attrib == "orientation": # used by eSlider
                        try:
                                guiObject.setOrientation(