add optional notification of childs when parent moves
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 5 May 2006 00:21:47 +0000 (00:21 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 5 May 2006 00:21:47 +0000 (00:21 +0000)
lib/gui/evideo.cpp
lib/gui/ewidget.cpp
lib/gui/ewidget.h

index 8151e800d6dc0bf7cbea6d496f696c8d0d0e258c..02d8a5293f4c8d5e1954ecdcb4d5d1eadae78983 100644 (file)
@@ -2,6 +2,7 @@
 
 eVideoWidget::eVideoWidget(eWidget *parent): eWidget(parent)
 {
+       parent->setPositionNotifyChild(1);
 }
 
 int eVideoWidget::event(int event, void *data, void *data2)
@@ -10,6 +11,7 @@ int eVideoWidget::event(int event, void *data, void *data2)
        {
        case evtChangedPosition:
        case evtChangedSize:
+       case evtParentChangedPosition:
                eDebug("position is now ...");
                updatePosition();
        }
index 7c50f4af47344d2f0153c36d3de0062a0f19e12d..e05042965b5cfaad310bdf63b1aa68c16104dca2 100644 (file)
@@ -23,6 +23,8 @@ eWidget::eWidget(eWidget *parent): m_animation(this), m_parent(parent ? parent->
 
        m_current_focus = 0;
        m_focus_owner = 0;
+       
+       m_notify_child_on_position_change = 1;
 }
 
 void eWidget::move(ePoint pos)
@@ -38,6 +40,11 @@ void eWidget::move(ePoint pos)
        m_position = pos;
        
        event(evtChangedPosition);
+       
+       if (m_notify_child_on_position_change)
+               for (ePtrList<eWidget>::iterator i(m_childs.begin()); i != m_childs.end(); ++i)
+                       i->event(evtParentChangedPosition);
+               
        recalcClipRegionsWhenVisible();
        
                /* try native move if supported. */
@@ -64,6 +71,11 @@ void eWidget::resize(eSize size)
        
        invalidate();
        event(evtChangedSize);
+
+       if (m_notify_child_on_position_change)
+               for (ePtrList<eWidget>::iterator i(m_childs.begin()); i != m_childs.end(); ++i)
+                       i->event(evtParentChangedPosition); /* position/size is the same here */
+
        recalcClipRegionsWhenVisible(); 
        invalidate();
 }
@@ -340,10 +352,12 @@ int eWidget::event(int event, void *data, void *data2)
                m_size = *static_cast<eSize*>(data);
                break;
        case evtChangedSize:
-       {
                m_clip_region = gRegion(eRect(ePoint(0, 0),  m_size));
                break;
-       }
+       case evtParentChangedPosition:
+               for (ePtrList<eWidget>::iterator i(m_childs.begin()); i != m_childs.end(); ++i)
+                       i->event(evtParentChangedPosition);
+               break;
        case evtFocusGot:
                m_focus_owner = (eWidget*)data;
                break;
index 4175eae7b67739b898a7da195c5bf4ea1517e257..22f5103b0a87cb5071f70f779c72a9a42f892722 100644 (file)
@@ -82,7 +82,7 @@ private:
        eWidget *m_current_focus, *m_focus_owner;
        
        int m_z_position;
-       
+       int m_notify_child_on_position_change;
 protected:
        virtual ~eWidget();
        void mayKillFocus();
@@ -99,6 +99,8 @@ public:
                evtChangedPosition,
                evtChangedSize,
                
+               evtParentChangedPosition,
+               
                evtWillShow,
                evtWillHide,
                evtWillChangePosition, /* new size is eRect *data */
@@ -113,6 +115,9 @@ public:
        };
        virtual int event(int event, void *data = 0, void *data2 = 0);
        void setFocus(eWidget *focus);
+
+               /* enable this if you need the absolute position of the widget */
+       void setPositionNotifyChild(int n) { m_notify_child_on_position_change = 1; }
 };
 
 extern eWidgetDesktop *getDesktop(int which);