mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
plasma: simplify animations classes
the proxy class Plasma::EasingAnimation is simply redundant, just one more virtual function call which slows the animations Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
eb37060455
commit
935b228484
17 changed files with 71 additions and 165 deletions
|
@ -24,7 +24,6 @@ set(plasma_LIB_SRCS
|
|||
abstracttoolbox.cpp
|
||||
animator.cpp
|
||||
animations/animation.cpp
|
||||
animations/easinganimation.cpp
|
||||
animations/fade.cpp
|
||||
animations/pixmaptransition.cpp
|
||||
animations/pulser.cpp
|
||||
|
|
|
@ -26,10 +26,9 @@
|
|||
namespace Plasma
|
||||
{
|
||||
|
||||
|
||||
AnimationPrivate::AnimationPrivate()
|
||||
: easingCurve(QEasingCurve::Linear),
|
||||
duration(250)
|
||||
duration(250)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -79,18 +79,18 @@ public:
|
|||
* \ref Animator::create factory).
|
||||
*
|
||||
*/
|
||||
explicit Animation(QObject* parent = 0);
|
||||
explicit Animation(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
~Animation() = 0;
|
||||
virtual ~Animation();
|
||||
|
||||
/**
|
||||
* Set the widget on which the animation is to be performed.
|
||||
* @param widget The QGraphicsWidget to be animated.
|
||||
*/
|
||||
void setTargetWidget(QGraphicsWidget* widget);
|
||||
void setTargetWidget(QGraphicsWidget *widget);
|
||||
|
||||
/**
|
||||
* @return The widget that the animation will be performed upon
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "easinganimation_p.h"
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
EasingAnimation::EasingAnimation(QObject *parent)
|
||||
: Animation(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void EasingAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
updateEffectiveTime(easingCurve().valueForProgress(currentTime / qreal(qMax(1, duration()))) * duration());
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include "moc_easinganimation_p.cpp"
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_EASINGANIMATION_H
|
||||
#define PLASMA_EASINGANIMATION_H
|
||||
|
||||
#include "animation.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
|
||||
class EasingAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EasingAnimation(QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
virtual void updateEffectiveTime(int currentTime) = 0;
|
||||
|
||||
private:
|
||||
void updateCurrentTime(int currentTime);
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#endif // PLASMA_EASINGANIMATION_H
|
||||
|
|
@ -18,25 +18,20 @@
|
|||
*/
|
||||
|
||||
#include "fade_p.h"
|
||||
#include "kdebug.h"
|
||||
|
||||
#include <QRect>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
FadeAnimation::FadeAnimation(QObject *parent)
|
||||
: EasingAnimation(parent),
|
||||
: Animation(parent),
|
||||
m_startOpacity(0),
|
||||
m_targetOpacity(1)
|
||||
{
|
||||
}
|
||||
|
||||
FadeAnimation::~FadeAnimation()
|
||||
{
|
||||
}
|
||||
|
||||
void FadeAnimation::setStartOpacity(qreal factor)
|
||||
{
|
||||
m_startOpacity = qBound(qreal(0.0), factor, qreal(1.0));
|
||||
|
@ -71,11 +66,11 @@ void FadeAnimation::updateState(QAbstractAnimation::State newState, QAbstractAni
|
|||
}
|
||||
}
|
||||
|
||||
void FadeAnimation::updateEffectiveTime(int currentTime)
|
||||
void FadeAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = targetWidget();
|
||||
if (w) {
|
||||
qreal delta = currentTime / qreal(duration());
|
||||
qreal delta = easingCurve().valueForProgress(qreal(currentTime) / qreal(duration()));
|
||||
delta *= m_startOpacity - m_targetOpacity;
|
||||
w->setOpacity(m_startOpacity - delta);
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
#ifndef PLASMA_ANIMATIONS_FADE_P_H
|
||||
#define PLASMA_ANIMATIONS_FADE_P_H
|
||||
|
||||
#include <plasma/animations/easinganimation_p.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
#include "animations/animation.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
@ -38,7 +37,7 @@ namespace Plasma
|
|||
* value to a target value. The range is 0 (full translucent) to 1 (full
|
||||
* opaque).
|
||||
*/
|
||||
class FadeAnimation : public EasingAnimation
|
||||
class FadeAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal startOpacity READ startOpacity WRITE setStartOpacity)
|
||||
|
@ -46,10 +45,7 @@ class FadeAnimation : public EasingAnimation
|
|||
|
||||
public:
|
||||
/** Default constructor */
|
||||
explicit FadeAnimation(QObject *parent = 0);
|
||||
|
||||
/** Destructor */
|
||||
virtual ~FadeAnimation();
|
||||
explicit FadeAnimation(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* Access start opacity of the target widget.
|
||||
|
@ -59,6 +55,7 @@ public:
|
|||
* @return The opacity (range is 0 to 1).
|
||||
*/
|
||||
qreal startOpacity() const;
|
||||
|
||||
/**
|
||||
* Set the start opacity of the target widget.
|
||||
*
|
||||
|
@ -75,6 +72,7 @@ public:
|
|||
* @return The opacity (range is 0 to 1).
|
||||
*/
|
||||
qreal targetOpacity() const;
|
||||
|
||||
/**
|
||||
* Set the final opacity of the target widget.
|
||||
*
|
||||
|
@ -85,7 +83,7 @@ public:
|
|||
|
||||
protected:
|
||||
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||
void updateEffectiveTime(int currentTime);
|
||||
void updateCurrentTime(int currentTime);
|
||||
|
||||
private:
|
||||
/** Initial opacity */
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace Plasma
|
|||
{
|
||||
|
||||
GeometryAnimation::GeometryAnimation(QObject *parent)
|
||||
: EasingAnimation(parent),
|
||||
: Animation(parent),
|
||||
m_startGeometry(-1, -1, -1, -1)
|
||||
{
|
||||
}
|
||||
|
@ -70,19 +70,26 @@ void GeometryAnimation::updateState(QAbstractAnimation::State newState, QAbstrac
|
|||
}
|
||||
}
|
||||
|
||||
void GeometryAnimation::updateEffectiveTime(int currentTime)
|
||||
void GeometryAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = targetWidget();
|
||||
if (w) {
|
||||
const qreal delta = currentTime / qreal(duration());
|
||||
const qreal delta = easingCurve().valueForProgress(qreal(currentTime) / qreal(duration()));
|
||||
|
||||
QRectF newGeo;
|
||||
|
||||
newGeo.moveTopLeft(QPointF(m_startGeometry.left()*(1-delta) + m_targetGeometry.left()*(delta),
|
||||
m_startGeometry.top()*(1-delta) + m_targetGeometry.top()*(delta)));
|
||||
newGeo.moveTopLeft(
|
||||
QPointF(
|
||||
m_startGeometry.left()*(1-delta) + m_targetGeometry.left()*(delta),
|
||||
m_startGeometry.top()*(1-delta) + m_targetGeometry.top()*(delta)
|
||||
)
|
||||
);
|
||||
if (m_startGeometry.size() != m_targetGeometry.size()) {
|
||||
newGeo.setSize(QSizeF(m_startGeometry.width()*(1-delta) + m_targetGeometry.width()*(delta),
|
||||
m_startGeometry.height()*(1-delta) + m_targetGeometry.height()*(delta)));
|
||||
newGeo.setSize(
|
||||
QSizeF(
|
||||
m_startGeometry.width()*(1-delta) + m_targetGeometry.width()*(delta),
|
||||
m_startGeometry.height()*(1-delta) + m_targetGeometry.height()*(delta)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
newGeo.setSize(m_targetGeometry.size());
|
||||
}
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
#ifndef PLASMA_ANIMATIONS_GEOMETRY_P_H
|
||||
#define PLASMA_ANIMATIONS_GEOMETRY_P_H
|
||||
|
||||
#include <plasma/animations/easinganimation_p.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
#include "animations/animation.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
@ -36,7 +35,7 @@ namespace Plasma
|
|||
* Use this class when you want to change the geometry of an QGraphicsWidget
|
||||
* in an animated way (you should at least set the target geometry).
|
||||
*/
|
||||
class GeometryAnimation : public EasingAnimation
|
||||
class GeometryAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QRectF startGeometry READ startGeometry WRITE setStartGeometry)
|
||||
|
@ -44,7 +43,7 @@ class GeometryAnimation : public EasingAnimation
|
|||
|
||||
public:
|
||||
/** Default constructor */
|
||||
explicit GeometryAnimation(QObject *parent = 0);
|
||||
explicit GeometryAnimation(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* Access the initial geometry of animated widget.
|
||||
|
@ -54,6 +53,7 @@ public:
|
|||
* @return Start geometry.
|
||||
*/
|
||||
QRectF startGeometry() const;
|
||||
|
||||
/**
|
||||
* Set the initial geometry of animated widget.
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
|
||||
protected:
|
||||
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||
void updateEffectiveTime(int currentTime);
|
||||
void updateCurrentTime(int currentTime);
|
||||
|
||||
private:
|
||||
/** Initial geometry */
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Plasma
|
|||
{
|
||||
|
||||
PixmapTransition::PixmapTransition(QObject *parent)
|
||||
: EasingAnimation(parent),
|
||||
: Animation(parent),
|
||||
m_cache(false),
|
||||
m_dirty(false)
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ void PixmapTransition::setStartPixmap(const QPixmap &pixmap)
|
|||
m_startPixmap = pixmap;
|
||||
|
||||
//this will center the pixmaps if needed
|
||||
updateEffectiveTime(0);
|
||||
updateCurrentTime(0);
|
||||
}
|
||||
|
||||
QPixmap PixmapTransition::startPixmap() const
|
||||
|
@ -62,7 +62,7 @@ void PixmapTransition::setTargetPixmap(const QPixmap &pixmap)
|
|||
|
||||
m_targetPixmap = pixmap;
|
||||
|
||||
updateEffectiveTime(0);
|
||||
updateCurrentTime(0);
|
||||
}
|
||||
|
||||
void PixmapTransition::setUsesCache(bool cache)
|
||||
|
@ -160,7 +160,7 @@ void PixmapTransition::updateState(QAbstractAnimation::State newState, QAbstract
|
|||
m_dirty = true;
|
||||
}
|
||||
|
||||
void PixmapTransition::updateEffectiveTime(int currentTime)
|
||||
void PixmapTransition::updateCurrentTime(int currentTime)
|
||||
{
|
||||
Q_UNUSED(currentTime)
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
#ifndef PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H
|
||||
#define PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H
|
||||
|
||||
#include <plasma/animations/easinganimation_p.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
#include "animations/animation.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
@ -37,7 +36,7 @@ namespace Plasma
|
|||
*
|
||||
* Effect that paints a transition between two pixmaps
|
||||
*/
|
||||
class PixmapTransition : public EasingAnimation
|
||||
class PixmapTransition : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QPixmap startPixmap READ startPixmap WRITE setStartPixmap)
|
||||
|
@ -46,7 +45,7 @@ class PixmapTransition : public EasingAnimation
|
|||
Q_PROPERTY(QPixmap currentPixmap READ currentPixmap)
|
||||
|
||||
public:
|
||||
explicit PixmapTransition(QObject *parent = 0);
|
||||
explicit PixmapTransition(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @return The first pixmap of the animation
|
||||
|
@ -56,7 +55,7 @@ public:
|
|||
/**
|
||||
* Set the first pixmap of the animation
|
||||
*/
|
||||
void setStartPixmap(const QPixmap &);
|
||||
void setStartPixmap(const QPixmap &pixmap);
|
||||
|
||||
/**
|
||||
* The pixmap the animation will evolve to
|
||||
|
@ -66,7 +65,7 @@ public:
|
|||
/**
|
||||
* Set the pixmap the animation will evolve to
|
||||
*/
|
||||
void setTargetPixmap(const QPixmap &);
|
||||
void setTargetPixmap(const QPixmap &pixmap);
|
||||
|
||||
/**
|
||||
* @return the current pixmap
|
||||
|
@ -87,7 +86,7 @@ public:
|
|||
|
||||
protected:
|
||||
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||
void updateEffectiveTime(int currentTime);
|
||||
void updateCurrentTime(int currentTime);
|
||||
|
||||
private:
|
||||
QPixmap alignedTargetPixmap() const;
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
#include <QEvent>
|
||||
#include <QGraphicsWidget>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QWeakPointer>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
@ -30,7 +28,7 @@ namespace Plasma
|
|||
{
|
||||
|
||||
PulseAnimation::PulseAnimation(QObject *parent)
|
||||
: EasingAnimation(parent),
|
||||
: Animation(parent),
|
||||
m_zvalue(0),
|
||||
m_scale(0),
|
||||
m_opacity(0),
|
||||
|
@ -111,16 +109,17 @@ void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAn
|
|||
}
|
||||
}
|
||||
|
||||
void PulseAnimation::updateEffectiveTime(int currentTime)
|
||||
void PulseAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
if (m_under.data()) {
|
||||
qreal delta = currentTime / qreal(duration());
|
||||
const qreal progress = easingCurve().valueForProgress(qreal(currentTime) / qreal(duration()));
|
||||
qreal delta = progress;
|
||||
|
||||
m_under.data()->setScale(delta);
|
||||
delta = (1 - m_endScale) * delta;
|
||||
m_under.data()->setScale(1 - delta);
|
||||
|
||||
delta = currentTime / qreal(duration());
|
||||
delta = progress;
|
||||
if (direction() == Forward) {
|
||||
m_under.data()->setOpacity(1.0 - delta);
|
||||
} else if (direction() == Backward) {
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#ifndef PLASMA_ANIMATIONS_PULSER_P_H
|
||||
#define PLASMA_ANIMATIONS_PULSER_P_H
|
||||
|
||||
#include <plasma/animations/easinganimation_p.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
#include "animations/animation.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
@ -38,14 +37,14 @@ class WidgetSnapShot;
|
|||
* Effect that pulses a shadow copy of any QGraphicsWidget making
|
||||
* it more translucent and bigger along the time until it vanishes.
|
||||
*/
|
||||
class PulseAnimation : public EasingAnimation
|
||||
class PulseAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal targetScale READ targetScale WRITE setTargetScale)
|
||||
|
||||
public:
|
||||
/** Default Constructor */
|
||||
explicit PulseAnimation(QObject *parent = 0);
|
||||
explicit PulseAnimation(QObject *parent = nullptr);
|
||||
|
||||
/** Destructor */
|
||||
~PulseAnimation();
|
||||
|
@ -75,7 +74,7 @@ public:
|
|||
|
||||
protected:
|
||||
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||
void updateEffectiveTime(int currentTime);
|
||||
void updateCurrentTime(int currentTime);
|
||||
void setCopy();
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
*/
|
||||
|
||||
#include "slide_p.h"
|
||||
#include "kdebug.h"
|
||||
|
||||
#include <QtCore/qpoint.h>
|
||||
#include <kdebug.h>
|
||||
#include <QPoint>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
SlideAnimation::SlideAnimation(QObject *parent, MovementDirection direction, qreal distance)
|
||||
: EasingAnimation(parent)
|
||||
: Animation(parent)
|
||||
{
|
||||
setMovementDirection(direction);
|
||||
setDistance(distance);
|
||||
|
@ -63,11 +63,11 @@ Animation::MovementDirection SlideAnimation::movementDirection() const
|
|||
return m_animDirection;
|
||||
}
|
||||
|
||||
void SlideAnimation::updateEffectiveTime(int currentTime)
|
||||
void SlideAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = targetWidget();
|
||||
if (w && state() == QAbstractAnimation::Running) {
|
||||
const qreal delta = currentTime / qreal(duration());
|
||||
const qreal delta = easingCurve().valueForProgress(qreal(currentTime) / qreal(duration()));
|
||||
w->setPos(m_startPos * (1-delta) + (m_targetPos * delta));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,9 +24,7 @@
|
|||
#ifndef PLASMA_ANIMATIONS_SLIDE_P_H
|
||||
#define PLASMA_ANIMATIONS_SLIDE_P_H
|
||||
|
||||
#include "plasma/animations/easinganimation_p.h"
|
||||
#include "plasma/plasma_export.h"
|
||||
#include "plasma/plasma.h"
|
||||
#include "animations/animation.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
@ -38,7 +36,7 @@ namespace Plasma
|
|||
* Effect that moves the object a specific distance in a given direction. The
|
||||
* object is optionally made invisible at the beginning or at the end.
|
||||
*/
|
||||
class SlideAnimation : public EasingAnimation
|
||||
class SlideAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
|
||||
|
@ -46,7 +44,7 @@ class SlideAnimation : public EasingAnimation
|
|||
Q_PROPERTY(QPointF distancePointF READ distancePointF WRITE setDistancePointF)
|
||||
|
||||
public:
|
||||
explicit SlideAnimation(QObject *parent = 0, MovementDirection direction = MoveUp, qreal distance = 0);
|
||||
explicit SlideAnimation(QObject *parent = nullptr, MovementDirection direction = MoveUp, qreal distance = 0);
|
||||
|
||||
/**
|
||||
* Set the animation distance
|
||||
|
@ -74,7 +72,7 @@ public:
|
|||
Animation::MovementDirection movementDirection() const;
|
||||
|
||||
protected:
|
||||
void updateEffectiveTime(int currentTime);
|
||||
void updateCurrentTime(int currentTime);
|
||||
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,15 +18,14 @@
|
|||
*/
|
||||
|
||||
#include "zoom_p.h"
|
||||
|
||||
#include <kdebug.h>
|
||||
#include "kdebug.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
ZoomAnimation::ZoomAnimation(QObject *parent)
|
||||
: EasingAnimation(parent),
|
||||
m_zoom(0)
|
||||
: Animation(parent),
|
||||
m_zoom(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -55,11 +54,11 @@ void ZoomAnimation::updateState(QAbstractAnimation::State newState, QAbstractAni
|
|||
}
|
||||
}
|
||||
|
||||
void ZoomAnimation::updateEffectiveTime(int currentTime)
|
||||
void ZoomAnimation::updateCurrentTime(int currentTime)
|
||||
{
|
||||
QGraphicsWidget *w = targetWidget();
|
||||
if (w) {
|
||||
qreal delta = currentTime / qreal(duration());
|
||||
qreal delta = easingCurve().valueForProgress(qreal(currentTime) / qreal(duration()));
|
||||
if (m_zoom != 1) {
|
||||
delta = (1 - m_zoom) * delta;
|
||||
w->setScale(1 - delta);
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
#ifndef PLASMA_ANIMATIONS_ZOOM_P_H
|
||||
#define PLASMA_ANIMATIONS_ZOOM_P_H
|
||||
|
||||
#include <plasma/animations/easinganimation_p.h>
|
||||
#include <plasma/plasma_export.h>
|
||||
#include "animations/animation.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
@ -35,20 +34,20 @@ namespace Plasma
|
|||
* @short Zoom Animation
|
||||
*
|
||||
*/
|
||||
class ZoomAnimation : public EasingAnimation
|
||||
class ZoomAnimation : public Animation
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qreal zoom READ zoom WRITE setZoom)
|
||||
|
||||
public:
|
||||
explicit ZoomAnimation(QObject *parent = 0);
|
||||
explicit ZoomAnimation(QObject *parent = nullptr);
|
||||
|
||||
qreal zoom() const;
|
||||
void setZoom(qreal);
|
||||
|
||||
protected:
|
||||
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
|
||||
void updateEffectiveTime(int currentTime);
|
||||
void updateCurrentTime(int currentTime);
|
||||
|
||||
private:
|
||||
qreal m_zoom;
|
||||
|
|
Loading…
Add table
Reference in a new issue