Skip to content

Commit

Permalink
UI|Widgets|libappfw: Minor UI tweaks and fixes
Browse files Browse the repository at this point in the history
PanelWidget was not waiting for assets because it wasn’t using the
new IAssetGroup interface.

Home items should not animate from zero height when they first appear.

Make sure bundles get identified at startup.
  • Loading branch information
skyjake committed Nov 19, 2016
1 parent d52b604 commit 8c278bb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 20 deletions.
1 change: 1 addition & 0 deletions doomsday/apps/client/src/ui/dialogs/packagesdialog.cpp
Expand Up @@ -21,6 +21,7 @@
#include "ui/widgets/homeitemwidget.h"
#include "ui/widgets/homemenuwidget.h"
#include "ui/widgets/packagepopupwidget.h"
#include "ui/clientwindow.h"
#include "clientapp.h"

#include <doomsday/Games>
Expand Down
1 change: 1 addition & 0 deletions doomsday/apps/libdoomsday/src/resource/bundles.cpp
Expand Up @@ -213,6 +213,7 @@ bool Bundles::isEverythingIdentified() const

void Bundles::waitForEverythingIdentified()
{
identify();
d->tasks.waitForDone();
}

Expand Down
2 changes: 1 addition & 1 deletion doomsday/sdk/libappfw/src/widgets/dialogwidget.cpp
Expand Up @@ -112,7 +112,7 @@ DENG_GUI_PIMPL(DialogWidget)
, needButtonUpdate(false)
, animatingGlow(false)
{
minWidth = new IndirectRule;
minWidth = new IndirectRule;

// Initialize the border glow.
normalGlow = style().colors().colorf("glow").w;
Expand Down
18 changes: 11 additions & 7 deletions doomsday/sdk/libappfw/src/widgets/panelwidget.cpp
Expand Up @@ -154,22 +154,26 @@ DENG_GUI_PIMPL(PanelWidget)
dismissTimer.setInterval((CLOSING_ANIM_SPAN + delay).asMilliSeconds());
}

void findAssets(Widget const *widget)
void findAssets(Widget *widget)
{
if (Asset const *asset = widget->maybeAs<Asset>())
//qDebug() << "checking if" << widget << "is an asset to wait for...";

if (auto *assetGroup = widget->maybeAs<IAssetGroup>())
{
if (!asset->isReady())
if (!assetGroup->assets().isReady())
{
*pendingShow += *asset;
*pendingShow += *assetGroup;

LOGDEV_XVERBOSE("Found " _E(m) "NotReady" _E(.) " asset %s (%p)")
<< widget->path() << widget;
}
}

foreach (Widget const *child, widget->children())
else
{
findAssets(child);
foreach (Widget *child, widget->children())
{
findAssets(child);
}
}
}

Expand Down
19 changes: 14 additions & 5 deletions doomsday/sdk/libcore/include/de/widgets/animationrule.h
Expand Up @@ -25,6 +25,8 @@
#include "../Animation"
#include "../Time"

#include <QFlags>

namespace de {

/**
Expand Down Expand Up @@ -60,7 +62,12 @@ class DENG2_PUBLIC AnimationRule : public Rule, DENG2_OBSERVES(Clock, TimeChange

void setStyle(Animation::Style style, float bounceSpring);

enum Behavior { Singleshot, RestartWhenTargetChanges };
enum Behavior {
Singleshot = 0x1,
RestartWhenTargetChanges = 0x2,
DontAnimateFromZero = 0x4,
};
Q_DECLARE_FLAGS(Behaviors, Behavior)

/**
* Sets the behavior for updating the animation target. The default is Singleshot,
Expand All @@ -70,9 +77,9 @@ class DENG2_PUBLIC AnimationRule : public Rule, DENG2_OBSERVES(Clock, TimeChange
*
* @param behavior Target update behavior.
*/
void setBehavior(Behavior behavior);
void setBehavior(Behaviors behavior);

Behavior behavior() const;
Behaviors behavior() const;

/**
* Read-only access to the scalar animation.
Expand Down Expand Up @@ -106,9 +113,11 @@ class DENG2_PUBLIC AnimationRule : public Rule, DENG2_OBSERVES(Clock, TimeChange
private:
Animation _animation;
Rule const *_targetRule;
Behavior _behavior;
Behaviors _behavior;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(AnimationRule::Behaviors)

} // namespace de

#endif // LIBDENG2_ANIMAITONRULE_H
#endif // LIBDENG2_ANIMATIONRULE_H
17 changes: 10 additions & 7 deletions doomsday/sdk/libcore/src/widgets/animationrule.cpp
Expand Up @@ -34,7 +34,7 @@ AnimationRule::AnimationRule(Rule const &target, TimeDelta transition, Animation
: Rule(target.value())
, _animation(target.value(), style)
, _targetRule(0)
, _behavior(RestartWhenTargetChanges)
, _behavior(RestartWhenTargetChanges | DontAnimateFromZero)
{
set(target, transition);
}
Expand Down Expand Up @@ -74,12 +74,12 @@ void AnimationRule::setStyle(Animation::Style style, float bounceSpring)
_animation.setStyle(style, bounceSpring);
}

void AnimationRule::setBehavior(Behavior behavior)
void AnimationRule::setBehavior(Behaviors behavior)
{
_behavior = behavior;
}

AnimationRule::Behavior AnimationRule::behavior() const
AnimationRule::Behaviors AnimationRule::behavior() const
{
return _behavior;
}
Expand Down Expand Up @@ -120,9 +120,7 @@ void AnimationRule::update()
// When using a rule for the target, keep it updated.
if (_targetRule)
{
if (_behavior == Singleshot || !_animation.done() /*||
fequal(_animation.target(), 0) || // Don't animate to/from zero.
fequal(_targetRule->value(), 0)*/)
if (_behavior.testFlag(Singleshot) || !_animation.done())
{
_animation.adjustTarget(_targetRule->value());
}
Expand All @@ -131,7 +129,12 @@ void AnimationRule::update()
// Start a new animation with the previously used transition time.
if (!fequal(_animation.target(), _targetRule->value()))
{
_animation.setValue(_targetRule->value(), _animation.transitionTime());
TimeDelta span = _animation.transitionTime();
if (_behavior.testFlag(DontAnimateFromZero) && fequal(_animation.target(), 0))
{
span = 0;
}
_animation.setValue(_targetRule->value(), span);
_animation.clock().audienceForPriorityTimeChange += this;
}
}
Expand Down

0 comments on commit 8c278bb

Please sign in to comment.