Skip to content

Commit

Permalink
Client|UI: Improved popup and popup menu behavior
Browse files Browse the repository at this point in the history
When a popup widget is closing/closed, no events will be dispatched
to its children, i.e., the content widget.

The highlight of a popup menu is now cleared immediately when the
menu is closed.
  • Loading branch information
skyjake committed Jul 1, 2013
1 parent acfa593 commit e9511e1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions doomsday/client/include/ui/widgets/popupmenuwidget.h
Expand Up @@ -37,6 +37,7 @@ class PopupMenuWidget : public PopupWidget
protected:
void glMakeGeometry(DefaultVertexBuf::Builder &verts);
void preparePopupForOpening();
void popupClosing();

private:
DENG2_PRIVATE(d)
Expand Down
3 changes: 3 additions & 0 deletions doomsday/client/include/ui/widgets/popupwidget.h
Expand Up @@ -56,6 +56,8 @@ class PopupWidget : public GuiWidget
*/
void setOpeningDirection(ui::Direction dir);

bool isOpen() const;

// Events.
void viewResized();
void update();
Expand Down Expand Up @@ -92,6 +94,7 @@ public slots:
void glMakeGeometry(DefaultVertexBuf::Builder &verts);

virtual void preparePopupForOpening();
virtual void popupClosing();

private:
DENG2_PRIVATE(d)
Expand Down
3 changes: 2 additions & 1 deletion doomsday/client/src/ui/widgets/guiwidget.cpp
Expand Up @@ -428,7 +428,8 @@ bool GuiWidget::hitTest(Vector2i const &pos) const
GuiWidget const *gui = dynamic_cast<GuiWidget const *>(w);
if(gui)
{
if(gui->behavior().testFlag(ChildHitClipping) && !gui->hitTest(pos))
if(gui->behavior().testFlag(ChildHitClipping) &&
!gui->rule().recti().contains(pos))
{
// Must hit clipped parent widgets as well.
return false;
Expand Down
12 changes: 12 additions & 0 deletions doomsday/client/src/ui/widgets/popupmenuwidget.cpp
Expand Up @@ -132,3 +132,15 @@ void PopupMenuWidget::preparePopupForOpening()
*refless(menu().newColumnWidthRule(0)) + 2 * margin());
menu().updateLayout();
}

void PopupMenuWidget::popupClosing()
{
PopupWidget::popupClosing();

if(d->hover)
{
d->hover->setTextColor("text");
d->hover = 0;
requestGeometry();
}
}
16 changes: 16 additions & 0 deletions doomsday/client/src/ui/widgets/popupwidget.cpp
Expand Up @@ -201,10 +201,14 @@ DENG2_PIMPL(PopupWidget)

opened = false;

self.setBehavior(DisableEventDispatchToChildren);

// Begin the closing animation.
openingRule->setStyle(Animation::EaseIn);
openingRule->set(0, CLOSING_ANIM_SPAN, delay);

self.popupClosing();

emit self.closed();

dismissTimer.start();
Expand Down Expand Up @@ -272,6 +276,11 @@ void PopupWidget::setOpeningDirection(ui::Direction dir)
d->dir = dir;
}

bool PopupWidget::isOpen() const
{
return d->opened;
}

void PopupWidget::viewResized()
{
GuiWidget::viewResized();
Expand Down Expand Up @@ -343,6 +352,8 @@ void PopupWidget::open()
d->realParent->remove(*this);
d->realParent->root().add(this);

unsetBehavior(DisableEventDispatchToChildren);

show();

preparePopupForOpening();
Expand Down Expand Up @@ -413,3 +424,8 @@ void PopupWidget::preparePopupForOpening()
{
d->updateLayout();
}

void PopupWidget::popupClosing()
{
// overridden
}

0 comments on commit e9511e1

Please sign in to comment.