Moving AnimationPrivate to private directory and removing
privat members in GrowAnimation. Next: do the same with other animations. svn path=/trunk/KDE/kdelibs/; revision=1036737
This commit is contained in:
parent
c4cf4ed175
commit
6142e913f6
@ -18,36 +18,11 @@
|
||||
*/
|
||||
|
||||
#include "abstractanimation.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AnimationPrivate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Object the animation(s) should act upon.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
AnimationDirection animDirection;
|
||||
|
||||
/**
|
||||
* Animation distance: displacement factor for animations where
|
||||
* there is change in the position of animated widget.
|
||||
*/
|
||||
qreal animDistance;
|
||||
|
||||
};
|
||||
|
||||
AbstractAnimation::AbstractAnimation(): d(new AnimationPrivate)
|
||||
{
|
||||
@ -69,6 +44,11 @@ QGraphicsWidget* AbstractAnimation::getAnimatedObject()
|
||||
return d->animObject;
|
||||
}
|
||||
|
||||
AnimationPrivate* AbstractAnimation::getAnimationPrivate()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
} //namespace Plasma
|
||||
|
||||
#include <../abstractanimation.moc>
|
||||
|
@ -73,6 +73,8 @@ protected:
|
||||
|
||||
QGraphicsWidget *getAnimatedObject();
|
||||
|
||||
AnimationPrivate *getAnimationPrivate();
|
||||
|
||||
private:
|
||||
|
||||
AnimationPrivate *d;
|
||||
|
@ -18,18 +18,17 @@
|
||||
*/
|
||||
|
||||
#include "grow.h"
|
||||
#include "private/animationprivate_p.h"
|
||||
|
||||
#include <QRect>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
GrowAnimation::GrowAnimation(double factor)
|
||||
: m_factor(factor)
|
||||
{
|
||||
|
||||
getAnimationPrivate()->animFactor = factor;
|
||||
}
|
||||
|
||||
QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
@ -41,12 +40,13 @@ QAbstractAnimation* GrowAnimation::render(QObject* parent){
|
||||
qreal h = geometry.height();
|
||||
|
||||
//compute new geometry values
|
||||
qreal newWidth = w * m_factor;
|
||||
qreal newHeight = h * m_factor;
|
||||
qreal factor = getAnimationPrivate()->animFactor;
|
||||
qreal newWidth = w * factor;
|
||||
qreal newHeight = h * factor;
|
||||
//locfactor is factor by which object must move up and left
|
||||
//to compensate for its growth down and right, to keep the
|
||||
//center in place.
|
||||
qreal locfactor = (m_factor - 1) / 2.0;
|
||||
qreal locfactor = (factor - 1) / 2.0;
|
||||
qreal newX = geometry.x() - w * locfactor;
|
||||
qreal newY = geometry.y() - h * locfactor;
|
||||
|
||||
|
@ -49,9 +49,6 @@ public:
|
||||
protected:
|
||||
virtual QAbstractAnimation* render(QObject* parent = 0);
|
||||
|
||||
private:
|
||||
double m_factor;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
56
private/animationprivate_p.h
Normal file
56
private/animationprivate_p.h
Normal file
@ -0,0 +1,56 @@
|
||||
/***********************************************************************/
|
||||
/* 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
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AnimationPrivate
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Object the animation(s) should act upon.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
AnimationDirection animDirection;
|
||||
|
||||
/**
|
||||
* Animation distance: displacement factor for animations where
|
||||
* there is change in the position of animated widget.
|
||||
*/
|
||||
qreal animDistance;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user