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 class for animation groups in plasma.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_ANIMATIONGROUP_H
|
|
|
|
#define PLASMA_ANIMATIONGROUP_H
|
|
|
|
|
|
|
|
#include <QAbstractAnimation>
|
|
|
|
#include <QAnimationGroup>
|
|
|
|
#include <QGraphicsWidget>
|
|
|
|
#include <QList>
|
|
|
|
#include <QObject>
|
2009-12-03 20:30:02 +01:00
|
|
|
#include <plasma/animations/animation.h>
|
2009-10-15 21:36:38 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2009-10-21 06:15:52 +02:00
|
|
|
class AnimationGroupPrivate;
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
/**
|
2009-10-20 23:25:39 +02:00
|
|
|
* @brief A group of Animations and / or AnimationGroups.
|
|
|
|
* @since 4.4
|
2009-10-15 21:36:38 +02:00
|
|
|
*/
|
2009-12-03 20:30:02 +01:00
|
|
|
class PLASMA_EXPORT AnimationGroup : public QAbstractAnimation
|
2009-10-15 21:36:38 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2009-10-21 06:15:52 +02:00
|
|
|
Q_PROPERTY(bool parallel READ isParallel WRITE setParallel)
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2009-12-03 20:30:02 +01:00
|
|
|
QAbstractAnimation::Direction direction() const;
|
|
|
|
|
|
|
|
//void setDirection(QAbstractAnimation::Direction direction);
|
|
|
|
|
2009-10-21 09:51:11 +02:00
|
|
|
explicit AnimationGroup(QObject* parent = 0);
|
2009-10-15 21:36:38 +02:00
|
|
|
virtual ~AnimationGroup();
|
|
|
|
|
2009-12-03 20:30:02 +01:00
|
|
|
int duration() const;
|
|
|
|
|
2009-10-15 21:36:38 +02:00
|
|
|
/**
|
2009-12-03 20:30:02 +01:00
|
|
|
* @arg parallelness whether the animation should be in parallel or not,
|
|
|
|
* by default, it is not parallel
|
2009-10-15 21:36:38 +02:00
|
|
|
*/
|
|
|
|
void setParallel(bool parallelness);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return whether the current animation is parallel or not
|
|
|
|
*/
|
|
|
|
bool isParallel() const;
|
|
|
|
|
2009-10-21 09:51:11 +02:00
|
|
|
public Q_SLOTS:
|
2009-10-15 21:36:38 +02:00
|
|
|
/**
|
|
|
|
* Add an Animation or AnimationGroup to the group
|
|
|
|
* @arg elem element to add
|
|
|
|
* @return id of element added
|
|
|
|
*/
|
2009-12-03 20:30:02 +01:00
|
|
|
Q_INVOKABLE int add(QAbstractAnimation* elem);
|
2009-10-21 09:51:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an Animation or AnimationGroup from this group
|
|
|
|
* @arg eleme element to remove
|
|
|
|
*/
|
2009-12-03 20:30:02 +01:00
|
|
|
Q_INVOKABLE void remove(QAbstractAnimation* elem);
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return element with given id
|
|
|
|
* @return id of element to get
|
|
|
|
*/
|
2009-12-03 20:30:02 +01:00
|
|
|
Q_INVOKABLE QAbstractAnimation* at(int id) const;
|
2009-10-15 21:36:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove element with given id
|
|
|
|
* @arg id id of element to remove
|
|
|
|
*/
|
2009-10-21 09:51:11 +02:00
|
|
|
Q_INVOKABLE void remove(int id);
|
2009-10-15 21:36:38 +02:00
|
|
|
|
2009-12-03 20:30:02 +01:00
|
|
|
protected:
|
|
|
|
void updateCurrentTime(int currentTime);
|
|
|
|
void calculateGroupDuration();
|
|
|
|
void updateDirection(QAbstractAnimation::Direction direction);
|
|
|
|
void updateState(QAbstractAnimation::State oldState,
|
|
|
|
QAbstractAnimation::State newState);
|
|
|
|
|
2009-10-21 06:15:52 +02:00
|
|
|
private:
|
2009-12-03 20:30:02 +01:00
|
|
|
AnimationGroupPrivate *const d;
|
2009-10-15 21:36:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} //namespace Plasma
|
|
|
|
|
|
|
|
#endif
|