Skip to content

Commit

Permalink
Fixed|Client|UI: Small tweaks to widget animations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skyjake committed Aug 9, 2013
1 parent 57de87f commit 1ff4fe0
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/widgets/buttonwidget.cpp
Expand Up @@ -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;

Expand Down
8 changes: 5 additions & 3 deletions doomsday/client/src/ui/widgets/consolewidget.cpp
Expand Up @@ -33,6 +33,8 @@

using namespace de;

static TimeDelta const LOG_OPEN_CLOSE_SPAN = 0.2;

DENG2_PIMPL(ConsoleWidget)
{
ButtonWidget *button;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions doomsday/client/src/ui/widgets/popupwidget.cpp
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down
10 changes: 6 additions & 4 deletions doomsday/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1ff4fe0

Please sign in to comment.