Reverting "Added bouncing effect for Rotation animation"

svn path=/trunk/KDE/kdelibs/; revision=1112210
This commit is contained in:
Bruno de Oliveira Abinader 2010-04-07 15:56:21 +00:00
parent 7507808e7c
commit 4f301b339f
2 changed files with 7 additions and 64 deletions

View File

@ -26,13 +26,9 @@
namespace Plasma
{
const int RotationAnimation::s_bounceSteps = 10;
RotationAnimation::RotationAnimation(QObject *parent, bool isBounceable, qint8 reference, Qt::Axis axis, qreal angle)
: Animation(parent),
m_bounceStep(0)
RotationAnimation::RotationAnimation(QObject *parent, qint8 reference, Qt::Axis axis, qreal angle)
: Animation(parent)
{
setBounceable(isBounceable);
setAngle(angle);
setAxis(axis);
setReference(reference);
@ -44,16 +40,6 @@ RotationAnimation::~RotationAnimation()
{
}
bool RotationAnimation::isBounceable() const
{
return m_isBounceable;
}
void RotationAnimation::setBounceable(const bool isBounceable)
{
m_isBounceable = isBounceable;
}
Qt::Axis RotationAnimation::axis() const
{
return m_axis;
@ -168,18 +154,7 @@ void RotationAnimation::updateState(QAbstractAnimation::State newState, QAbstrac
if ((oldState == Stopped) && (newState == Running)) {
m_rotation->setAngle(direction() == Forward ? 0 : angle());
} else if (newState == Stopped) {
// Do not bounce if animation is part of a group
if (!m_isBounceable || group()) {
m_rotation->setAngle(direction() == Forward ? angle() : 0);
} else {
setDirection(direction() == Forward ? Backward : Forward);
if (++m_bounceStep < s_bounceSteps) {
start();
} else {
m_rotation->setAngle(direction() == Forward ? 0 : angle());
m_bounceStep = 0;
}
}
m_rotation->setAngle(direction() == Forward ? angle() : 0);
}
}
@ -189,18 +164,7 @@ void RotationAnimation::updateCurrentTime(int currentTime)
if (w) {
qreal delta = Animation::easingCurve().valueForProgress(
currentTime / qreal(duration()));
const qreal currentAngle = angle();
if (m_isBounceable) {
const qreal percentage = 1 - qBound(0.0, qreal(m_bounceStep) / qreal(s_bounceSteps), 1.0);
if (m_bounceStep == 0) { // initial bounce
delta = qBound(0.0, currentAngle * percentage * delta * 0.5, (currentAngle / 2.0));
} else {
delta -= 0.5;
delta = qBound(-(currentAngle / 2.0), currentAngle * percentage * delta, (currentAngle / 2.0));
}
} else {
delta = qBound(0.0, currentAngle * delta, currentAngle);
}
delta = angle() * delta;
m_rotation->setAngle(delta);
}
}

View File

@ -33,17 +33,16 @@ class QGraphicsRotation;
namespace Plasma {
/**
* @class RotationAnimation plasma/animations/rotation_p.h
* @short 3D rotation animation.
* @short 2D rotation animation.
*
* This animation rotates a QGraphicsWidget in a axis (bounce, reference, axis
* and angle can be defined using properties). See also
* This animation rotates a QGraphicsWidget in a axis (reference and
* axis can be defined using properties). See also
* \ref StackedRotationAnimation.
*/
class RotationAnimation : public Animation
{
Q_OBJECT
Q_PROPERTY(bool isBounceable READ isBounceable WRITE setBounceable)
Q_PROPERTY(Qt::Axis axis READ axis WRITE setAxis)
Q_PROPERTY(qint8 reference READ reference WRITE setReference)
Q_PROPERTY(qreal angle READ angle WRITE setAngle)
@ -52,14 +51,12 @@ public:
/** Default constructor
*
* @param parent Animation object parent.
* @param isBounceable Animation bounce behavior.
* @param reference See \ref Animation::Reference.
* @param axis Which axis to rotate (XAxis, YAxis, ZAxis).
* @param angle Rotation angle (0 to 360)
*
*/
explicit RotationAnimation(QObject *parent = 0,
bool isBounceable = false,
qint8 reference = Center,
Qt::Axis axis = Qt::ZAxis,
qreal angle = 180);
@ -67,18 +64,6 @@ public:
/** Destructor */
~RotationAnimation();
/**
* get animation bounce behavior
*/
bool isBounceable() const;
/**
* set animation bounce behavior (it can be bounceable only if not part of
* an animation group)
* @arg isBounceable
*/
void setBounceable(const bool isBounceable);
/**
* get animation rotation axis (e.g. YAxis, ZAxis, XAxis)
*/
@ -121,12 +106,6 @@ protected:
private:
/** Rotation transform object */
QGraphicsRotation *m_rotation;
/** Actual number of bounce steps */
int m_bounceStep;
/** Number of bounce steps */
static const int s_bounceSteps;
/** Animation bounce behavior */
bool m_isBounceable;
/** Rotation angle */
qreal m_angle;
/** Axis where to perform the rotation */