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
|
|
|
|
|
|
|
|
#include <QGraphicsWidget>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPropertyAnimation>
|
|
|
|
|
|
|
|
#include <plasma/animations/abstractanimation.h>
|
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
|
|
|
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
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT Animation : public AbstractAnimation
|
|
|
|
{
|
|
|
|
|
|
|
|
Q_OBJECT
|
2009-10-22 04:59:36 +02:00
|
|
|
Q_PROPERTY(int duration READ duration WRITE setDuration)
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-10-21 09:51:11 +02:00
|
|
|
explicit Animation(QObject* parent = 0);
|
2009-10-15 21:36:38 +02:00
|
|
|
virtual ~Animation() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Take the animation object and turn it into a QPropertyAnimation. Returns
|
|
|
|
* NULL on error. This function just does some boilerplate checking and then
|
|
|
|
* calls render().
|
|
|
|
*/
|
2009-10-16 23:27:35 +02:00
|
|
|
QAbstractAnimation* toQAbstractAnimation(QObject* parent = 0);
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Change the animation duration. Default is 1000ms.
|
|
|
|
* @arg duration The new duration of the animation.
|
|
|
|
*/
|
|
|
|
virtual void setDuration(int duration = 250);
|
|
|
|
|
2009-10-20 23:24:06 +02:00
|
|
|
/**
|
|
|
|
* Get the animation duration.
|
|
|
|
* @return duration in ms.
|
|
|
|
*/
|
|
|
|
int duration() const;
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
/**
|
|
|
|
* Each individual class must override this function to place their main
|
|
|
|
* functionality. This function must take the values from the constructor,
|
|
|
|
* do the appropriate calculations, and return a corresponding
|
|
|
|
* QPropertyAnimation initialized with the given parent.
|
|
|
|
*/
|
|
|
|
virtual QAbstractAnimation* render(QObject* parent = 0) = 0;
|
|
|
|
|
2009-10-15 22:19:02 +02:00
|
|
|
private:
|
2009-10-20 23:04:49 +02:00
|
|
|
AnimationPrivate * const d;
|
2009-10-15 21:36:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace Plasma
|
|
|
|
|
|
|
|
#endif
|