sort out the API a bit and don't have private classes that are named the same
svn path=/trunk/KDE/kdelibs/; revision=1038220
This commit is contained in:
parent
5b9120cae1
commit
b29d0a79aa
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "abstractanimation.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
#include "private/abstractanimationprivate_p.h"
|
||||
|
||||
#include <QEasingCurve>
|
||||
|
||||
@ -26,7 +26,8 @@ namespace Plasma
|
||||
{
|
||||
|
||||
|
||||
AbstractAnimation::AbstractAnimation(): d(new AnimationPrivate)
|
||||
AbstractAnimation::AbstractAnimation()
|
||||
: d(new AbstractAnimationPrivate)
|
||||
{
|
||||
d->easingCurve = QEasingCurve::Linear;
|
||||
}
|
||||
@ -41,7 +42,7 @@ void AbstractAnimation::setWidget(QGraphicsWidget* receiver)
|
||||
d->animObject = receiver;
|
||||
}
|
||||
|
||||
QGraphicsWidget* AbstractAnimation::getAnimatedObject()
|
||||
QGraphicsWidget* AbstractAnimation::animatedObject()
|
||||
{
|
||||
return d->animObject;
|
||||
}
|
||||
@ -86,11 +87,6 @@ bool AbstractAnimation::animationVisible() const
|
||||
return d->animVisible;
|
||||
}
|
||||
|
||||
AnimationPrivate* AbstractAnimation::getAnimationPrivate()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
||||
#include <../abstractanimation.moc>
|
||||
|
@ -37,7 +37,7 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AnimationPrivate;
|
||||
class AbstractAnimationPrivate;
|
||||
|
||||
/**
|
||||
* Abstract base class for AnimationGroup and Animation.
|
||||
@ -119,14 +119,10 @@ public slots:
|
||||
virtual void start() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
QGraphicsWidget *getAnimatedObject();
|
||||
|
||||
AnimationPrivate *getAnimationPrivate();
|
||||
QGraphicsWidget *animatedObject();
|
||||
|
||||
private:
|
||||
|
||||
AnimationPrivate *d;
|
||||
AbstractAnimationPrivate *d;
|
||||
};
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -47,8 +47,8 @@ public:
|
||||
};
|
||||
|
||||
Animation::Animation(QObject* parent)
|
||||
: d(new AnimationPrivate)
|
||||
{
|
||||
d = new AnimationPrivate;
|
||||
d->m_parent = parent;
|
||||
d->m_duration = 250;
|
||||
|
||||
@ -75,7 +75,7 @@ void Animation::start()
|
||||
QAbstractAnimation* Animation::toQAbstractAnimation(QObject* parent)
|
||||
{
|
||||
//check if .setObject() was done
|
||||
if (!getAnimatedObject()) {
|
||||
if (!animatedObject()) {
|
||||
kDebug() << "Object not set.";
|
||||
return NULL;
|
||||
}
|
||||
@ -89,7 +89,7 @@ QAbstractAnimation* Animation::toQAbstractAnimation(QObject* parent)
|
||||
|
||||
}
|
||||
|
||||
int Animation::getDuration()
|
||||
int Animation::duration() const
|
||||
{
|
||||
return d->m_duration;
|
||||
}
|
||||
|
@ -82,11 +82,11 @@ protected:
|
||||
* Get the animation duration.
|
||||
* @return duration in ms.
|
||||
*/
|
||||
int getDuration();
|
||||
int duration() const;
|
||||
|
||||
private:
|
||||
|
||||
AnimationPrivate *d;
|
||||
AnimationPrivate * const d;
|
||||
};
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "expand.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
|
||||
#include <QRect>
|
||||
#include <kdebug.h>
|
||||
@ -28,53 +27,50 @@ namespace Plasma
|
||||
|
||||
ExpandAnimation::ExpandAnimation(AnimationDirection direction, qreal distance)
|
||||
{
|
||||
AnimationPrivate *obj = getAnimationPrivate();
|
||||
obj->animDirection = direction;
|
||||
obj->animDistance = distance;
|
||||
setAnimationDirection(direction);
|
||||
setAnimationDistance(distance);
|
||||
}
|
||||
|
||||
QAbstractAnimation* ExpandAnimation::render(QObject* parent){
|
||||
|
||||
//get current geometry values
|
||||
QGraphicsWidget *m_object = getAnimatedObject();
|
||||
QGraphicsWidget *m_object = animatedObject();
|
||||
QRectF geometry = m_object->geometry();
|
||||
AnimationPrivate *obj = getAnimationPrivate();
|
||||
|
||||
//compute new geometry values
|
||||
switch (obj->animDirection) {
|
||||
switch (animationDirection()) {
|
||||
|
||||
case MoveUp:
|
||||
geometry.setTop(geometry.y() - obj->animDistance);
|
||||
break;
|
||||
geometry.setTop(geometry.y() - animationDistance());
|
||||
break;
|
||||
|
||||
case MoveRight:
|
||||
geometry.setRight(geometry.x() + geometry.width() - 1 + obj->animDistance);
|
||||
break;
|
||||
geometry.setRight(geometry.x() + geometry.width() - 1 + animationDistance());
|
||||
break;
|
||||
|
||||
case MoveDown:
|
||||
geometry.setBottom(geometry.y() + geometry.height() - 1 + obj->animDistance);
|
||||
break;
|
||||
geometry.setBottom(geometry.y() + geometry.height() - 1 + animationDistance());
|
||||
break;
|
||||
|
||||
case MoveLeft:
|
||||
geometry.setLeft(geometry.x() - obj->animDistance);
|
||||
break;
|
||||
geometry.setLeft(geometry.x() - animationDistance());
|
||||
break;
|
||||
|
||||
case MoveUpRight:
|
||||
case MoveDownRight:
|
||||
case MoveDownLeft:
|
||||
case MoveUpLeft:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
//create animation
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(m_object, "geometry", parent);
|
||||
anim->setEndValue(geometry);
|
||||
anim->setDuration(getDuration());
|
||||
anim->setDuration(duration());
|
||||
|
||||
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
|
||||
return anim;
|
||||
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "fade.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
|
||||
#include <QRect>
|
||||
#include <kdebug.h>
|
||||
@ -27,25 +26,17 @@ namespace Plasma
|
||||
{
|
||||
|
||||
FadeAnimation::FadeAnimation(qreal factor)
|
||||
: m_animFactor(qBound(qreal(0.0), factor, qreal(1.0)))
|
||||
{
|
||||
AnimationPrivate *obj = getAnimationPrivate();
|
||||
obj->animFactor = factor;
|
||||
if (obj->animFactor > 1.0) {
|
||||
kDebug() << "Opacity must be between 0 and 1.0. Reducing to 1.0.";
|
||||
obj->animFactor = 1.0;
|
||||
} else if (obj->animFactor < 0) {
|
||||
kDebug() << "Opacity must be between 0 and 1.0. Increasing to 0.";
|
||||
obj->animFactor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractAnimation* FadeAnimation::render(QObject* parent){
|
||||
|
||||
//create animation
|
||||
QGraphicsWidget *m_object = getAnimatedObject();
|
||||
QGraphicsWidget *m_object = animatedObject();
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(m_object, "opacity", parent);
|
||||
anim->setEndValue(getAnimationPrivate()->animFactor);
|
||||
anim->setDuration(getDuration());
|
||||
anim->setEndValue(m_animFactor);
|
||||
anim->setDuration(duration());
|
||||
|
||||
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace Plasma
|
||||
*
|
||||
* Effect that slowly transforms the opacity of the object to the given value.
|
||||
*/
|
||||
class PLASMA_EXPORT FadeAnimation : public Animation
|
||||
class FadeAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -47,6 +47,8 @@ public:
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
qreal m_animFactor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "grow.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
|
||||
#include <QRect>
|
||||
#include <kdebug.h>
|
||||
@ -27,20 +26,20 @@ namespace Plasma
|
||||
{
|
||||
|
||||
GrowAnimation::GrowAnimation(qreal factor)
|
||||
: m_animFactor(factor)
|
||||
{
|
||||
getAnimationPrivate()->animFactor = factor;
|
||||
}
|
||||
|
||||
QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
|
||||
//get current geometry values
|
||||
QGraphicsWidget *m_object = getAnimatedObject();
|
||||
QGraphicsWidget *m_object = animatedObject();
|
||||
QRectF geometry = m_object->geometry();
|
||||
qreal w = geometry.width();
|
||||
qreal h = geometry.height();
|
||||
|
||||
//compute new geometry values
|
||||
qreal factor = getAnimationPrivate()->animFactor;
|
||||
qreal factor = m_animFactor;
|
||||
qreal newWidth = w * factor;
|
||||
qreal newHeight = h * factor;
|
||||
//locfactor is factor by which object must move up and left
|
||||
@ -55,7 +54,7 @@ QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
anim->setEndValue(QRectF(
|
||||
newX, newY,
|
||||
newWidth, newHeight));
|
||||
anim->setDuration(getDuration());
|
||||
anim->setDuration(duration());
|
||||
|
||||
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace Plasma
|
||||
* constructor. The center of the object stays in place while the sides grow.
|
||||
*
|
||||
*/
|
||||
class PLASMA_EXPORT GrowAnimation : public Animation
|
||||
class GrowAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -50,6 +50,8 @@ public:
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
qreal m_animFactor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ PulseAnimation::~PulseAnimation()
|
||||
|
||||
void PulseAnimation::setCopy(QGraphicsWidget *copy)
|
||||
{
|
||||
QGraphicsWidget *target = getAnimatedObject();
|
||||
QGraphicsWidget *target = animatedObject();
|
||||
d->under = copy;
|
||||
if (d->under != target) {
|
||||
d->under->setParentItem(target);
|
||||
@ -116,7 +116,7 @@ void PulseAnimation::resetPulser()
|
||||
|
||||
void PulseAnimation::createAnimation(qreal duration, qreal scale)
|
||||
{
|
||||
QGraphicsWidget *target = getAnimatedObject();
|
||||
QGraphicsWidget *target = animatedObject();
|
||||
/* Fallback to parent widget if we don't have one 'shadow' widget */
|
||||
if (!d->under) {
|
||||
setCopy(target);
|
||||
|
@ -91,7 +91,7 @@ void RotationAnimation::setAngle(const qreal &angle)
|
||||
QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
QGraphicsWidget *m_object = getAnimatedObject();
|
||||
QGraphicsWidget *m_object = animatedObject();
|
||||
|
||||
QVector3D vector(0, 0, 0);
|
||||
|
||||
@ -161,7 +161,7 @@ QPropertyAnimation *RotationAnimation::render(QObject *parent)
|
||||
QPropertyAnimation *rotationAnimation= new QPropertyAnimation(d->rotation,
|
||||
"angle", m_object);
|
||||
rotationAnimation->setEndValue(d->angle);
|
||||
rotationAnimation->setDuration(getDuration());
|
||||
rotationAnimation->setDuration(duration());
|
||||
|
||||
return rotationAnimation;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "slide.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
|
||||
#include <QPointF>
|
||||
#include <kdebug.h>
|
||||
@ -28,57 +27,53 @@ namespace Plasma
|
||||
|
||||
SlideAnimation::SlideAnimation(AnimationDirection direction, qreal distance)
|
||||
{
|
||||
AnimationPrivate *obj = getAnimationPrivate();
|
||||
obj->animDirection = direction;
|
||||
obj->animDistance = distance;
|
||||
obj->animVisible = true;
|
||||
setAnimationDirection(direction);
|
||||
setAnimationDistance(distance);
|
||||
setAnimationVisible(true);
|
||||
}
|
||||
|
||||
QAbstractAnimation* SlideAnimation::render(QObject* parent)
|
||||
{
|
||||
QGraphicsWidget *m_object = getAnimatedObject();
|
||||
QGraphicsWidget *m_object = animatedObject();
|
||||
qreal x = m_object->x();
|
||||
qreal y = m_object->y();
|
||||
|
||||
qreal newX = x;
|
||||
qreal newY = y;
|
||||
|
||||
AnimationPrivate *obj = getAnimationPrivate();
|
||||
switch (obj->animDirection) {
|
||||
|
||||
switch (animationDirection()) {
|
||||
case MoveUp:
|
||||
newY = y - obj->animDistance;
|
||||
break;
|
||||
newY = y - animationDistance();
|
||||
break;
|
||||
|
||||
case MoveRight:
|
||||
newX = x + obj->animDistance;
|
||||
break;
|
||||
newX = x + animationDistance();
|
||||
break;
|
||||
|
||||
case MoveDown:
|
||||
newY = y + obj->animDistance;
|
||||
break;
|
||||
newY = y + animationDistance();
|
||||
break;
|
||||
|
||||
case MoveLeft:
|
||||
newX = x - obj->animDistance;
|
||||
break;
|
||||
newX = x - animationDistance();
|
||||
break;
|
||||
|
||||
case MoveUpRight:
|
||||
case MoveDownRight:
|
||||
case MoveDownLeft:
|
||||
case MoveUpLeft:
|
||||
/* TODO: support compound directions */
|
||||
kDebug() << "Compound directions (UpRight, DownRight, DownLeft, \
|
||||
UpLeft) are not supported\n";
|
||||
break;
|
||||
/* TODO: support compound directions */
|
||||
kDebug() << "Compound directions (UpRight, DownRight, DownLeft, UpLeft) are not supported";
|
||||
break;
|
||||
}
|
||||
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(m_object, "pos", parent);
|
||||
anim->setEndValue(QPointF(newX, newY));
|
||||
anim->setDuration(getDuration());
|
||||
anim->setDuration(duration());
|
||||
|
||||
//QObject::connect(anim, SIGNAL(finished()), anim, SLOT(deleteLater()));
|
||||
|
||||
if (obj->animVisible) {
|
||||
if (animationVisible()) {
|
||||
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(show()));
|
||||
} else {
|
||||
QObject::connect(anim, SIGNAL(finished()), m_object, SLOT(hide()));
|
||||
@ -90,7 +85,7 @@ UpLeft) are not supported\n";
|
||||
|
||||
void SlideAnimation::setVisibleAtEnd(bool visibility)
|
||||
{
|
||||
getAnimationPrivate()->animVisible = visibility;
|
||||
setAnimationVisible(visibility);
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
@ -26,7 +26,7 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AnimationPrivate
|
||||
class AbstractAnimationPrivate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -34,12 +34,6 @@ public:
|
||||
*/
|
||||
QGraphicsWidget* animObject;
|
||||
|
||||
/**
|
||||
* Animation factor: its meaning depends on the animation class
|
||||
* (e.g. opacity in FadeAnimation, scale in GrowAnimation, etc)
|
||||
*/
|
||||
qreal animFactor;
|
||||
|
||||
/**
|
||||
* Animation direction: where the animation will move.
|
||||
*/
|
Loading…
Reference in New Issue
Block a user