From c5f61282a2391235e05ff40bc40a2f0852ea1a9f Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Mon, 28 Nov 2005 00:38:00 +0000 Subject: [PATCH] add support for render pixmaps with transparent background use in skin for ePixmaps alphatest="on" --- lib/gdi/grc.h | 7 ++++++- lib/gui/epixmap.cpp | 10 ++++++++-- lib/gui/epixmap.h | 2 ++ skin.py | 5 +++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h index 82243483..e277db34 100644 --- a/lib/gdi/grc.h +++ b/lib/gdi/grc.h @@ -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); diff --git a/lib/gui/epixmap.cpp b/lib/gui/epixmap.cpp index e4e4acc3..3a377f14 100644 --- a/lib/gui/epixmap.cpp +++ b/lib/gui/epixmap.cpp @@ -2,10 +2,16 @@ #include #include -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; } diff --git a/lib/gui/epixmap.h b/lib/gui/epixmap.h index 220db1ff..ce1e7a56 100644 --- a/lib/gui/epixmap.h +++ b/lib/gui/epixmap.h @@ -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 m_pixmap; int event(int event, void *data=0, void *data2=0); diff --git a/skin.py b/skin.py index dc78c198..f5a67185 100644 --- 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( -- 2.30.2