Amazon sized patch... So many changes that I can hardly remember what they are,
but this is the list from what I can recall: - removing expand animation (it is a case of grow animation) - removing AbstractAnimation and using QAbstractAnimation as the common base - animations are non longer factories, but real animation (so it is just no issue to mesh then with user created animations) - animation group will correctly revert the direction of all subanimations (useful for rewinding an animation) - fixed opacity effect in pulse animation (now it works correctly) - there is not 'forward' property, but animation 'direction' (this is how rewinding an animation must be done) - direction now is movementDirection property (used in SlideAnimation and RotationStacked) - the weakpointer for the actual animaiton is non longer in AnimationPrivate but in each specialized animation class - hide property is being removed (in progress) since it really is a case of Fade I guess this is it, now is just a matter of iron out the remaining bugs and polish the public API. svn path=/trunk/KDE/kdelibs/; revision=1057993
This commit is contained in:
parent
65455b418b
commit
818e93a576
@ -44,10 +44,8 @@ set(plasma_LIB_SRCS
|
||||
abstractrunner.cpp
|
||||
abstracttoolbox.cpp
|
||||
animator.cpp
|
||||
animations/abstractanimation.cpp
|
||||
animations/animation.cpp
|
||||
animations/animationgroup.cpp
|
||||
animations/expand.cpp
|
||||
animations/fade.cpp
|
||||
animations/grow.cpp
|
||||
animations/slide.cpp
|
||||
@ -255,7 +253,6 @@ set(plasma_LIB_INCLUDES
|
||||
abstractrunner.h
|
||||
abstracttoolbox.h
|
||||
animationdriver.h
|
||||
animations/abstractanimation.h
|
||||
animations/animation.h
|
||||
animations/animationgroup.h
|
||||
animator.h
|
||||
@ -356,7 +353,6 @@ if(PHONON_FOUND)
|
||||
endif(PHONON_FOUND)
|
||||
|
||||
install(FILES
|
||||
animations/abstractanimation.h
|
||||
animations/animation.h
|
||||
animations/animationgroup.h
|
||||
animations/rotationstacked.h
|
||||
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "abstractanimation.h"
|
||||
#include "private/abstractanimationprivate_p.h"
|
||||
|
||||
#include <QEasingCurve>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
AbstractAnimationPrivate::AbstractAnimationPrivate()
|
||||
: animVisible(true),
|
||||
easingCurve(QEasingCurve::Linear),
|
||||
forwards(true)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractAnimation::AbstractAnimation(QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new AbstractAnimationPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractAnimation::~AbstractAnimation()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setWidgetToAnimate(QGraphicsWidget* receiver)
|
||||
{
|
||||
d->animObject = receiver;
|
||||
/* Changed the object, delete the animation */
|
||||
delete d->animation.data();
|
||||
d->animation.clear();
|
||||
|
||||
}
|
||||
|
||||
QGraphicsWidget* AbstractAnimation::widgetToAnimate()
|
||||
{
|
||||
return d->animObject.data();
|
||||
}
|
||||
|
||||
void AbstractAnimation::setEasingCurveType(QEasingCurve::Type easingCurve)
|
||||
{
|
||||
d->easingCurve = easingCurve;
|
||||
}
|
||||
|
||||
QEasingCurve::Type AbstractAnimation::easingCurveType() const
|
||||
{
|
||||
return d->easingCurve;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setForwards(bool forwards)
|
||||
{
|
||||
d->forwards = forwards;
|
||||
}
|
||||
|
||||
bool AbstractAnimation::forwards() const
|
||||
{
|
||||
return d->forwards;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setDirection(const qint8 &direction)
|
||||
{
|
||||
d->animDirection = static_cast<Plasma::AnimationDirection>(direction);
|
||||
}
|
||||
|
||||
qint8 AbstractAnimation::direction() const
|
||||
{
|
||||
return d->animDirection;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setDistance(qreal distance)
|
||||
{
|
||||
d->animDistance = distance;
|
||||
}
|
||||
|
||||
qreal AbstractAnimation::distance() const
|
||||
{
|
||||
return d->animDistance;
|
||||
}
|
||||
|
||||
void AbstractAnimation::setVisible(bool isVisible)
|
||||
{
|
||||
d->animVisible = isVisible;
|
||||
}
|
||||
|
||||
bool AbstractAnimation::isVisible() const
|
||||
{
|
||||
return d->animVisible;
|
||||
}
|
||||
|
||||
QAbstractAnimation* AbstractAnimation::animation()
|
||||
{
|
||||
return d->animation.data();
|
||||
}
|
||||
|
||||
void AbstractAnimation::setAnimation(QAbstractAnimation *obj)
|
||||
{
|
||||
d->animation = obj;
|
||||
}
|
||||
|
||||
void AbstractAnimation::start()
|
||||
{
|
||||
QAbstractAnimation* anim = toQAbstractAnimation(parent());
|
||||
if (anim) {
|
||||
anim->setDirection(d->forwards ? QAbstractAnimation::Forward :
|
||||
QAbstractAnimation::Backward);
|
||||
anim->start();
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
||||
#include <../abstractanimation.moc>
|
@ -1,170 +0,0 @@
|
||||
/*
|
||||
* 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>
|
||||
#include <QEasingCurve>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QObject>
|
||||
|
||||
#include <plasma/plasma.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AbstractAnimationPrivate;
|
||||
|
||||
/**
|
||||
* @brief Abstract base class for AnimationGroup and Animation.
|
||||
* @since 4.4
|
||||
*/
|
||||
class PLASMA_EXPORT AbstractAnimation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType)
|
||||
Q_PROPERTY(qint8 direction READ direction WRITE setDirection)
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible)
|
||||
Q_PROPERTY(QGraphicsWidget *widgetToAnimate READ widgetToAnimate WRITE setWidgetToAnimate)
|
||||
Q_PROPERTY(bool forwards READ forwards WRITE setForwards)
|
||||
Q_PROPERTY(QAbstractAnimation* animation READ animation WRITE setAnimation)
|
||||
|
||||
public:
|
||||
|
||||
/* FIXME: find a better place and name for it. */
|
||||
enum Reference{
|
||||
Center,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
|
||||
explicit AbstractAnimation(QObject *parent = 0);
|
||||
virtual ~AbstractAnimation();
|
||||
|
||||
/**
|
||||
* Set the widget on which the animation is to be performed.
|
||||
* @arg receiver The QGraphicsWidget to be animated.
|
||||
*/
|
||||
virtual void setWidgetToAnimate(QGraphicsWidget* receiver);
|
||||
|
||||
/**
|
||||
* The widget that the animation will be performed upon
|
||||
*/
|
||||
QGraphicsWidget *widgetToAnimate();
|
||||
|
||||
/**
|
||||
* Take an AbstractAnimation and turn it into a
|
||||
* QAbstractAnimation.
|
||||
*/
|
||||
virtual QAbstractAnimation* toQAbstractAnimation(QObject* parent) = 0;
|
||||
|
||||
/**
|
||||
* Set the animation easing curve type
|
||||
*/
|
||||
void setEasingCurveType(QEasingCurve::Type easingCurve);
|
||||
|
||||
/**
|
||||
* Get the animation easing curve type
|
||||
*/
|
||||
QEasingCurve::Type easingCurveType() const;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Set the animation direction
|
||||
* @arg direction animation direction
|
||||
*/
|
||||
void setDirection(const qint8 &direction);
|
||||
|
||||
/**
|
||||
* Get the animation direction
|
||||
*/
|
||||
qint8 direction() const;
|
||||
|
||||
/**
|
||||
* Set the animation distance
|
||||
* @distance animation distance
|
||||
*/
|
||||
void setDistance(qreal distance);
|
||||
|
||||
/**
|
||||
* Get the animation distance
|
||||
*/
|
||||
qreal distance() const;
|
||||
|
||||
/**
|
||||
* set the animation visibility
|
||||
* @arg isVisible animation visibility
|
||||
*/
|
||||
void setVisible(bool isVisible);
|
||||
|
||||
/**
|
||||
* get the animation visibility
|
||||
*/
|
||||
bool isVisible() const;
|
||||
|
||||
/**
|
||||
* Access the QAbstractAnimation of this plasma::Animation object.
|
||||
*/
|
||||
QAbstractAnimation *animation();
|
||||
|
||||
/**
|
||||
* Access the QAbstractAnimation of this plasma::Animation object.
|
||||
* @arg obj An animation pointer (it will be cleared by the object)
|
||||
*/
|
||||
void setAnimation(QAbstractAnimation *obj);
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
/**
|
||||
* Start the animation.
|
||||
*/
|
||||
virtual void start();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
AbstractAnimationPrivate *d;
|
||||
};
|
||||
|
||||
} //namespace Plasma
|
||||
|
||||
#endif
|
@ -18,32 +18,33 @@
|
||||
*/
|
||||
|
||||
#include "animation.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
|
||||
#include <QMapIterator>
|
||||
#include <QObject>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QSequentialAnimationGroup>
|
||||
|
||||
#include <QDebug>
|
||||
#include <kdebug.h>
|
||||
#include <kglobalsettings.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AnimationPrivate {
|
||||
|
||||
public:
|
||||
/**
|
||||
* Duration of the animation. Default is 250ms.
|
||||
*/
|
||||
int duration;
|
||||
};
|
||||
AnimationPrivate::AnimationPrivate()
|
||||
: animVisible(true),
|
||||
dirtyFlag(false),
|
||||
easingCurve(QEasingCurve::Linear),
|
||||
forwards(QAbstractAnimation::Forward),
|
||||
duration(250)
|
||||
{
|
||||
}
|
||||
|
||||
Animation::Animation(QObject* parent)
|
||||
: AbstractAnimation(parent),
|
||||
: QAbstractAnimation(parent),
|
||||
d(new AnimationPrivate)
|
||||
{
|
||||
d->duration = 250;
|
||||
}
|
||||
|
||||
Animation::~Animation()
|
||||
@ -56,27 +57,88 @@ void Animation::setDuration(int duration)
|
||||
d->duration = duration;
|
||||
}
|
||||
|
||||
QAbstractAnimation* Animation::toQAbstractAnimation(QObject* parent)
|
||||
{
|
||||
//check if the widget to animate was set already
|
||||
if (!widgetToAnimate()) {
|
||||
kDebug() << "Object not set.";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//check which parent to use
|
||||
if (parent) {
|
||||
return render(parent);
|
||||
} else {
|
||||
return render(this->parent());
|
||||
}
|
||||
}
|
||||
|
||||
int Animation::duration() const
|
||||
{
|
||||
return d->duration;
|
||||
}
|
||||
|
||||
void Animation::setWidgetToAnimate(QGraphicsWidget* receiver)
|
||||
{
|
||||
d->animObject = receiver;
|
||||
}
|
||||
|
||||
QGraphicsWidget* Animation::widgetToAnimate()
|
||||
{
|
||||
return d->animObject.data();
|
||||
}
|
||||
|
||||
void Animation::setEasingCurveType(QEasingCurve::Type easingCurve)
|
||||
{
|
||||
d->easingCurve = easingCurve;
|
||||
}
|
||||
|
||||
QEasingCurve::Type Animation::easingCurveType() const
|
||||
{
|
||||
return d->easingCurve;
|
||||
}
|
||||
|
||||
QAbstractAnimation::Direction Animation::direction() const
|
||||
{
|
||||
return d->forwards;
|
||||
}
|
||||
|
||||
void Animation::updateDirection(QAbstractAnimation::Direction direction)
|
||||
{
|
||||
d->forwards = direction;
|
||||
|
||||
|
||||
void Animation::setVisible(bool isVisible)
|
||||
{
|
||||
d->animVisible = isVisible;
|
||||
}
|
||||
|
||||
bool Animation::isVisible() const
|
||||
{
|
||||
return d->animVisible;
|
||||
}
|
||||
|
||||
void Animation::start(QAbstractAnimation::DeletionPolicy policy)
|
||||
{
|
||||
/* TODO: Actually treat policy parameter */
|
||||
|
||||
QAbstractAnimation* anim = render(parent());
|
||||
if (anim) {
|
||||
anim->setDirection(direction());
|
||||
anim->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Animation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
/**
|
||||
* XXX: not sure if is a bug in my code or Qt, but 'start()' is not being
|
||||
* called when the animation is inside of an animatin group.
|
||||
* The solution for while is to explicitly call it in 'updateCurrentTime'
|
||||
* and use this flag for control.
|
||||
*/
|
||||
if (!d->dirtyFlag) {
|
||||
d->dirtyFlag = true;
|
||||
start();
|
||||
}
|
||||
|
||||
if (d->forwards == QAbstractAnimation::Forward) {
|
||||
if (currentTime == duration()) {
|
||||
d->dirtyFlag = false;
|
||||
}
|
||||
} else if (d->forwards == QAbstractAnimation::Backward) {
|
||||
if (currentTime == 0) {
|
||||
d->dirtyFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
||||
#include <../animation.moc>
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <QGraphicsWidget>
|
||||
#include <QObject>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
#include <QAbstractAnimation>
|
||||
#include <plasma/animations/abstractanimation.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
@ -41,30 +41,18 @@ class AnimationPrivate;
|
||||
* @brief Abstract representation of a single animation.
|
||||
* @since 4.4
|
||||
*/
|
||||
class PLASMA_EXPORT Animation : public AbstractAnimation
|
||||
class PLASMA_EXPORT Animation : public QAbstractAnimation
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int duration READ duration WRITE setDuration)
|
||||
Q_PROPERTY(QEasingCurve::Type easingCurveType READ easingCurveType WRITE setEasingCurveType)
|
||||
Q_PROPERTY(bool isVisible READ isVisible WRITE setVisible)
|
||||
Q_PROPERTY(QGraphicsWidget *widgetToAnimate READ widgetToAnimate WRITE setWidgetToAnimate)
|
||||
|
||||
public:
|
||||
|
||||
explicit Animation(QObject* parent = 0);
|
||||
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().
|
||||
*/
|
||||
QAbstractAnimation* toQAbstractAnimation(QObject* parent = 0);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Change the animation duration. Default is 1000ms.
|
||||
* @arg duration The new duration of the animation.
|
||||
*/
|
||||
virtual void setDuration(int duration = 250);
|
||||
QAbstractAnimation::Direction direction() const;
|
||||
|
||||
/**
|
||||
* Get the animation duration.
|
||||
@ -72,6 +60,56 @@ protected:
|
||||
*/
|
||||
int duration() const;
|
||||
|
||||
/* FIXME: find a better place and name for it. */
|
||||
enum Reference{
|
||||
Center,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
explicit Animation(QObject* parent = 0);
|
||||
virtual ~Animation() = 0;
|
||||
|
||||
/**
|
||||
* Set the widget on which the animation is to be performed.
|
||||
* @arg receiver The QGraphicsWidget to be animated.
|
||||
*/
|
||||
virtual void setWidgetToAnimate(QGraphicsWidget* receiver);
|
||||
|
||||
/**
|
||||
* The widget that the animation will be performed upon
|
||||
*/
|
||||
QGraphicsWidget *widgetToAnimate();
|
||||
|
||||
/**
|
||||
* Set the animation easing curve type
|
||||
*/
|
||||
void setEasingCurveType(QEasingCurve::Type easingCurve);
|
||||
|
||||
/**
|
||||
* Get the animation easing curve type
|
||||
*/
|
||||
QEasingCurve::Type easingCurveType() const;
|
||||
|
||||
/**
|
||||
* set the animation visibility
|
||||
* @arg isVisible animation visibility
|
||||
*/
|
||||
void setVisible(bool isVisible);
|
||||
|
||||
/**
|
||||
* get the animation visibility
|
||||
*/
|
||||
bool isVisible() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Start the animation.
|
||||
*/
|
||||
void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
|
||||
|
||||
/**
|
||||
* Each individual class must override this function to place their main
|
||||
* functionality. This function must take the values from the constructor,
|
||||
@ -80,8 +118,23 @@ protected:
|
||||
*/
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0) = 0;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Change the animation duration. Default is 1000ms.
|
||||
* @arg duration The new duration of the animation.
|
||||
*/
|
||||
virtual void setDuration(int duration = 250);
|
||||
|
||||
void updateDirection(QAbstractAnimation::Direction direction);
|
||||
|
||||
void updateCurrentTime(int currentTime);
|
||||
|
||||
private:
|
||||
AnimationPrivate * const d;
|
||||
AnimationPrivate *const d;
|
||||
|
||||
};
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -18,10 +18,10 @@
|
||||
*/
|
||||
|
||||
#include "animationgroup.h"
|
||||
|
||||
#include <QMapIterator>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QSequentialAnimationGroup>
|
||||
#include <QDebug>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -29,22 +29,25 @@ namespace Plasma
|
||||
class AnimationGroupPrivate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Boolean determining if the animation is parallel. Default is false.
|
||||
*/
|
||||
bool parallel;
|
||||
AnimationGroupPrivate(): forwards(QAbstractAnimation::Forward),
|
||||
parallel(false),
|
||||
dirtyFlag(false), duration(0),
|
||||
anim(0)
|
||||
{ }
|
||||
|
||||
QAbstractAnimation::Direction forwards;
|
||||
bool parallel;
|
||||
bool dirtyFlag;
|
||||
int duration;
|
||||
QAnimationGroup *anim;
|
||||
|
||||
/**
|
||||
* Map of AbstractAnimations to be run, by id.
|
||||
*/
|
||||
QList<AbstractAnimation *> anims;
|
||||
};
|
||||
|
||||
AnimationGroup::AnimationGroup(QObject* parent)
|
||||
: AbstractAnimation(parent),
|
||||
: QAbstractAnimation(parent),
|
||||
d(new AnimationGroupPrivate)
|
||||
{
|
||||
d->parallel = false;
|
||||
d->anim = new QSequentialAnimationGroup(this);
|
||||
}
|
||||
|
||||
AnimationGroup::~AnimationGroup()
|
||||
@ -52,9 +55,31 @@ AnimationGroup::~AnimationGroup()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void AnimationGroup::setParallel(bool parallelness)
|
||||
QAbstractAnimation::Direction AnimationGroup::direction() const
|
||||
{
|
||||
d->parallel = parallelness;
|
||||
return d->forwards;
|
||||
}
|
||||
|
||||
void AnimationGroup::setParallel(bool parallel)
|
||||
{
|
||||
if (isParallel() == parallel) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->parallel = parallel;
|
||||
|
||||
QAnimationGroup *newGroup;
|
||||
if (parallel)
|
||||
newGroup = new QParallelAnimationGroup(this);
|
||||
else
|
||||
newGroup = new QSequentialAnimationGroup(this);
|
||||
|
||||
while (d->anim->animationCount()) {
|
||||
newGroup->addAnimation(d->anim->takeAnimation(0));
|
||||
}
|
||||
|
||||
delete d->anim;
|
||||
d->anim = newGroup;
|
||||
}
|
||||
|
||||
bool AnimationGroup::isParallel() const
|
||||
@ -62,52 +87,104 @@ bool AnimationGroup::isParallel() const
|
||||
return d->parallel;
|
||||
}
|
||||
|
||||
int AnimationGroup::add(AbstractAnimation* elem)
|
||||
int AnimationGroup::add(QAbstractAnimation* elem)
|
||||
{
|
||||
d->anims.insert(d->anims.count(), elem);
|
||||
return d->anims.count();
|
||||
d->anim->addAnimation(elem);
|
||||
calculateGroupDuration();
|
||||
return d->anim->animationCount();
|
||||
}
|
||||
|
||||
void AnimationGroup::remove(Plasma::AbstractAnimation* elem)
|
||||
void AnimationGroup::remove(QAbstractAnimation* elem)
|
||||
{
|
||||
d->anims.removeAll(elem);
|
||||
d->anim->removeAnimation(elem);
|
||||
calculateGroupDuration();
|
||||
}
|
||||
|
||||
AbstractAnimation* AnimationGroup::at(int id) const
|
||||
QAbstractAnimation* AnimationGroup::at(int id) const
|
||||
{
|
||||
return d->anims.value(id);
|
||||
return d->anim->animationAt(id);
|
||||
}
|
||||
|
||||
void AnimationGroup::remove(int id)
|
||||
{
|
||||
if (id >= d->anims.count() || id < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->anims.removeAt(id);
|
||||
//This used to save some code...
|
||||
//d->anim->takeAnimationAt(id);
|
||||
d->anim->removeAnimation(d->anim->animationAt(id));
|
||||
calculateGroupDuration();
|
||||
}
|
||||
|
||||
QAnimationGroup* AnimationGroup::toQAbstractAnimation(QObject* parent)
|
||||
void AnimationGroup::start(QAbstractAnimation::DeletionPolicy policy)
|
||||
{
|
||||
//if supplied, use parent given in args.
|
||||
if (!parent){
|
||||
parent = this->parent();
|
||||
if (d->anim) {
|
||||
d->anim->setDirection(d->forwards);
|
||||
d->anim->start(policy);
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationGroup::updateCurrentTime(int currentTime)
|
||||
{
|
||||
|
||||
/**
|
||||
* XXX: not sure if is a bug in my code or Qt, but 'start()' is not being
|
||||
* called when the animation is inside of an animatin group.
|
||||
* The solution for while is to explicitly call it in 'updateCurrentTime'
|
||||
* and use this flag for control.
|
||||
*/
|
||||
if (!d->dirtyFlag) {
|
||||
d->dirtyFlag = true;
|
||||
start();
|
||||
}
|
||||
|
||||
QAnimationGroup* g;
|
||||
if (d->forwards == QAbstractAnimation::Forward) {
|
||||
if (currentTime == duration()) {
|
||||
d->dirtyFlag = false;
|
||||
}
|
||||
} else if (d->forwards == QAbstractAnimation::Backward) {
|
||||
if (currentTime == 0) {
|
||||
d->dirtyFlag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationGroup::calculateGroupDuration()
|
||||
{
|
||||
QAbstractAnimation *tmp;
|
||||
d->duration = 0;
|
||||
if (d->parallel) {
|
||||
g = new QParallelAnimationGroup(parent);
|
||||
for (int i = 0; i < d->anim->animationCount(); ++i) {
|
||||
tmp = d->anim->animationAt(i);
|
||||
if (d->duration < tmp->duration())
|
||||
d->duration = tmp->duration();
|
||||
}
|
||||
|
||||
} else {
|
||||
g = new QSequentialAnimationGroup(parent);
|
||||
for (int i = 0; i < d->anim->animationCount(); ++i) {
|
||||
tmp = d->anim->animationAt(i);
|
||||
d->duration += tmp->duration();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int AnimationGroup::duration() const
|
||||
{
|
||||
return d->duration;
|
||||
}
|
||||
|
||||
void AnimationGroup::updateDirection(QAbstractAnimation::Direction direction)
|
||||
{
|
||||
d->forwards = direction;
|
||||
QAbstractAnimation *tmp;
|
||||
for (int i = 0; i < d->anim->animationCount(); ++i) {
|
||||
tmp = d->anim->animationAt(i);
|
||||
tmp->setDirection(d->forwards);
|
||||
}
|
||||
|
||||
QListIterator<AbstractAnimation*> it(d->anims);
|
||||
while (it.hasNext()) {
|
||||
//add with group as owner
|
||||
g->addAnimation(it.next()->toQAbstractAnimation(g));
|
||||
}
|
||||
}
|
||||
|
||||
return g;
|
||||
void AnimationGroup::updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
|
||||
{
|
||||
/* TODO: watch animation state and eventually emit 'finished' signal */
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -29,8 +29,7 @@
|
||||
#include <QGraphicsWidget>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
#include <plasma/animations/abstractanimation.h>
|
||||
#include <plasma/animations/animation.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
namespace Plasma
|
||||
@ -42,18 +41,25 @@ class AnimationGroupPrivate;
|
||||
* @brief A group of Animations and / or AnimationGroups.
|
||||
* @since 4.4
|
||||
*/
|
||||
class PLASMA_EXPORT AnimationGroup : public AbstractAnimation
|
||||
class PLASMA_EXPORT AnimationGroup : public QAbstractAnimation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool parallel READ isParallel WRITE setParallel)
|
||||
|
||||
public:
|
||||
|
||||
QAbstractAnimation::Direction direction() const;
|
||||
|
||||
//void setDirection(QAbstractAnimation::Direction direction);
|
||||
|
||||
explicit AnimationGroup(QObject* parent = 0);
|
||||
virtual ~AnimationGroup();
|
||||
|
||||
int duration() const;
|
||||
|
||||
/**
|
||||
* @arg parallelness whether the animation should be in parallel or not
|
||||
* @arg parallelness whether the animation should be in parallel or not,
|
||||
* by default, it is not parallel
|
||||
*/
|
||||
void setParallel(bool parallelness);
|
||||
|
||||
@ -62,32 +68,25 @@ public:
|
||||
*/
|
||||
bool isParallel() const;
|
||||
|
||||
/**
|
||||
* Take the animation object and turn it into a QAnimationGroup. More
|
||||
* specifically, a QSerialAnimation or QParallelAnimation depending on
|
||||
* the value of m_parallel at the time of invocation. Returns NULL on error.
|
||||
*/
|
||||
QAnimationGroup* toQAbstractAnimation(QObject* parent = 0);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Add an Animation or AnimationGroup to the group
|
||||
* @arg elem element to add
|
||||
* @return id of element added
|
||||
*/
|
||||
Q_INVOKABLE int add(Plasma::AbstractAnimation* elem);
|
||||
Q_INVOKABLE int add(QAbstractAnimation* elem);
|
||||
|
||||
/**
|
||||
* Remove an Animation or AnimationGroup from this group
|
||||
* @arg eleme element to remove
|
||||
*/
|
||||
Q_INVOKABLE void remove(Plasma::AbstractAnimation* elem);
|
||||
Q_INVOKABLE void remove(QAbstractAnimation* elem);
|
||||
|
||||
/**
|
||||
* Return element with given id
|
||||
* @return id of element to get
|
||||
*/
|
||||
Q_INVOKABLE AbstractAnimation* at(int id) const;
|
||||
Q_INVOKABLE QAbstractAnimation* at(int id) const;
|
||||
|
||||
/**
|
||||
* Remove element with given id
|
||||
@ -95,8 +94,21 @@ public Q_SLOTS:
|
||||
*/
|
||||
Q_INVOKABLE void remove(int id);
|
||||
|
||||
/**
|
||||
* Start the animation.
|
||||
*/
|
||||
void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
|
||||
|
||||
|
||||
protected:
|
||||
void updateCurrentTime(int currentTime);
|
||||
void calculateGroupDuration();
|
||||
void updateDirection(QAbstractAnimation::Direction direction);
|
||||
void updateState(QAbstractAnimation::State oldState,
|
||||
QAbstractAnimation::State newState);
|
||||
|
||||
private:
|
||||
AnimationGroupPrivate * const d;
|
||||
AnimationGroupPrivate *const d;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "expand_p.h"
|
||||
|
||||
#include <QRect>
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
ExpandAnimation::ExpandAnimation(QObject *parent)
|
||||
: Animation(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QAbstractAnimation* ExpandAnimation::render(QObject* parent)
|
||||
{
|
||||
|
||||
//get current geometry values
|
||||
QGraphicsWidget *m_object = widgetToAnimate();
|
||||
QRectF geometry = m_object->geometry();
|
||||
|
||||
//compute new geometry values
|
||||
switch (direction()) {
|
||||
|
||||
case MoveUp:
|
||||
geometry.setTop(geometry.y() - distance());
|
||||
break;
|
||||
|
||||
case MoveRight:
|
||||
geometry.setRight(geometry.x() + geometry.width() - 1 + distance());
|
||||
break;
|
||||
|
||||
case MoveDown:
|
||||
geometry.setBottom(geometry.y() + geometry.height() - 1 + distance());
|
||||
break;
|
||||
|
||||
case MoveLeft:
|
||||
geometry.setLeft(geometry.x() - distance());
|
||||
break;
|
||||
|
||||
case MoveUpRight:
|
||||
case MoveDownRight:
|
||||
case MoveDownLeft:
|
||||
case MoveUpLeft:
|
||||
break;
|
||||
}
|
||||
|
||||
//Recreate only if needed
|
||||
QPropertyAnimation *anim = dynamic_cast<QPropertyAnimation* >(animation());
|
||||
if (!anim) {
|
||||
anim = new QPropertyAnimation(m_object, "geometry", parent);
|
||||
setAnimation(anim);
|
||||
}
|
||||
anim->setEndValue(geometry);
|
||||
anim->setDuration(duration());
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* 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 definition for the Expand effect.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_ANIMATIONS_Expand_H
|
||||
#define PLASMA_ANIMATIONS_Expand_H
|
||||
|
||||
#include <plasma/animations/animation.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
/**
|
||||
* @class Expand plasma/animations/expand.h
|
||||
* @short Expand effect
|
||||
*
|
||||
* Effect that grows the object a specific distance in a given direction, on
|
||||
* one side. The object doesn't "move" except for the side that is expanding.
|
||||
*/
|
||||
class ExpandAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExpandAnimation(QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
virtual QAbstractAnimation *render(QObject* parent = 0);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -59,26 +59,30 @@ qreal FadeAnimation::targetOpacity() const
|
||||
|
||||
void FadeAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
|
||||
if (widget) {
|
||||
widget->setOpacity(m_startOpacity);
|
||||
m_widget = widget;
|
||||
}
|
||||
|
||||
if (animation.data()) {
|
||||
delete animation.data();
|
||||
animation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractAnimation* FadeAnimation::render(QObject* parent)
|
||||
{
|
||||
//create animation
|
||||
QPropertyAnimation* anim = dynamic_cast<QPropertyAnimation* >(animation());
|
||||
QPropertyAnimation* anim = animation.data();
|
||||
if (!anim) {
|
||||
anim = new QPropertyAnimation(m_widget.data(), "opacity", parent);
|
||||
setAnimation(anim);
|
||||
QGraphicsWidget *widget = widgetToAnimate();
|
||||
anim = new QPropertyAnimation(widget, "opacity", widget);
|
||||
animation = anim;
|
||||
qDebug()<<"creating";
|
||||
}
|
||||
|
||||
anim->setStartValue(m_startOpacity);
|
||||
anim->setEndValue(m_targetOpacity);
|
||||
anim->setStartValue(startOpacity());
|
||||
anim->setEndValue(targetOpacity());
|
||||
anim->setDuration(duration());
|
||||
|
||||
return anim;
|
||||
|
@ -60,7 +60,7 @@ protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
QWeakPointer<QGraphicsWidget> m_widget;
|
||||
QWeakPointer<QPropertyAnimation> animation;
|
||||
qreal m_startOpacity;
|
||||
qreal m_targetOpacity;
|
||||
};
|
||||
|
@ -25,8 +25,8 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
GrowAnimation::GrowAnimation(qreal factor)
|
||||
: m_animFactor(factor)
|
||||
GrowAnimation::GrowAnimation(QObject *parent, qreal factor)
|
||||
: Animation(parent), m_animFactor(factor)
|
||||
{
|
||||
}
|
||||
|
||||
@ -40,6 +40,15 @@ qreal GrowAnimation::factor() const
|
||||
return m_animFactor;
|
||||
}
|
||||
|
||||
void GrowAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
if (animation.data()) {
|
||||
delete animation.data();
|
||||
animation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
|
||||
//get current geometry values
|
||||
@ -54,7 +63,7 @@ QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
//compute new geometry values
|
||||
qreal newWidth;
|
||||
qreal newHeight;
|
||||
if (forwards()) {
|
||||
if (direction() == QAbstractAnimation::Forward) {
|
||||
newWidth = qBound(minimum.width(), w * factor, maximum.width());
|
||||
newHeight = qBound(minimum.height(), h * factor, maximum.height());
|
||||
} else {
|
||||
@ -68,13 +77,19 @@ QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
newY = geometry.y() - (newHeight - h)/2;
|
||||
|
||||
//Recreate only if needed
|
||||
QPropertyAnimation *anim = dynamic_cast<QPropertyAnimation* >(animation());
|
||||
QPropertyAnimation *anim = animation.data();
|
||||
if (!anim) {
|
||||
anim = new QPropertyAnimation(m_object, "geometry", parent);
|
||||
setAnimation(anim);
|
||||
anim = new QPropertyAnimation(m_object, "geometry", m_object);
|
||||
animation = anim;
|
||||
}
|
||||
|
||||
if (forwards()) {
|
||||
//Prevents from deforming (with multiple clicks)
|
||||
QAbstractAnimation::State temp = anim->state();
|
||||
if (temp == QAbstractAnimation::Running) {
|
||||
return anim;
|
||||
}
|
||||
|
||||
if (direction() == QAbstractAnimation::Forward) {
|
||||
anim->setStartValue(QRectF(geometry.x(), geometry.y(), w, h));
|
||||
anim->setEndValue(QRectF(newX, newY, newWidth, newHeight));
|
||||
} else {
|
||||
@ -82,9 +97,9 @@ QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
anim->setEndValue(QRectF(geometry.x(), geometry.y(), w, h));
|
||||
}
|
||||
|
||||
anim->setDuration(duration());
|
||||
qDebug()<<"start value:"<<anim->startValue()<<"end value:"<<anim->endValue();
|
||||
|
||||
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
anim->setDuration(duration());
|
||||
|
||||
return anim;
|
||||
}
|
||||
|
@ -45,19 +45,21 @@ class GrowAnimation : public Animation
|
||||
|
||||
public:
|
||||
|
||||
GrowAnimation(qreal factor = 2);
|
||||
GrowAnimation(QObject *parent = 0, qreal factor = 2);
|
||||
virtual ~GrowAnimation(){};
|
||||
|
||||
qreal factor() const;
|
||||
|
||||
void setFactor(const qreal factor);
|
||||
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
qreal m_animFactor;
|
||||
QWeakPointer<QPropertyAnimation> animation;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -29,13 +29,22 @@ PauseAnimation::PauseAnimation(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void PauseAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
if (animation.data()) {
|
||||
delete animation.data();
|
||||
animation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractAnimation* PauseAnimation::render(QObject* parent)
|
||||
{
|
||||
//Recreate only if needed
|
||||
QPauseAnimation *anim = dynamic_cast<QPauseAnimation* >(animation());
|
||||
QPauseAnimation *anim = animation.data();
|
||||
if (!anim) {
|
||||
anim = new QPauseAnimation(duration(), parent);
|
||||
setAnimation(anim);
|
||||
animation = anim;
|
||||
}
|
||||
|
||||
return anim;
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <plasma/animations/animation.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
class QPauseAnimation;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -40,9 +41,13 @@ class PauseAnimation : public Animation
|
||||
|
||||
public:
|
||||
PauseAnimation(QObject *parent = 0);
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
QWeakPointer<QPauseAnimation> animation;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "pulser_p.h"
|
||||
#include "plasma/private/pulsershadow_p.h"
|
||||
#include <QAbstractAnimation>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QParallelAnimationGroup>
|
||||
@ -37,8 +36,7 @@ class PulseAnimationPrivate
|
||||
{
|
||||
public :
|
||||
PulseAnimationPrivate()
|
||||
: animation(0),
|
||||
under(0),
|
||||
: under(0),
|
||||
zvalue(0),
|
||||
mscale(0),
|
||||
opacityAnimation(0),
|
||||
@ -49,16 +47,26 @@ public :
|
||||
~PulseAnimationPrivate()
|
||||
{ }
|
||||
|
||||
QAbstractAnimation *animation;
|
||||
QGraphicsWidget *under;
|
||||
qreal zvalue, mscale, mopacity;
|
||||
QPropertyAnimation *opacityAnimation;
|
||||
QPropertyAnimation *geometryAnimation;
|
||||
QPropertyAnimation *scaleAnimation;
|
||||
QWeakPointer<QParallelAnimationGroup> animation;
|
||||
};
|
||||
|
||||
|
||||
PulseAnimation::PulseAnimation(): d(new PulseAnimationPrivate)
|
||||
void PulseAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
if (d->animation.data()) {
|
||||
delete d->animation.data();
|
||||
d->animation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
PulseAnimation::PulseAnimation(QObject *parent)
|
||||
: Animation(parent), d(new PulseAnimationPrivate)
|
||||
{
|
||||
|
||||
}
|
||||
@ -108,12 +116,12 @@ void PulseAnimation::createAnimation(qreal duration, qreal scale)
|
||||
if (!d->under)
|
||||
setCopy();
|
||||
|
||||
QParallelAnimationGroup *anim = dynamic_cast<QParallelAnimationGroup* >(animation());
|
||||
QParallelAnimationGroup *anim = d->animation.data();
|
||||
if (!anim) {
|
||||
QParallelAnimationGroup *group = new QParallelAnimationGroup(this);
|
||||
d->opacityAnimation = new QPropertyAnimation(d->under, "opacity");
|
||||
d->opacityAnimation->setDuration(duration);
|
||||
d->opacityAnimation->setStartValue(100);
|
||||
d->opacityAnimation->setStartValue(1);
|
||||
d->opacityAnimation->setEndValue(0);
|
||||
group->addAnimation(d->opacityAnimation);
|
||||
|
||||
@ -125,7 +133,6 @@ void PulseAnimation::createAnimation(qreal duration, qreal scale)
|
||||
/* The group takes ownership of all animations */
|
||||
group->addAnimation(d->scaleAnimation);
|
||||
d->animation = group;
|
||||
setAnimation(d->animation);
|
||||
dirty = true;
|
||||
|
||||
} else {
|
||||
@ -146,15 +153,15 @@ void PulseAnimation::createAnimation(qreal duration, qreal scale)
|
||||
}
|
||||
|
||||
if (dirty)
|
||||
connect(d->animation, SIGNAL(finished()), this, SLOT(resetPulser()));
|
||||
connect(d->animation.data(), SIGNAL(finished()), this, SLOT(resetPulser()));
|
||||
}
|
||||
|
||||
QAbstractAnimation* PulseAnimation::render(QObject* parent)
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
Q_UNUSED(parent);
|
||||
|
||||
createAnimation(duration());
|
||||
return d->animation;
|
||||
return d->animation.data();
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -32,19 +32,21 @@ class PulseAnimation : public Animation
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PulseAnimation();
|
||||
PulseAnimation(QObject *parent = 0);
|
||||
~PulseAnimation();
|
||||
|
||||
void updateGeometry(QRectF updated, qreal zCoordinate = 0, qreal scale = 1.5);
|
||||
void setCopy();
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
public Q_SLOTS:
|
||||
void resetPulser();
|
||||
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
void setCopy();
|
||||
|
||||
private:
|
||||
|
||||
void createAnimation(qreal _duration = 500, qreal _scale = 1.5);
|
||||
|
||||
PulseAnimationPrivate *d;
|
||||
|
@ -52,12 +52,25 @@ public:
|
||||
*/
|
||||
qint8 reference;
|
||||
|
||||
QWeakPointer<QPropertyAnimation> animation;
|
||||
|
||||
|
||||
};
|
||||
|
||||
void RotationAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
if (d->animation.data()) {
|
||||
delete d->animation.data();
|
||||
d->animation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
RotationAnimation::RotationAnimation(const qint8 &reference, const Qt::Axis &axis, const qreal &angle)
|
||||
: d(new RotationAnimationPrivate)
|
||||
RotationAnimation::RotationAnimation(QObject *parent,
|
||||
const qint8 &reference,
|
||||
const Qt::Axis &axis,
|
||||
const qreal &angle)
|
||||
: Animation(parent), d(new RotationAnimationPrivate)
|
||||
{
|
||||
setAngle(angle);
|
||||
setAxis(axis);
|
||||
@ -143,10 +156,10 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
transformation.append(d->rotation);
|
||||
m_object->setTransformations(transformation);
|
||||
|
||||
QPropertyAnimation *rotationAnimation = dynamic_cast<QPropertyAnimation* >(animation());
|
||||
QPropertyAnimation *rotationAnimation = d->animation.data();
|
||||
if (!rotationAnimation) {
|
||||
rotationAnimation = new QPropertyAnimation(d->rotation, "angle", m_object);
|
||||
setAnimation(rotationAnimation);
|
||||
d->animation = rotationAnimation;
|
||||
}
|
||||
|
||||
rotationAnimation->setStartValue(0);
|
||||
|
@ -41,7 +41,8 @@ class RotationAnimation : public Animation
|
||||
Q_PROPERTY(qreal angle READ angle WRITE setAngle)
|
||||
|
||||
public:
|
||||
RotationAnimation(const qint8 &reference = Up,
|
||||
RotationAnimation(QObject *parent = 0,
|
||||
const qint8 &reference = Up,
|
||||
const Qt::Axis &axis = Qt::ZAxis,
|
||||
const qreal &angle = 180);
|
||||
|
||||
@ -84,9 +85,9 @@ public:
|
||||
*/
|
||||
void setAngle(const qreal &angle);
|
||||
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
RotationAnimationPrivate *const d;
|
||||
};
|
||||
} // Plasma
|
||||
|
@ -32,19 +32,24 @@ namespace Plasma
|
||||
{
|
||||
|
||||
class RotationStackedAnimationPrivate {
|
||||
public:
|
||||
QGraphicsRotation *backRotation;
|
||||
QGraphicsRotation *frontRotation;
|
||||
public:
|
||||
QGraphicsRotation *backRotation;
|
||||
QGraphicsRotation *frontRotation;
|
||||
|
||||
qint8 reference;
|
||||
qint8 reference;
|
||||
/**
|
||||
* Animation direction: where the animation will move.
|
||||
*/
|
||||
Plasma::AnimationDirection animDirection;
|
||||
|
||||
QWeakPointer<QGraphicsWidget> backWidget;
|
||||
QSequentialAnimationGroup *groupAnim;
|
||||
StackedLayout *sLayout;
|
||||
QWeakPointer<QGraphicsWidget> backWidget;
|
||||
StackedLayout *sLayout;
|
||||
QWeakPointer<QSequentialAnimationGroup> animation;
|
||||
};
|
||||
|
||||
RotationStackedAnimation::RotationStackedAnimation(QObject *parent)
|
||||
: d(new RotationStackedAnimationPrivate)
|
||||
: Animation(parent),
|
||||
d(new RotationStackedAnimationPrivate)
|
||||
{
|
||||
d->backRotation = new QGraphicsRotation(this);
|
||||
d->frontRotation = new QGraphicsRotation(this);
|
||||
@ -52,11 +57,30 @@ RotationStackedAnimation::RotationStackedAnimation(QObject *parent)
|
||||
d->sLayout = new StackedLayout;
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::setMovementDirection(const qint8 &direction)
|
||||
{
|
||||
d->animDirection = static_cast<Plasma::AnimationDirection>(direction);
|
||||
}
|
||||
|
||||
qint8 RotationStackedAnimation::movementDirection() const
|
||||
{
|
||||
return static_cast<qint8>(d->animDirection);
|
||||
}
|
||||
|
||||
RotationStackedAnimation::~RotationStackedAnimation()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
if (d->animation.data()) {
|
||||
delete d->animation.data();
|
||||
d->animation.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::setReference(const qint8 &reference)
|
||||
{
|
||||
d->reference = reference;
|
||||
@ -80,6 +104,7 @@ void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget)
|
||||
d->sLayout->addWidget(widgetToAnimate());
|
||||
d->sLayout->addWidget(d->backWidget.data());
|
||||
}
|
||||
render(parent());
|
||||
}
|
||||
|
||||
QGraphicsLayoutItem *RotationStackedAnimation::layout()
|
||||
@ -91,23 +116,27 @@ QAbstractAnimation *RotationStackedAnimation::render(QObject *parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
bool dirty = false;
|
||||
if (!backWidget()) {
|
||||
return d->animation.data();
|
||||
}
|
||||
|
||||
QPair<QGraphicsWidget *,QGraphicsWidget *> widgets = qMakePair(widgetToAnimate(), backWidget());
|
||||
QPropertyAnimation *frontAnim, *backAnim;
|
||||
d->groupAnim = dynamic_cast<QSequentialAnimationGroup* >(animation());
|
||||
if (!d->groupAnim) {
|
||||
QSequentialAnimationGroup *groupAnim = d->animation.data();
|
||||
if (!groupAnim) {
|
||||
|
||||
d->groupAnim = new QSequentialAnimationGroup(parent);
|
||||
frontAnim = new QPropertyAnimation(d->frontRotation, "angle", d->groupAnim);
|
||||
backAnim = new QPropertyAnimation(d->backRotation, "angle", d->groupAnim);
|
||||
setAnimation(d->groupAnim);
|
||||
groupAnim = new QSequentialAnimationGroup(parent);
|
||||
frontAnim = new QPropertyAnimation(d->frontRotation, "angle", groupAnim);
|
||||
backAnim = new QPropertyAnimation(d->backRotation, "angle", groupAnim);
|
||||
d->animation = groupAnim;
|
||||
dirty = true;
|
||||
} else {
|
||||
if (d->groupAnim->animationCount() == 2) {
|
||||
frontAnim = dynamic_cast<QPropertyAnimation* >(d->groupAnim->animationAt(0));
|
||||
backAnim = dynamic_cast<QPropertyAnimation* >(d->groupAnim->animationAt(1));
|
||||
if (groupAnim->animationCount() == 2) {
|
||||
frontAnim = dynamic_cast<QPropertyAnimation* >(groupAnim->animationAt(0));
|
||||
backAnim = dynamic_cast<QPropertyAnimation* >(groupAnim->animationAt(1));
|
||||
} else {
|
||||
kDebug() << "_ Where are my little animations? Duh!";
|
||||
return d->groupAnim;
|
||||
return groupAnim;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,16 +148,19 @@ QAbstractAnimation *RotationStackedAnimation::render(QObject *parent)
|
||||
|
||||
QPair<QVector3D, QVector3D> vector;
|
||||
|
||||
if(reference() == Center) {
|
||||
if (reference() == Center) {
|
||||
|
||||
vector.first = QVector3D(widgetFrontWidth/2, widgetFrontHeight/2, 0);
|
||||
vector.second = QVector3D(widgetBackWidth/2, widgetBackHeight/2, 0);
|
||||
|
||||
if(direction() == MoveLeft || direction() == MoveRight) {
|
||||
if (d->animDirection == MoveLeft || d->animDirection == MoveRight) {
|
||||
d->frontRotation->setAxis(Qt::YAxis);
|
||||
d->backRotation->setAxis(Qt::YAxis);
|
||||
|
||||
if(direction() == MoveLeft) {
|
||||
if (d->animDirection == MoveLeft) {
|
||||
/* TODO: the order way */
|
||||
|
||||
|
||||
} else {
|
||||
d->backRotation->setAngle(265);
|
||||
backAnim->setStartValue(d->backRotation->angle());
|
||||
@ -157,22 +189,25 @@ QAbstractAnimation *RotationStackedAnimation::render(QObject *parent)
|
||||
if (dirty) {
|
||||
connect(frontAnim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)),
|
||||
this, SLOT(animationStateChange(QAbstractAnimation::State, QAbstractAnimation::State)));
|
||||
d->groupAnim->addAnimation(frontAnim);
|
||||
d->groupAnim->addAnimation(backAnim);
|
||||
groupAnim->addAnimation(frontAnim);
|
||||
groupAnim->addAnimation(backAnim);
|
||||
}
|
||||
|
||||
return d->groupAnim;
|
||||
return groupAnim;
|
||||
}
|
||||
|
||||
void RotationStackedAnimation::animationStateChange(
|
||||
QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
|
||||
QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
|
||||
{
|
||||
if(d->groupAnim->direction() == QAbstractAnimation::Backward) {
|
||||
if(newState == QAbstractAnimation::Running) {
|
||||
Q_UNUSED(oldState);
|
||||
if (direction() == QAbstractAnimation::Backward) {
|
||||
if ((newState == QAbstractAnimation::Running) &&
|
||||
(oldState == QAbstractAnimation::Stopped)) {
|
||||
d->sLayout->setCurrentWidgetIndex(0);
|
||||
}
|
||||
} else {
|
||||
if(newState == QAbstractAnimation::Stopped) {
|
||||
if((newState == QAbstractAnimation::Stopped) &&
|
||||
(oldState == QAbstractAnimation::Running)) {
|
||||
d->sLayout->setCurrentWidgetIndex(1);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class RotationStackedAnimationPrivate;
|
||||
class RotationStackedAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qint8 movementDirection READ movementDirection WRITE setMovementDirection)
|
||||
Q_PROPERTY(QGraphicsLayoutItem* layout READ layout)
|
||||
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
|
||||
Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget)
|
||||
@ -49,6 +49,17 @@ class RotationStackedAnimation : public Animation
|
||||
|
||||
QAbstractAnimation *render(QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* Set the animation direction
|
||||
* @arg direction animation direction
|
||||
*/
|
||||
void setMovementDirection(const qint8 &direction);
|
||||
|
||||
/**
|
||||
* Get the animation direction
|
||||
*/
|
||||
qint8 movementDirection() const;
|
||||
|
||||
void setReference(const qint8 &reference);
|
||||
qint8 reference() const;
|
||||
|
||||
@ -57,9 +68,11 @@ class RotationStackedAnimation : public Animation
|
||||
QGraphicsWidget *backWidget();
|
||||
void setBackWidget(QGraphicsWidget *backWidget);
|
||||
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
public Q_SLOTS:
|
||||
void animationStateChange(QAbstractAnimation::State oldState,
|
||||
QAbstractAnimation::State newState);
|
||||
void animationStateChange(QAbstractAnimation::State newState,
|
||||
QAbstractAnimation::State oldState);
|
||||
|
||||
private:
|
||||
RotationStackedAnimationPrivate *d;
|
||||
|
@ -25,13 +25,48 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
SlideAnimation::SlideAnimation(AnimationDirection direction, qreal distance)
|
||||
void SlideAnimation::setWidgetToAnimate(QGraphicsWidget *widget)
|
||||
{
|
||||
setDirection(direction);
|
||||
Animation::setWidgetToAnimate(widget);
|
||||
if (animation.data()) {
|
||||
delete animation.data();
|
||||
animation.clear();
|
||||
}
|
||||
|
||||
}
|
||||
void SlideAnimation::setDistance(qreal distance)
|
||||
{
|
||||
animDistance = distance;
|
||||
}
|
||||
|
||||
qreal SlideAnimation::distance() const
|
||||
{
|
||||
return animDistance;
|
||||
}
|
||||
|
||||
SlideAnimation::~SlideAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
SlideAnimation::SlideAnimation(QObject *parent,
|
||||
AnimationDirection direction,
|
||||
qreal distance) : Animation(parent)
|
||||
{
|
||||
setMovementDirection(direction);
|
||||
setDistance(distance);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void SlideAnimation::setMovementDirection(const qint8 &direction)
|
||||
{
|
||||
animDirection = static_cast<Plasma::AnimationDirection>(direction);
|
||||
}
|
||||
|
||||
qint8 SlideAnimation::movementDirection() const
|
||||
{
|
||||
return static_cast<qint8>(animDirection);
|
||||
}
|
||||
|
||||
QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
||||
{
|
||||
bool dirty = false;
|
||||
@ -42,8 +77,8 @@ QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
||||
qreal newX = x;
|
||||
qreal newY = y;
|
||||
|
||||
kDebug()<<direction();
|
||||
switch (direction()) {
|
||||
kDebug()<<movementDirection();
|
||||
switch (movementDirection()) {
|
||||
case MoveUp:
|
||||
newY -= distance();
|
||||
break;
|
||||
@ -87,24 +122,20 @@ QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
||||
}
|
||||
|
||||
//Recreate only if needed
|
||||
QPropertyAnimation* anim = dynamic_cast<QPropertyAnimation* >(animation());
|
||||
QPropertyAnimation* anim = animation.data();
|
||||
if (!anim) {
|
||||
anim = new QPropertyAnimation(m_object, "pos", parent);
|
||||
setAnimation(anim);
|
||||
dirty = true;
|
||||
animation = anim;
|
||||
}
|
||||
anim->setEndValue(QPointF(newX, newY));
|
||||
anim->setDuration(duration());
|
||||
|
||||
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
|
||||
if (dirty) {
|
||||
if (isVisible()) {
|
||||
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(show()));
|
||||
} else {
|
||||
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(hide()));
|
||||
}
|
||||
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(show()));
|
||||
}
|
||||
|
||||
return anim;
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class SlideAnimationPrivate;
|
||||
/**
|
||||
* @class Slide plasma/animations/slide.h
|
||||
* @short Slide effect
|
||||
@ -40,19 +41,60 @@ namespace Plasma
|
||||
class SlideAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qint8 movementDirection READ movementDirection WRITE setMovementDirection)
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
|
||||
public:
|
||||
SlideAnimation(AnimationDirection direction = MoveUp, qreal distance = 0);
|
||||
virtual ~SlideAnimation(){};
|
||||
SlideAnimation(QObject *parent = 0,
|
||||
AnimationDirection direction = MoveUp, qreal distance = 0);
|
||||
~SlideAnimation();
|
||||
|
||||
/**
|
||||
* Set the animation distance
|
||||
* @distance animation distance
|
||||
*/
|
||||
void setDistance(qreal distance);
|
||||
|
||||
/**
|
||||
* Get the animation distance
|
||||
*/
|
||||
qreal distance() const;
|
||||
|
||||
/**
|
||||
* Set if the widget is visible at the end of the animation (default True).
|
||||
* @param visibility True for visible, False for not.
|
||||
*/
|
||||
void setVisibleAtEnd(bool visibility);
|
||||
|
||||
/**
|
||||
* Set the animation direction
|
||||
* @arg direction animation direction
|
||||
*/
|
||||
void setMovementDirection(const qint8 &direction);
|
||||
|
||||
/**
|
||||
* Get the animation direction
|
||||
*/
|
||||
qint8 movementDirection() const;
|
||||
|
||||
void setWidgetToAnimate(QGraphicsWidget *widget);
|
||||
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Animation direction: where the animation will move.
|
||||
*/
|
||||
Plasma::AnimationDirection animDirection;
|
||||
|
||||
/**
|
||||
* Animation distance: displacement factor for animations where
|
||||
* there is change in the position of animated widget.
|
||||
*/
|
||||
qreal animDistance;
|
||||
|
||||
QWeakPointer<QPropertyAnimation> animation;
|
||||
};
|
||||
|
||||
}
|
||||
|
10
animator.cpp
10
animator.cpp
@ -22,9 +22,7 @@
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "animations/abstractanimation.h"
|
||||
#include "animations/animation.h"
|
||||
#include "animations/expand_p.h"
|
||||
#include "animations/fade_p.h"
|
||||
#include "animations/grow_p.h"
|
||||
#include "animations/pause_p.h"
|
||||
@ -36,9 +34,9 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
AbstractAnimation *Animator::create(Animation type, QObject *parent)
|
||||
Plasma::Animation* Animator::create(Animator::Animation type, QObject *parent)
|
||||
{
|
||||
AbstractAnimation *result = 0;
|
||||
Plasma::Animation *result = 0;
|
||||
|
||||
switch (type) {
|
||||
|
||||
@ -50,10 +48,6 @@ AbstractAnimation *Animator::create(Animation type, QObject *parent)
|
||||
result = new Plasma::GrowAnimation;
|
||||
break;
|
||||
|
||||
case ExpandAnimation:
|
||||
result = new Plasma::ExpandAnimation;
|
||||
break;
|
||||
|
||||
case PulseAnimation:
|
||||
result = new Plasma::PulseAnimation;
|
||||
break;
|
||||
|
@ -33,9 +33,8 @@ class QTimeLine;
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AbstractAnimation;
|
||||
|
||||
class AnimatorPrivate;
|
||||
class Animation;
|
||||
|
||||
/**
|
||||
* @class Animator plasma/animator.h <Plasma/Animator>
|
||||
@ -60,7 +59,6 @@ public:
|
||||
/* TODO: change the names of animation classes */
|
||||
FadeAnimation, /*<< Can be used for both fade in and out */
|
||||
GrowAnimation, /*<< Grow animated object geometry */
|
||||
ExpandAnimation, /*<< Not sure if we need this (should ask Mehmet A. Akmanalp) */
|
||||
PulseAnimation, /*<< Pulse animated object (opacity/geometry/scale) */
|
||||
RotationAnimation, /*<< Rotate an animated object */
|
||||
RotationStackedAnimation, /*<< TODO: for flipping one object with another */
|
||||
@ -91,7 +89,7 @@ public:
|
||||
* Factory to build new animation objects. To control their behavior,
|
||||
* check \ref AbstractAnimation properties.
|
||||
**/
|
||||
static AbstractAnimation *create(Animation type, QObject *parent = 0);
|
||||
static Plasma::Animation *create(Animator::Animation type, QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* Starts a standard animation on a QGraphicsItem.
|
||||
|
@ -80,6 +80,8 @@ qreal AnimatorPrivate::calculateProgress(int time, int duration, Animator::Curve
|
||||
|
||||
void AnimatorPrivate::performAnimation(qreal amount, const AnimationState *state)
|
||||
{
|
||||
/* TODO: write new animations to replace this.
|
||||
*/
|
||||
switch (state->animation) {
|
||||
case Animator::AppearAnimation:
|
||||
driver->itemAppear(amount, state->item);
|
||||
@ -93,6 +95,9 @@ void AnimatorPrivate::performAnimation(qreal amount, const AnimationState *state
|
||||
case Animator::ActivateAnimation:
|
||||
driver->itemActivated(amount, state->item);
|
||||
break;
|
||||
default:
|
||||
kDebug() << "Unsupported animation type.";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,6 +510,9 @@ QPixmap Animator::currentPixmap(int id)
|
||||
break;
|
||||
case ActivateAnimation:
|
||||
break;
|
||||
default:
|
||||
kDebug() << "Unsupported animation type.";
|
||||
|
||||
}
|
||||
|
||||
return state->pixmap;
|
||||
|
@ -28,7 +28,7 @@ class QAbstractAnimation;
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AbstractAnimationPrivate
|
||||
class AnimationPrivate
|
||||
{
|
||||
public:
|
||||
|
||||
@ -70,6 +70,12 @@ public:
|
||||
* to rewind the animation by setDirection(QAbstractAnimation::Backward).
|
||||
*/
|
||||
bool forwards;
|
||||
|
||||
/**
|
||||
* Duration of the animation. Default is 250ms.
|
||||
*/
|
||||
int duration;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
77
private/animationprivate_p.h
Normal file
77
private/animationprivate_p.h
Normal file
@ -0,0 +1,77 @@
|
||||
/***********************************************************************/
|
||||
/* animationprivate.h */
|
||||
/* */
|
||||
/* Copyright(C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>*/
|
||||
/* */
|
||||
/* This library is free software; you can redistribute it and/or */
|
||||
/* modify it under the terms of the GNU Lesser General Public */
|
||||
/* License as published by the Free Software Foundation; either */
|
||||
/* version 2.1 of the License, or (at your option) any later version. */
|
||||
/* */
|
||||
/* This library 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 */
|
||||
/* Lesser General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU Lesser General Public */
|
||||
/* License along with this library; if not, write to the Free Software */
|
||||
/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA */
|
||||
/* 02110-1301 USA */
|
||||
/***********************************************************************/
|
||||
#ifndef PLASMA_ANIMATIONPRIVATE_H
|
||||
#define PLASMA_ANIMATIONPRIVATE_H
|
||||
|
||||
#include <QEasingCurve>
|
||||
#include <QWeakPointer>
|
||||
class QAbstractAnimation;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AnimationPrivate
|
||||
{
|
||||
public:
|
||||
|
||||
AnimationPrivate();
|
||||
/**
|
||||
* Object the animation(s) should act upon.
|
||||
*/
|
||||
QWeakPointer<QGraphicsWidget> animObject;
|
||||
|
||||
/**
|
||||
* Animation visibility: whether to end the animation being visible
|
||||
* or not.
|
||||
*/
|
||||
bool animVisible;
|
||||
|
||||
/**
|
||||
* XXX: not sure if is a bug in my code or Qt, but 'start()' is not being
|
||||
* called when the animation is inside of an animatin group.
|
||||
* The solution for while is to explicitly call it in 'updateCurrentTime'
|
||||
* and use this flag for control.
|
||||
*/
|
||||
bool dirtyFlag;
|
||||
|
||||
/**
|
||||
* Animation easing curve type
|
||||
*/
|
||||
QEasingCurve::Type easingCurve;
|
||||
|
||||
/**
|
||||
* Animation direction, the idea is to offer a way
|
||||
* to rewind the animation by setDirection(QAbstractAnimation::Backward).
|
||||
* TODO: map this to QAbstractAnimation::Direction
|
||||
*/
|
||||
QAbstractAnimation::Direction forwards;
|
||||
|
||||
/**
|
||||
* Duration of the animation. Default is 250ms.
|
||||
* TODO: map this to QAbstractAnimation::duration
|
||||
*/
|
||||
int duration;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
#include <plasma/animations/abstractanimation.h>
|
||||
#include <plasma/animations/animation.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -51,7 +51,7 @@ private Q_SLOTS:
|
||||
private:
|
||||
QGraphicsWidget *m_parent;
|
||||
Plasma::FrameSvg *m_background;
|
||||
AbstractAnimation *m_fade;
|
||||
Animation *m_fade;
|
||||
QRectF m_customGeometry;
|
||||
QString m_prefix;
|
||||
QString m_customPrefix;
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QPainter>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QDebug>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -51,7 +51,9 @@ void ShadowFake::copyTarget(QGraphicsWidget *target)
|
||||
QPainter painter(photo);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
||||
painter.fillRect(target->rect(), Qt::transparent);
|
||||
target->paint(&painter, 0, 0);
|
||||
/* Does it need any special initialization for KDE? */
|
||||
QStyleOptionGraphicsItem style;
|
||||
target->paint(&painter, &style, 0);
|
||||
painter.end();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user