From c917eef3dc01ada59fc5f3f1e63036ee6fcb5bba Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 13 Jul 2007 16:07:25 +0000 Subject: [PATCH] add 'parent visibility changes' notification and use that to fix video widget --- lib/gui/evideo.cpp | 10 ++++++++-- lib/gui/ewidget.cpp | 11 +++++++++++ lib/gui/ewidget.h | 5 +++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/gui/evideo.cpp b/lib/gui/evideo.cpp index 666fe324..f7f16803 100644 --- a/lib/gui/evideo.cpp +++ b/lib/gui/evideo.cpp @@ -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) diff --git a/lib/gui/ewidget.cpp b/lib/gui/ewidget.cpp index 6d02ebaf..a0a089a6 100644 --- a/lib/gui/ewidget.cpp +++ b/lib/gui/ewidget.cpp @@ -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::iterator i(m_childs.begin()); i != m_childs.end(); ++i) + i->notifyShowHide(); +} diff --git a/lib/gui/ewidget.h b/lib/gui/ewidget.h index 98b30087..a028006c 100644 --- a/lib/gui/ewidget.h +++ b/lib/gui/ewidget.h @@ -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); -- 2.30.2