Implementing the factory in plasma::Animator for new animation objects.

The user should call Animator::create() with the animation type desired
(e.g. FadeAnimation, GrowAnimation, PulseAnimation, etc).

Next: move animation classes to private directory and rename then
so we can use a proper enumeration name.


svn path=/trunk/KDE/kdelibs/; revision=1038194
This commit is contained in:
Adenilson Cavalcanti Da Silva 2009-10-20 19:54:22 +00:00
parent c849327042
commit 5b9120cae1
2 changed files with 67 additions and 8 deletions

View File

@ -33,6 +33,8 @@ class QTimeLine;
namespace Plasma
{
class AbstractAnimation;
class AnimatorPrivateDeprecated;
/**
@ -55,14 +57,14 @@ public:
DisappearAnimation, /*<< Animate the disappearance of an element */
ActivateAnimation, /*<< When something is activated or launched,
such as an app icon being clicked */
/* TODO: should we change the names of animation classes? */
FadeAnimation, /*<< Can be used for both fade in and out */
GrowAnimation, /*<< Grow animated object geometry */
ExpandAnimation, /*<< Not sure if we need this (should ask Mehmet A. Akmanalp) */
PulserAnimation, /*<< Pulse animated object (opacity/geometry/scale) */
RotationAnimation, /*<< Rotate an animated object */
RotationStackedAnimation, /*<< TODO: for flipping one object with another */
SlideAnimation /*<< Move the position of animated object */
/* TODO: change the names of animation classes */
FadeAnim, /*<< Can be used for both fade in and out */
GrowAnim, /*<< Grow animated object geometry */
ExpandAnim, /*<< Not sure if we need this (should ask Mehmet A. Akmanalp) */
PulseAnim, /*<< Pulse animated object (opacity/geometry/scale) */
RotationAnim, /*<< Rotate an animated object */
RotationStackedAnim, /*<< TODO: for flipping one object with another */
SlideAnim /*<< Move the position of animated object */
};
enum CurveShape {
@ -84,6 +86,12 @@ public:
**/
static KDE_DEPRECATED Animator *self();
/**
* Factory to build new animation objects. To control their behavior,
* check \ref AbstractAnimation properties.
**/
AbstractAnimation *create(Animation type);
/**
* Starts a standard animation on a QGraphicsItem.
*

View File

@ -19,6 +19,14 @@
*/
#include "animator.h"
#include "animations/abstractanimation.h"
#include "animations/animation.h"
#include "animations/expand.h"
#include "animations/fade.h"
#include "animations/grow.h"
#include "animations/pulser.h"
#include "animations/rotation.h"
#include "animations/slide.h"
#include <QGraphicsItem>
#include <QTimeLine>
@ -212,6 +220,49 @@ Animator *Animator::self()
return &privateSelf->self;
}
AbstractAnimation *Animator::create(Animation type)
{
AbstractAnimation *result = 0;
switch (type) {
case FadeAnim:
result = new FadeAnimation;
break;
case GrowAnim:
result = new GrowAnimation;
break;
case ExpandAnim:
result = new ExpandAnimation;
break;
case PulseAnim:
result = new PulseAnimation;
break;
case RotationAnim:
result = new RotationAnimation;
break;
case RotationStackedAnim:
//TODO: implement stacked rotation
//result = new Plasma::RotationStackedAnimation;
break;
case SlideAnim:
result = new SlideAnimation;
break;
default:
kDebug() << "Unsupported animation type.";
}
return result;
}
Animator::Animator(QObject *parent)
: QObject(parent),
d(new AnimatorPrivateDeprecated)