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 classes for AbstractAnimation, which is the
|
|
|
|
* abstract base class for all animations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_ABSTRACTANIMATION_H
|
|
|
|
#define PLASMA_ABSTRACTANIMATION_H
|
|
|
|
|
|
|
|
#include <QAbstractAnimation>
|
2009-10-20 15:08:23 +02:00
|
|
|
#include <QEasingCurve>
|
2009-10-15 21:36:38 +02:00
|
|
|
#include <QGraphicsWidget>
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include <plasma/plasma.h>
|
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
2009-10-20 15:08:23 +02:00
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-10-20 23:04:49 +02:00
|
|
|
class AbstractAnimationPrivate;
|
2009-10-17 19:02:28 +02:00
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
/**
|
2009-10-20 23:21:40 +02:00
|
|
|
* @brief Abstract base class for AnimationGroup and Animation.
|
|
|
|
* @since 4.4
|
2009-10-15 21:36:38 +02:00
|
|
|
*/
|
|
|
|
class PLASMA_EXPORT AbstractAnimation : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2009-10-20 15:08:23 +02:00
|
|
|
Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType)
|
2009-10-20 23:14:46 +02:00
|
|
|
Q_PROPERTY(AnimationDirection direction READ direction WRITE setDirection)
|
|
|
|
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
|
|
|
Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible)
|
2009-10-21 04:28:08 +02:00
|
|
|
Q_PROPERTY(QGraphicsWidget *widgetToAnimate READ widgetToAnimate WRITE setWidgetToAnimate)
|
2009-10-22 06:00:48 +02:00
|
|
|
Q_PROPERTY(bool forwards READ forwards WRITE setForwards)
|
|
|
|
|
2009-10-21 07:32:04 +02:00
|
|
|
/**
|
|
|
|
* TODO: add missing properties (e.g. angle, axis, reference, etc)
|
|
|
|
*/
|
|
|
|
Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis)
|
|
|
|
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
|
|
|
|
Q_PROPERTY(qreal angle READ angle WRITE setAngle)
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-10-21 07:32:04 +02:00
|
|
|
/* FIXME: find a better place and name for it. */
|
|
|
|
enum Reference{
|
2009-10-21 09:51:11 +02:00
|
|
|
Center,
|
|
|
|
Up,
|
|
|
|
Down,
|
|
|
|
Left,
|
|
|
|
Right
|
2009-10-21 07:32:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-10-21 09:51:11 +02:00
|
|
|
explicit AbstractAnimation(QObject *parent = 0);
|
2009-10-21 06:15:04 +02:00
|
|
|
virtual ~AbstractAnimation();
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the widget on which the animation is to be performed.
|
|
|
|
* @arg receiver The QGraphicsWidget to be animated.
|
|
|
|
*/
|
2009-10-20 23:21:40 +02:00
|
|
|
virtual void setWidgetToAnimate(QGraphicsWidget* receiver);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The widget that the animation will be performed upon
|
|
|
|
*/
|
|
|
|
QGraphicsWidget *widgetToAnimate();
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
/**
|
2009-10-20 20:40:34 +02:00
|
|
|
* Take an AbstractAnimation and turn it into a
|
2009-10-15 21:36:38 +02:00
|
|
|
* QAbstractAnimation.
|
|
|
|
*/
|
2009-10-16 23:27:35 +02:00
|
|
|
virtual QAbstractAnimation* toQAbstractAnimation(QObject* parent) = 0;
|
2009-10-15 21:36:38 +02:00
|
|
|
|
2009-10-20 15:08:23 +02:00
|
|
|
/**
|
|
|
|
* Set the animation easing curve type
|
|
|
|
*/
|
|
|
|
void setEasingCurveType(QEasingCurve::Type easingCurve);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the animation easing curve type
|
|
|
|
*/
|
|
|
|
QEasingCurve::Type easingCurveType() const;
|
|
|
|
|
2009-10-22 06:00:48 +02:00
|
|
|
/**
|
|
|
|
* Sets whether the animation will run forwards or backwards
|
|
|
|
* @arg forward true to run the animation forewards
|
|
|
|
*/
|
|
|
|
void setForwards(bool forward);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the animation will run forwards, false if it will run backwards
|
|
|
|
*/
|
|
|
|
bool forwards() const;
|
|
|
|
|
2009-10-20 17:53:53 +02:00
|
|
|
/**
|
|
|
|
* Set the animation direction
|
2009-10-20 23:14:46 +02:00
|
|
|
* @arg direction animation direction
|
2009-10-20 17:53:53 +02:00
|
|
|
*/
|
2009-10-20 23:14:46 +02:00
|
|
|
void setDirection(AnimationDirection direction);
|
2009-10-20 17:53:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the animation direction
|
|
|
|
*/
|
2009-10-20 23:14:46 +02:00
|
|
|
AnimationDirection direction() const;
|
2009-10-20 17:53:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the animation distance
|
2009-10-20 23:14:46 +02:00
|
|
|
* @distance animation distance
|
2009-10-20 17:53:53 +02:00
|
|
|
*/
|
2009-10-20 23:14:46 +02:00
|
|
|
void setDistance(qreal distance);
|
2009-10-20 17:53:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the animation distance
|
|
|
|
*/
|
2009-10-20 23:14:46 +02:00
|
|
|
qreal distance() const;
|
2009-10-20 17:53:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* set the animation visibility
|
2009-10-20 23:14:46 +02:00
|
|
|
* @arg isVisible animation visibility
|
2009-10-20 17:53:53 +02:00
|
|
|
*/
|
2009-10-20 23:14:46 +02:00
|
|
|
void setVisible(bool isVisible);
|
2009-10-20 17:53:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the animation visibility
|
|
|
|
*/
|
2009-10-20 23:14:46 +02:00
|
|
|
bool isVisible() const;
|
2009-10-20 17:53:53 +02:00
|
|
|
|
2009-10-21 07:32:04 +02:00
|
|
|
/**
|
|
|
|
* get animation rotation axis (e.g. YAxis, ZAxis, XAxis)
|
|
|
|
*/
|
|
|
|
Qt::Axis axis() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set animation rotation axis
|
|
|
|
* @arg axis Rotation (e.g. YAxis, ZAxis, XAxis)
|
|
|
|
*/
|
|
|
|
void setAxis(const Qt::Axis &axis);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Rotation reference (e.g. Center, Up, Down, Left, Right) can
|
|
|
|
* be combined (i.e. Center|Up)
|
|
|
|
*/
|
|
|
|
qint8 reference() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set rotation reference (e.g. Center, Up, Down, Left, Right) can
|
|
|
|
* be combined (i.e. Center|Up)
|
|
|
|
* @arg reference The reference
|
|
|
|
*/
|
|
|
|
void setReference(const qint8 &reference);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Animation rotation angle (e.g. 45, 180, etc)
|
|
|
|
*/
|
|
|
|
qreal angle() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set animation rotation angle (e.g. 45, 180, etc)
|
|
|
|
* @arg angle The angle
|
|
|
|
*/
|
|
|
|
void setAngle(const qreal &angle);
|
|
|
|
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start the animation.
|
|
|
|
*/
|
2009-10-21 09:51:11 +02:00
|
|
|
virtual void start();
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
protected:
|
2009-10-17 19:35:02 +02:00
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
private:
|
2009-10-20 23:04:49 +02:00
|
|
|
AbstractAnimationPrivate *d;
|
2009-10-15 21:36:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace Plasma
|
|
|
|
|
|
|
|
#endif
|