diff --git a/doomsday/client/include/ui/widgets/dialogwidget.h b/doomsday/client/include/ui/widgets/dialogwidget.h index 7b03e3834d..a01e2d1e0c 100644 --- a/doomsday/client/include/ui/widgets/dialogwidget.h +++ b/doomsday/client/include/ui/widgets/dialogwidget.h @@ -117,6 +117,7 @@ class DialogWidget : public PopupWidget int exec(GuiRootWidget &root); // Events. + void update(); bool handleEvent(de::Event const &event); public slots: diff --git a/doomsday/client/src/ui/widgets/dialogwidget.cpp b/doomsday/client/src/ui/widgets/dialogwidget.cpp index fe44f42159..6d8af607c5 100644 --- a/doomsday/client/src/ui/widgets/dialogwidget.cpp +++ b/doomsday/client/src/ui/widgets/dialogwidget.cpp @@ -23,10 +23,13 @@ #include "dd_main.h" #include +#include #include using namespace de; +static TimeDelta const FLASH_ANIM_SPAN = 0.75; + static bool dialogButtonOrder(ui::Item const &a, ui::Item const &b) { DialogButtonItem const &left = a.as(); @@ -71,9 +74,18 @@ DENG2_OBSERVES(Widget, ChildAddition) // for styling the contents ScrollAreaWidget *area; MenuWidget *buttons; QEventLoop subloop; + Animation glow; + float normalGlow; + bool animatingGlow; - Instance(Public *i) : Base(i), modality(Modal) + Instance(Public *i) : Base(i), modality(Modal), animatingGlow(false) { + // Initialize the border glow. + normalGlow = self.style().colors().colorf("glow").w; + glow.setValue(normalGlow); + glow.setStyle(Animation::EaseIn); + + // Set up widget structure. GuiWidget *container = new GuiWidget("container"); area = new ScrollAreaWidget("area"); @@ -220,6 +232,24 @@ DENG2_OBSERVES(Widget, ChildAddition) // for styling the contents { return buttons->organizer().itemWidget(item)->as(); } + + void startBorderFlash() + { + animatingGlow = true; + glow.setValueFrom(1, normalGlow, FLASH_ANIM_SPAN); + Background bg = self.background(); + bg.color.w = glow; + self.set(bg); + } + + void updateBorderFlash() + { + Background bg = self.background(); + bg.color.w = glow; + self.set(bg); + + if(glow.done()) animatingGlow = false; + } }; DialogWidget::DialogWidget(String const &name) @@ -271,6 +301,16 @@ int DialogWidget::exec(GuiRootWidget &root) return result; } +void DialogWidget::update() +{ + PopupWidget::update(); + + if(d->animatingGlow) + { + d->updateBorderFlash(); + } +} + bool DialogWidget::handleEvent(Event const &event) { if(event.isKeyDown()) @@ -301,6 +341,11 @@ bool DialogWidget::handleEvent(Event const &event) if(d->modality == Modal) { // The event should already have been handled by the children. + if(event.isKeyDown() || + (event.type() == Event::MouseButton && !hitTest(event.as().pos()))) + { + d->startBorderFlash(); + } return true; } diff --git a/doomsday/client/src/ui/widgets/guiwidget.cpp b/doomsday/client/src/ui/widgets/guiwidget.cpp index 0a09cf3039..e537c24eee 100644 --- a/doomsday/client/src/ui/widgets/guiwidget.cpp +++ b/doomsday/client/src/ui/widgets/guiwidget.cpp @@ -363,6 +363,7 @@ void GuiWidget::deleteLater() void GuiWidget::set(Background const &bg) { d->background = bg; + requestGeometry(); } bool GuiWidget::clipped() const diff --git a/doomsday/client/src/ui/widgets/popupwidget.cpp b/doomsday/client/src/ui/widgets/popupwidget.cpp index 9067ab7385..d84bbfd633 100644 --- a/doomsday/client/src/ui/widgets/popupwidget.cpp +++ b/doomsday/client/src/ui/widgets/popupwidget.cpp @@ -203,7 +203,7 @@ PopupWidget::PopupWidget(String const &name) : d(new Instance(this)) // Initially the popup is hidden. hide(); - // Move these to an updateStyle: + /// @todo Move these to an updateStyle. Style const &st = style(); set(Background(st.colors().colorf("background"), Background::BorderGlow,