Skip to content

Commit

Permalink
libdeng2|Animation: Added copy constructor and assignment operator
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed May 30, 2013
1 parent d44d148 commit 6e99bc9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doomsday/libdeng2/include/de/widgets/animation.h
Expand Up @@ -51,7 +51,9 @@ class DENG2_PUBLIC Animation : public ISerializable
DENG2_ERROR(ClockMissingError);

public:
Animation(float value = 0, Style style = EaseIn);
Animation(float value = 0, Style style = EaseIn);
Animation(Animation const &other);
Animation &operator = (Animation const &other);

void setStyle(Style s);

Expand Down Expand Up @@ -159,6 +161,8 @@ class DENG2_PUBLIC Animation : public ISerializable

static Time currentTime();

static Animation range(Style style, float from, float to, TimeDelta span, TimeDelta delay = 0);

private:
DENG2_PRIVATE(d)

Expand Down
16 changes: 16 additions & 0 deletions doomsday/libdeng2/src/widgets/animation.cpp
Expand Up @@ -148,6 +148,15 @@ DENG2_PIMPL_NOREF(Animation)
Animation::Animation(float val, Style s) : d(new Instance(val, s))
{}

Animation::Animation(Animation const &other) : d(new Instance(*other.d))
{}

Animation &Animation::operator = (Animation const &other)
{
d.reset(new Instance(*other.d));
return *this;
}

void Animation::setStyle(Animation::Style s)
{
d->style = s;
Expand Down Expand Up @@ -310,4 +319,11 @@ Time Animation::currentTime()
return _clock->time();
}

Animation Animation::range(Style style, float from, float to, TimeDelta span, TimeDelta delay)
{
Animation anim(from, style);
anim.setValue(to, span, delay);
return anim;
}

} // namespace de

0 comments on commit 6e99bc9

Please sign in to comment.