Merge branch 'master' of git.opendreambox.org:/git/enigma2
[enigma2.git] / lib / gui / ewidget.cpp
index a0a089a6ff114aa9ed68f853b9c3988bfd1aaee5..fea3524c8b717cdc51c70a57748461d4638413d2 100644 (file)
@@ -6,6 +6,7 @@ extern void dumpRegion(const gRegion &region);
 eWidget::eWidget(eWidget *parent): m_animation(this), m_parent(parent ? parent->child() : 0)
 {
        m_vis = 0;
+       m_layer = 0;
        m_desktop = 0;
        m_have_background_color = 0;
        m_z_position = 0;
@@ -53,6 +54,7 @@ void eWidget::resize(eSize size)
                   only once. */
        eSize old_size = m_size;
        eSize old_offset = m_client_offset;
+       m_client_size = size;
        m_client_offset = eSize(0, 0);
        event(evtWillChangeSize, &size, &m_client_offset);
        if (old_size == m_size)
@@ -82,16 +84,20 @@ void eWidget::invalidate(const gRegion &region)
                return;
        eWidget *root = this;
        ePoint abspos = position();
+       int target_layer = m_layer;
+
        while (root && !root->m_desktop)
        {
                root = root->m_parent;
-               assert(root);
+               ASSERT(root);
+               if (root->m_layer != -1)
+                       target_layer = root->m_layer;
                abspos += root->position();
        }
        res.moveBy(abspos);
 //     eDebug("region to invalidate:");
 //     dumpRegion(res);
-       root->m_desktop->invalidate(res);
+       root->m_desktop->invalidate(res, this, target_layer);
 }
 
 void eWidget::show()
@@ -100,12 +106,14 @@ void eWidget::show()
                return;
 
        m_vis |= wVisShow;
-       eDebug("show widget %p", this);
+//     eDebug("show widget %p", this);
        notifyShowHide();
 
                /* TODO: optimize here to only recalc what's required. possibly merge with hide. */
        eWidget *root = this;
        ePoint abspos = position();
+       int target_layer = m_layer;
+
        while (root && !root->m_desktop)
        {
                root = root->m_parent;
@@ -115,9 +123,11 @@ void eWidget::show()
                                        probably somebody already erased the root, but tries some
                                        operations on a child window. 
                                                                        ignore them for now. */
-                       /* assert(root); */
+                       /* ASSERT(root); */
                        return;
                }
+               if (root->m_layer != -1)
+                       target_layer = root->m_layer;
                abspos += root->position();
        }
 
@@ -125,7 +135,7 @@ void eWidget::show()
 
        gRegion abs = m_visible_with_childs;
        abs.moveBy(abspos);
-       root->m_desktop->invalidate(abs);
+       root->m_desktop->invalidate(abs, this, target_layer);
 }
 
 void eWidget::hide()
@@ -153,7 +163,7 @@ void eWidget::hide()
                        return;
                abspos += root->position();
        }
-       assert(root->m_desktop);
+       ASSERT(root->m_desktop);
 
        gRegion abs = m_visible_with_childs;
        abs.moveBy(abspos);
@@ -209,7 +219,7 @@ ePoint eWidget::getAbsolutePosition()
        while (root && !root->m_desktop)
        {
                root = root->m_parent;
-               assert(root);
+               ASSERT(root);
                abspos += root->position();
        }
 
@@ -255,7 +265,7 @@ void eWidget::insertIntoParent()
        }
 }
 
-void eWidget::doPaint(gPainter &painter, const gRegion &r)
+void eWidget::doPaint(gPainter &painter, const gRegion &r, int layer)
 {
        if (m_visible_with_childs.empty())
                return;
@@ -264,17 +274,20 @@ void eWidget::doPaint(gPainter &painter, const gRegion &r)
        region.moveBy(-position());
        painter.moveOffset(position());
                /* check if there's anything for us to paint */
-       region &= m_visible_region;
-       if (!region.empty())
+       if (layer == m_layer)
        {
-               painter.resetClip(region);
-               event(evtPaint, &region, &painter);
+               region &= m_visible_region;
+               if (!region.empty())
+               {
+                       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);
+               i->doPaint(painter, childs, layer);
        painter.moveOffset(-position());
 }
 
@@ -291,7 +304,7 @@ void eWidget::recalcClipRegionsWhenVisible()
                        break;
                }
                t = t->m_parent;
-               assert(t);
+               ASSERT(t);
        } while(1);
 }