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:
parent
9278caf4a0
commit
51a9b1ac72
@ -366,7 +366,6 @@ endif(PHONON_FOUND)
|
||||
|
||||
install(FILES
|
||||
animations/animation.h
|
||||
animations/pendulumcurve.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/animations COMPONENT Devel)
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
* 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.
|
||||
|
@ -15,13 +15,11 @@
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_ANIMATIONS_PENDULUMCURVE_H
|
||||
#define PLASMA_ANIMATIONS_PENDULUMCURVE_H
|
||||
#ifndef PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
|
||||
#define PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
|
||||
|
||||
#include <QtCore/QEasingCurve>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -32,7 +30,7 @@ namespace Plasma
|
||||
* 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.
|
||||
*/
|
||||
class PLASMA_EXPORT PendulumCurve : public QEasingCurve
|
||||
class PendulumCurve : public QEasingCurve
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -43,4 +41,4 @@ public:
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#endif // PLASMA_ANIMATIONS_PENDULUMCURVE_H
|
||||
#endif // PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
|
35
animator.cpp
35
animator.cpp
@ -32,6 +32,8 @@
|
||||
#include "animations/pixmaptransition_p.h"
|
||||
#include "animations/water_p.h"
|
||||
|
||||
#include "animations/pendulumcurve_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -87,6 +89,39 @@ Plasma::Animation* Animator::create(Animator::Animation type, QObject *parent)
|
||||
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
|
||||
|
||||
#include <animator.moc>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QtGui/QImage>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QAbstractAnimation>
|
||||
#include <QtCore/QEasingCurve>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
@ -74,7 +75,8 @@ public:
|
||||
EaseInCurve = 0,
|
||||
EaseOutCurve,
|
||||
EaseInOutCurve,
|
||||
LinearCurve
|
||||
LinearCurve,
|
||||
PendularCurve
|
||||
};
|
||||
|
||||
enum Movement {
|
||||
@ -95,6 +97,11 @@ public:
|
||||
**/
|
||||
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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user