Added Plasma::Animator::easingCurve() pre-defined easing curves factory.

Using this, Plasma::PendulumCurve now longer needs to be public :-)

svn path=/trunk/KDE/kdelibs/; revision=1118090
This commit is contained in:
Bruno de Oliveira Abinader 2010-04-23 20:55:46 +00:00
parent 9278caf4a0
commit 51a9b1ac72
5 changed files with 48 additions and 9 deletions

View File

@ -366,7 +366,6 @@ endif(PHONON_FOUND)
install(FILES install(FILES
animations/animation.h animations/animation.h
animations/pendulumcurve.h
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/animations COMPONENT Devel) DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/animations COMPONENT Devel)

View File

@ -15,7 +15,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "pendulumcurve.h" #include "pendulumcurve_p.h"
/** /**
* This static method is used to create a custom easing curve type. * This static method is used to create a custom easing curve type.

View File

@ -15,13 +15,11 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef PLASMA_ANIMATIONS_PENDULUMCURVE_H #ifndef PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
#define PLASMA_ANIMATIONS_PENDULUMCURVE_H #define PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
#include <QtCore/QEasingCurve> #include <QtCore/QEasingCurve>
#include <plasma/plasma_export.h>
namespace Plasma namespace Plasma
{ {
@ -32,7 +30,7 @@ namespace Plasma
* This easing curve provides values which are split in 4 parts: * This easing curve provides values which are split in 4 parts:
* from 0 to 1, from 1 to 0, from 0 to -1, and from -1 to 0, in a linear way. * from 0 to 1, from 1 to 0, from 0 to -1, and from -1 to 0, in a linear way.
*/ */
class PLASMA_EXPORT PendulumCurve : public QEasingCurve class PendulumCurve : public QEasingCurve
{ {
public: public:
/** /**
@ -43,4 +41,4 @@ public:
} // namespace Plasma } // namespace Plasma
#endif // PLASMA_ANIMATIONS_PENDULUMCURVE_H #endif // PLASMA_ANIMATIONS_PENDULUMCURVE_P_H

View File

@ -32,6 +32,8 @@
#include "animations/pixmaptransition_p.h" #include "animations/pixmaptransition_p.h"
#include "animations/water_p.h" #include "animations/water_p.h"
#include "animations/pendulumcurve_p.h"
namespace Plasma namespace Plasma
{ {
@ -87,6 +89,39 @@ Plasma::Animation* Animator::create(Animator::Animation type, QObject *parent)
return result; return result;
} }
QEasingCurve Animator::easingCurve(Animator::CurveShape type)
{
QEasingCurve result;
switch (type) {
case EaseInCurve:
result.setType(QEasingCurve::InQuad);
break;
case EaseOutCurve:
result.setType(QEasingCurve::OutQuad);
break;
case EaseInOutCurve:
result.setType(QEasingCurve::InOutQuad);
break;
case LinearCurve:
result.setType(QEasingCurve::Linear);
break;
case PendularCurve:
result = PendulumCurve();
break;
default:
kDebug() << "Unsupported easing curve type.";
break;
}
return result;
}
} // namespace Plasma } // namespace Plasma
#include <animator.moc> #include <animator.moc>

View File

@ -24,6 +24,7 @@
#include <QtGui/QImage> #include <QtGui/QImage>
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QAbstractAnimation> #include <QtCore/QAbstractAnimation>
#include <QtCore/QEasingCurve>
#include <plasma/plasma_export.h> #include <plasma/plasma_export.h>
@ -74,7 +75,8 @@ public:
EaseInCurve = 0, EaseInCurve = 0,
EaseOutCurve, EaseOutCurve,
EaseInOutCurve, EaseInOutCurve,
LinearCurve LinearCurve,
PendularCurve
}; };
enum Movement { enum Movement {
@ -95,6 +97,11 @@ public:
**/ **/
static Plasma::Animation *create(Animator::Animation type, QObject *parent = 0); static Plasma::Animation *create(Animator::Animation type, QObject *parent = 0);
/**
* Factory to build new custom easing curves.
*/
static QEasingCurve easingCurve(Animator::CurveShape type);
/** /**
* Starts a standard animation on a QGraphicsItem. * Starts a standard animation on a QGraphicsItem.
* *