diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2005-11-28 02:32:59 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2005-11-28 02:32:59 +0000 |
| commit | bf82503dcba2b12fc921040397a0387d6dea9dbb (patch) | |
| tree | cd7e31bc5991745c30f587b56b77b101dda4baae /lib | |
| parent | 0329b4216112f4591e758ff2407002500abb0bf6 (diff) | |
| download | enigma2-bf82503dcba2b12fc921040397a0387d6dea9dbb.tar.gz enigma2-bf82503dcba2b12fc921040397a0387d6dea9dbb.zip | |
gui: add transparent widgets
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gui/ewidget.cpp | 37 | ||||
| -rw-r--r-- | lib/gui/ewidget.h | 3 | ||||
| -rw-r--r-- | lib/gui/ewidgetdesktop.cpp | 27 |
3 files changed, 47 insertions, 20 deletions
diff --git a/lib/gui/ewidget.cpp b/lib/gui/ewidget.cpp index b047f5fb..b4c24d86 100644 --- a/lib/gui/ewidget.cpp +++ b/lib/gui/ewidget.cpp @@ -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, ®ion, &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; } diff --git a/lib/gui/ewidget.h b/lib/gui/ewidget.h index 879e5eaa..db86fd10 100644 --- a/lib/gui/ewidget.h +++ b/lib/gui/ewidget.h @@ -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: diff --git a/lib/gui/ewidgetdesktop.cpp b/lib/gui/ewidgetdesktop.cpp index afe1995c..c89cd270 100644 --- a/lib/gui/ewidgetdesktop.cpp +++ b/lib/gui/ewidgetdesktop.cpp @@ -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) |
