add 'parent visibility changes' notification and use that to fix video widget
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 13 Jul 2007 16:07:25 +0000 (16:07 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 13 Jul 2007 16:07:25 +0000 (16:07 +0000)
lib/gui/evideo.cpp
lib/gui/ewidget.cpp
lib/gui/ewidget.h

index 666fe32..f7f1680 100644 (file)
@@ -13,8 +13,9 @@ int eVideoWidget::event(int event, void *data, void *data2)
        case evtChangedPosition:
        case evtChangedSize:
        case evtParentChangedPosition:
-               eDebug("position is now ...");
-               updatePosition();
+       case evtParentVisibilityChanged:
+               updatePosition(!isVisible());
+               break;
        }
        return eWidget::event(event, data, data2);
 }
@@ -30,6 +31,11 @@ void eVideoWidget::updatePosition(int disable)
        if (!disable)
                pos = eRect(getAbsolutePosition(), size());
 
+       if (m_cur_pos == pos)
+               return;
+
+       m_cur_pos = pos;
+
        eDebug("position is %d %d -> %d %d", pos.left(), pos.top(), pos.width(), pos.height());
 
        for (int i=0; i<4; ++i)
index 6d02eba..a0a089a 100644 (file)
@@ -100,6 +100,9 @@ void eWidget::show()
                return;
 
        m_vis |= wVisShow;
+       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();
@@ -133,10 +136,12 @@ void eWidget::hide()
        if (!(m_vis & wVisShow))
                return;
        m_vis &= ~wVisShow;
+
                /* this is a workaround to the above problem. when we are in the delete phase, 
                   don't hide childs. */
        if (!(m_parent || m_desktop))
                return;
+       notifyShowHide();
 
                /* TODO: optimize here to only recalc what's required. possibly merge with show. */
        eWidget *root = this;
@@ -361,3 +366,9 @@ void eWidget::setFocus(eWidget *focus)
                m_current_focus->event(evtFocusGot, this);
 }
 
+void eWidget::notifyShowHide()
+{
+       event(evtParentVisibilityChanged);
+       for (ePtrList<eWidget>::iterator i(m_childs.begin()); i != m_childs.end(); ++i)
+               i->notifyShowHide();
+}
index 98b3008..a028006 100644 (file)
@@ -101,8 +101,7 @@ public:
                
                evtParentChangedPosition,
                
-               evtWillShow,
-               evtWillHide,
+               evtParentVisibilityChanged,
                evtWillChangePosition, /* new size is eRect *data */
                evtWillChangeSize,
                
@@ -118,6 +117,8 @@ public:
 
                /* enable this if you need the absolute position of the widget */
        void setPositionNotifyChild(int n) { m_notify_child_on_position_change = 1; }
+
+       void notifyShowHide();
 };
 
 extern eWidgetDesktop *getDesktop(int which);