From 1ff4fe063846735842ea997d23a137463b307772 Mon Sep 17 00:00:00 2001 From: skyjake Date: Fri, 9 Aug 2013 14:51:46 +0300 Subject: [PATCH] Fixed|Client|UI: Small tweaks to widget animations The style of an animation should be changed after changing its value, as if it is changed before, the value setter will misinterpret the current position of the animation. Also ensured the log widget slides away in the same time span as the task bar is hidden. --- doomsday/client/src/ui/widgets/buttonwidget.cpp | 4 ++-- doomsday/client/src/ui/widgets/consolewidget.cpp | 8 +++++--- doomsday/client/src/ui/widgets/popupwidget.cpp | 4 ++-- doomsday/client/src/ui/widgets/taskbarwidget.cpp | 10 ++++++---- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/doomsday/client/src/ui/widgets/buttonwidget.cpp b/doomsday/client/src/ui/widgets/buttonwidget.cpp index 8cee5fcbc3..ffa4a478e5 100644 --- a/doomsday/client/src/ui/widgets/buttonwidget.cpp +++ b/doomsday/client/src/ui/widgets/buttonwidget.cpp @@ -53,14 +53,14 @@ DENG2_OBSERVES(Action, Triggered) switch(st) { case Up: - scale.setStyle(prev == Down? Animation::Bounce : Animation::EaseOut); scale.setValue(1.f, .3f); + scale.setStyle(prev == Down? Animation::Bounce : Animation::EaseOut); frameOpacity.setValue(.08f, .6f); break; case Hover: - //scale.setStyle(Animation::EaseOut); //scale.setValue(1.1f, .15f); + //scale.setStyle(Animation::EaseOut); frameOpacity.setValue(.4f, .15f); break; diff --git a/doomsday/client/src/ui/widgets/consolewidget.cpp b/doomsday/client/src/ui/widgets/consolewidget.cpp index 408063ee73..ca395c41e0 100644 --- a/doomsday/client/src/ui/widgets/consolewidget.cpp +++ b/doomsday/client/src/ui/widgets/consolewidget.cpp @@ -33,6 +33,8 @@ using namespace de; +static TimeDelta const LOG_OPEN_CLOSE_SPAN = 0.2; + DENG2_PIMPL(ConsoleWidget) { ButtonWidget *button; @@ -100,8 +102,8 @@ DENG2_PIMPL(ConsoleWidget) delta += 2 * log->topMargin(); } - height->setStyle(style); height->set(height->animation().target() + delta, .25f); + height->setStyle(style); if(useOffsetAnimation && opened) { @@ -356,7 +358,7 @@ void ConsoleWidget::openLog() if(d->opened) return; d->opened = true; - d->horizShift->set(0, .3f); + d->horizShift->set(0, LOG_OPEN_CLOSE_SPAN); d->log->unsetBehavior(DisableEventDispatch); } @@ -365,7 +367,7 @@ void ConsoleWidget::closeLog() if(!d->opened) return; d->opened = false; - d->horizShift->set(-rule().width().valuei() - 1, .3f); + d->horizShift->set(-rule().width().valuei() - 1, LOG_OPEN_CLOSE_SPAN); d->log->setBehavior(DisableEventDispatch); } diff --git a/doomsday/client/src/ui/widgets/popupwidget.cpp b/doomsday/client/src/ui/widgets/popupwidget.cpp index c6809771fe..8ad1684b91 100644 --- a/doomsday/client/src/ui/widgets/popupwidget.cpp +++ b/doomsday/client/src/ui/widgets/popupwidget.cpp @@ -218,8 +218,8 @@ DENG2_PIMPL(PopupWidget) self.setBehavior(DisableEventDispatchToChildren); // Begin the closing animation. - openingRule->setStyle(Animation::EaseIn); openingRule->set(0, CLOSING_ANIM_SPAN + delay, delay); + openingRule->setStyle(Animation::EaseIn); self.popupClosing(); @@ -393,7 +393,6 @@ void PopupWidget::open() preparePopupForOpening(); // Start the opening animation. - d->openingRule->setStyle(Animation::Bounce, 8); if(d->dir == ui::Up || d->dir == ui::Down) { d->openingRule->set(d->content->rule().height(), OPENING_ANIM_SPAN); @@ -402,6 +401,7 @@ void PopupWidget::open() { d->openingRule->set(d->content->rule().width(), OPENING_ANIM_SPAN); } + d->openingRule->setStyle(Animation::Bounce, 8); d->opened = true; diff --git a/doomsday/client/src/ui/widgets/taskbarwidget.cpp b/doomsday/client/src/ui/widgets/taskbarwidget.cpp index aac966c4ac..ced444f13b 100644 --- a/doomsday/client/src/ui/widgets/taskbarwidget.cpp +++ b/doomsday/client/src/ui/widgets/taskbarwidget.cpp @@ -42,6 +42,8 @@ using namespace de; using namespace ui; +static TimeDelta OPEN_CLOSE_SPAN = 0.2; + DENG2_PIMPL(TaskBarWidget), DENG2_OBSERVES(Variable, Change), public IGameChangeObserver @@ -426,8 +428,8 @@ void TaskBarWidget::open(bool doAction) d->console->clearLog(); - d->vertShift->set(0, .2f); - setOpacity(1, .2f); + d->vertShift->set(0, OPEN_CLOSE_SPAN); + setOpacity(1, OPEN_CLOSE_SPAN); emit opened(); @@ -467,8 +469,8 @@ void TaskBarWidget::close() // Slide the task bar down. d->vertShift->set(rule().height().valuei() + - style().rules().rule("unit").valuei(), .2f); - setOpacity(0, .2f); + style().rules().rule("unit").valuei(), OPEN_CLOSE_SPAN); + setOpacity(0, OPEN_CLOSE_SPAN); d->console->closeLog(); d->console->closeMenu();