From 6142e913f6ff0b2f42c8ff6a279b00e2643c4ad1 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Da Silva Date: Sat, 17 Oct 2009 17:35:02 +0000 Subject: [PATCH] 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 --- animations/abstractanimation.cpp | 32 ++++-------------- animations/abstractanimation.h | 2 ++ animations/grow.cpp | 12 +++---- animations/grow.h | 3 -- private/animationprivate_p.h | 56 ++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 private/animationprivate_p.h diff --git a/animations/abstractanimation.cpp b/animations/abstractanimation.cpp index 72e0e2b5f..c3d91b0af 100644 --- a/animations/abstractanimation.cpp +++ b/animations/abstractanimation.cpp @@ -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> diff --git a/animations/abstractanimation.h b/animations/abstractanimation.h index 38df47566..b9b065654 100644 --- a/animations/abstractanimation.h +++ b/animations/abstractanimation.h @@ -73,6 +73,8 @@ protected: QGraphicsWidget *getAnimatedObject(); + AnimationPrivate *getAnimationPrivate(); + private: AnimationPrivate *d; diff --git a/animations/grow.cpp b/animations/grow.cpp index 1ca14b4b3..19e956686 100644 --- a/animations/grow.cpp +++ b/animations/grow.cpp @@ -18,18 +18,17 @@ */ #include "grow.h" +#include "private/animationprivate_p.h" #include - #include 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; diff --git a/animations/grow.h b/animations/grow.h index 608f8d593..f07c5a274 100644 --- a/animations/grow.h +++ b/animations/grow.h @@ -49,9 +49,6 @@ public: protected: virtual QAbstractAnimation* render(QObject* parent = 0); -private: - double m_factor; - }; } diff --git a/private/animationprivate_p.h b/private/animationprivate_p.h new file mode 100644 index 000000000..544634d4b --- /dev/null +++ b/private/animationprivate_p.h @@ -0,0 +1,56 @@ +/***********************************************************************/ +/* animationprivate.h */ +/* */ +/* Copyright(C) 2009 Adenilson Cavalcanti */ +/* */ +/* 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