Home · All Classes · Main Classes · Deprecated
Public Member Functions | Protected Member Functions

MAnimation Class Reference

MAnimation provides an base class for animations. More...

Inherits QAbstractAnimation.

Inherited by MGroupAnimation, and MLayoutAnimation.

List of all members.

Public Member Functions

 MAnimation (QObject *parent=NULL)
virtual ~MAnimation ()

Protected Member Functions

MAnimationStyleContainerstyle ()
const MAnimationStyleContainerstyle () const
virtual const char * styleType () const
virtual MAnimationStyleContainercreateStyleContainer () const

Detailed Description

MAnimation provides an base class for animations.

The class defines the functions for the functionality shared by all M animations.

By inheriting this class, you can create custom, CSS-styled, animations that plug into the rest of the animation framework.

The progress of an animation is given by its current time (currentTime()), which is measured in milliseconds from the start of the animation (0) to its end (duration()). The value is updated automatically while the animation is running. It can also be set directly with setCurrentTime().

See the base class documentation, QAbstractAnimation, for more details on running, pausing and stopping animations.

Classes inheriting from this will need to implement the duration() and updateCurrentTime() virtual functions. The duration() function lets you report a duration for the animation (see QAbstractAnimation for more details) and the animation framework calls updateCurrentTime() when current time has changed. By reimplementing this function, you can track the animation progress. Note that neither the interval between calls nor the number of calls to this function are defined; though, it will normally be 60 updates per second.

Classes inheriting MAnimation can be integrated into the rest of the Qt animation framework, and can be used in a QAnimationGroup, combined with a QVariantAnimation etc.

Class inheriting MAnimation need to include the M_ANIMATION macro in the class definiton. For example:

   class FadeInAnimation : public MAnimation {
       Q_OBJECT
       M_ANIMATION(FadeInAnimationStyle)

     public:
       FadeInAnimation(QGraphicsItem *item, QObject *parent = NULL) : MAnimation(parent),mItem(item);
       virtual void updateCurrentTime (int currentTime ) {
          item->setOpacity(currentTime/1000.0);
       }
       virtual int duration () const { return 1000; }
     protected:
       QGraphicsItem *item;
   };

Constructor & Destructor Documentation

MAnimation::MAnimation ( QObject parent = NULL  ) 

Constructs the MAnimation base class, and passes parent to the QAbstractAnimation's constructor.

See also:
QAbstractAnimation, QAnimationGroup, QVariantAnimation, MGroupAnimation
MAnimation::~MAnimation (  )  [virtual]

Stops the animation if it's running, then destroys the MAnimation.

If the animation is part of a QAnimationGroup, it is automatically removed before it's destroyed.


Member Function Documentation

MAnimationStyleContainer * MAnimation::createStyleContainer (  )  const [protected, virtual]

Instantiates a style container for this animation.

The M_ANIMATION macro, added to inheriting classes, overrides this method with correct return type.

const MAnimationStyleContainer & MAnimation::style (  )  const [protected]

Returns a style container object for this animation - const version.

The M_ANIMATION macro, added to inheriting classes, overrides this method to return the correct type.

MAnimationStyleContainer & MAnimation::style (  )  [protected]

Returns a style container object for this animation.

The M_ANIMATION macro, added to inheriting classes, overrides this method with return the correct type.

const char * MAnimation::styleType (  )  const [protected, virtual]

Returns the type of the style this animation uses.

This is the name used in the CSS file.

The M_ANIMATION macro, added to inheriting classes, overrides this method with correct return type.


Copyright © 2010 Nokia Corporation
MeeGo Touch