From: Felix Domke Date: Fri, 5 May 2006 00:21:47 +0000 (+0000) Subject: add optional notification of childs when parent moves X-Git-Tag: 2.6.0~3492 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/d73219bf587818d7648531da574beb45f6e3c000 add optional notification of childs when parent moves --- diff --git a/lib/gui/evideo.cpp b/lib/gui/evideo.cpp index 8151e800..02d8a529 100644 --- a/lib/gui/evideo.cpp +++ b/lib/gui/evideo.cpp @@ -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(); } diff --git a/lib/gui/ewidget.cpp b/lib/gui/ewidget.cpp index 7c50f4af..e0504296 100644 --- a/lib/gui/ewidget.cpp +++ b/lib/gui/ewidget.cpp @@ -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::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::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(data); break; case evtChangedSize: - { m_clip_region = gRegion(eRect(ePoint(0, 0), m_size)); break; - } + case evtParentChangedPosition: + for (ePtrList::iterator i(m_childs.begin()); i != m_childs.end(); ++i) + i->event(evtParentChangedPosition); + break; case evtFocusGot: m_focus_owner = (eWidget*)data; break; diff --git a/lib/gui/ewidget.h b/lib/gui/ewidget.h index 4175eae7..22f5103b 100644 --- a/lib/gui/ewidget.h +++ b/lib/gui/ewidget.h @@ -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);