2009-10-15 21:36:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file This file contains the abstract base class for all singular
|
|
|
|
* animations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_ANIMATION_H
|
|
|
|
#define PLASMA_ANIMATION_H
|
|
|
|
|
2009-12-27 23:16:11 +01:00
|
|
|
#include <QtGui/QGraphicsWidget>
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
#include <QtCore/QPropertyAnimation>
|
|
|
|
#include <QtCore/QAbstractAnimation>
|
|
|
|
#include <QtCore/QEasingCurve>
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2009-12-03 20:52:27 +01:00
|
|
|
#include <plasma/plasma.h>
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-10-15 22:19:02 +02:00
|
|
|
class AnimationPrivate;
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
/**
|
2009-10-20 23:25:39 +02:00
|
|
|
* @brief Abstract representation of a single animation.
|
|
|
|
* @since 4.4
|
2009-10-15 21:36:38 +02:00
|
|
|
*/
|
2009-12-03 20:30:02 +01:00
|
|
|
class PLASMA_EXPORT Animation : public QAbstractAnimation
|
2009-10-15 21:36:38 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
Q_OBJECT
|
2010-01-12 10:40:51 +01:00
|
|
|
Q_ENUMS(Reference)
|
2010-01-12 23:24:58 +01:00
|
|
|
Q_ENUMS(MovementDirection)
|
2009-10-22 04:59:36 +02:00
|
|
|
Q_PROPERTY(int duration READ duration WRITE setDuration)
|
2010-01-12 23:24:58 +01:00
|
|
|
Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve)
|
2010-01-04 10:16:41 +01:00
|
|
|
Q_PROPERTY(QGraphicsWidget *targetWidget READ targetWidget WRITE setTargetWidget)
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
public:
|
2009-12-03 20:30:02 +01:00
|
|
|
/**
|
2009-12-09 18:56:40 +01:00
|
|
|
* Get the animation duration. It can be set using the property duration.
|
2009-12-03 20:30:02 +01:00
|
|
|
* @return duration in ms.
|
|
|
|
*/
|
|
|
|
int duration() const;
|
|
|
|
|
2009-12-09 18:56:40 +01:00
|
|
|
/**
|
|
|
|
* Animation movement reference (used by \ref RotationAnimation).
|
|
|
|
*/
|
2009-12-03 20:30:02 +01:00
|
|
|
enum Reference{
|
|
|
|
Center,
|
|
|
|
Up,
|
|
|
|
Down,
|
|
|
|
Left,
|
|
|
|
Right
|
|
|
|
};
|
|
|
|
|
2010-01-12 10:54:42 +01:00
|
|
|
/**
|
|
|
|
* The movement direction of an animation.
|
|
|
|
*/
|
2010-01-12 23:24:58 +01:00
|
|
|
enum MovementDirection {
|
2010-01-12 10:54:42 +01:00
|
|
|
MoveUp = 0, /**< Move up */
|
|
|
|
MoveUpRight, /**< Move up and right */
|
|
|
|
MoveRight, /**< Move right */
|
|
|
|
MoveDownRight, /**< Move down and right */
|
|
|
|
MoveDown, /**< Move down */
|
|
|
|
MoveDownLeft, /**< Move down and left */
|
|
|
|
MoveLeft, /**< Move left */
|
|
|
|
MoveUpLeft /**< Move up and left */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-12-09 18:56:40 +01:00
|
|
|
/**
|
|
|
|
* Default constructor.
|
|
|
|
*
|
|
|
|
* @param parent Object parent (might be set when using
|
|
|
|
* \ref Animator::create factory).
|
|
|
|
*
|
|
|
|
*/
|
2009-10-21 09:51:11 +02:00
|
|
|
explicit Animation(QObject* parent = 0);
|
2009-12-09 18:56:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destructor.
|
|
|
|
*/
|
2010-01-04 10:16:41 +01:00
|
|
|
~Animation() = 0;
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
/**
|
2009-12-03 20:30:02 +01:00
|
|
|
* Set the widget on which the animation is to be performed.
|
2010-01-04 10:16:41 +01:00
|
|
|
* @arg widget The QGraphicsWidget to be animated.
|
2009-10-15 21:36:38 +02:00
|
|
|
*/
|
2010-01-04 10:16:41 +01:00
|
|
|
void setTargetWidget(QGraphicsWidget* widget);
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
/**
|
2010-01-04 10:16:41 +01:00
|
|
|
* @return The widget that the animation will be performed upon
|
2009-10-15 21:36:38 +02:00
|
|
|
*/
|
2010-01-04 10:16:41 +01:00
|
|
|
QGraphicsWidget *targetWidget() const;
|
2009-10-15 21:36:38 +02:00
|
|
|
|
2009-10-20 23:24:06 +02:00
|
|
|
/**
|
2009-12-03 20:30:02 +01:00
|
|
|
* Set the animation easing curve type
|
2009-10-20 23:24:06 +02:00
|
|
|
*/
|
2010-01-12 23:24:58 +01:00
|
|
|
void setEasingCurve(const QEasingCurve &curve);
|
2009-12-03 20:30:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the animation easing curve type
|
|
|
|
*/
|
2010-01-12 23:24:58 +01:00
|
|
|
QEasingCurve easingCurve() const;
|
2009-12-03 20:30:02 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
2009-12-09 18:56:40 +01:00
|
|
|
* Change the animation duration. Default is 250ms.
|
2009-12-03 20:30:02 +01:00
|
|
|
* @arg duration The new duration of the animation.
|
|
|
|
*/
|
|
|
|
virtual void setDuration(int duration = 250);
|
|
|
|
|
2009-12-09 18:56:40 +01:00
|
|
|
/**
|
|
|
|
* QAbstractAnimation will call this method while the animation
|
|
|
|
* is running. Each specialized animation class should implement
|
|
|
|
* the correct behavior for it.
|
|
|
|
* @param currentTime Slapsed time using the \ref duration as reference
|
|
|
|
* (it will be from duration up to zero if the animation is running
|
|
|
|
* backwards).
|
|
|
|
*/
|
2009-12-04 15:56:19 +01:00
|
|
|
virtual void updateCurrentTime(int currentTime);
|
2009-12-03 20:30:02 +01:00
|
|
|
|
2009-10-15 22:19:02 +02:00
|
|
|
private:
|
2009-12-09 18:56:40 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal pimple (actually is used as a data structure, see
|
|
|
|
* \ref AnimationPrivate).
|
|
|
|
*/
|
2009-12-03 20:30:02 +01:00
|
|
|
AnimationPrivate *const d;
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace Plasma
|
|
|
|
|
|
|
|
#endif
|