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:
parent
c849327042
commit
5b9120cae1
24
animator.h
24
animator.h
@ -33,6 +33,8 @@ class QTimeLine;
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class AbstractAnimation;
|
||||||
|
|
||||||
class AnimatorPrivateDeprecated;
|
class AnimatorPrivateDeprecated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,14 +57,14 @@ public:
|
|||||||
DisappearAnimation, /*<< Animate the disappearance of an element */
|
DisappearAnimation, /*<< Animate the disappearance of an element */
|
||||||
ActivateAnimation, /*<< When something is activated or launched,
|
ActivateAnimation, /*<< When something is activated or launched,
|
||||||
such as an app icon being clicked */
|
such as an app icon being clicked */
|
||||||
/* TODO: should we change the names of animation classes? */
|
/* TODO: change the names of animation classes */
|
||||||
FadeAnimation, /*<< Can be used for both fade in and out */
|
FadeAnim, /*<< Can be used for both fade in and out */
|
||||||
GrowAnimation, /*<< Grow animated object geometry */
|
GrowAnim, /*<< Grow animated object geometry */
|
||||||
ExpandAnimation, /*<< Not sure if we need this (should ask Mehmet A. Akmanalp) */
|
ExpandAnim, /*<< Not sure if we need this (should ask Mehmet A. Akmanalp) */
|
||||||
PulserAnimation, /*<< Pulse animated object (opacity/geometry/scale) */
|
PulseAnim, /*<< Pulse animated object (opacity/geometry/scale) */
|
||||||
RotationAnimation, /*<< Rotate an animated object */
|
RotationAnim, /*<< Rotate an animated object */
|
||||||
RotationStackedAnimation, /*<< TODO: for flipping one object with another */
|
RotationStackedAnim, /*<< TODO: for flipping one object with another */
|
||||||
SlideAnimation /*<< Move the position of animated object */
|
SlideAnim /*<< Move the position of animated object */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CurveShape {
|
enum CurveShape {
|
||||||
@ -84,6 +86,12 @@ public:
|
|||||||
**/
|
**/
|
||||||
static KDE_DEPRECATED Animator *self();
|
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.
|
* Starts a standard animation on a QGraphicsItem.
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "animator.h"
|
#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 <QGraphicsItem>
|
||||||
#include <QTimeLine>
|
#include <QTimeLine>
|
||||||
@ -212,6 +220,49 @@ Animator *Animator::self()
|
|||||||
return &privateSelf->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)
|
Animator::Animator(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new AnimatorPrivateDeprecated)
|
d(new AnimatorPrivateDeprecated)
|
||||||
|
Loading…
Reference in New Issue
Block a user