plasm: drop animations support

this will (most importantly) break some applets from kde-workspace
and could use a review + some cleanups (like headers inclusions,
variables declarations, etc.) but it's pretty much complete
This commit is contained in:
Ivailo Monev 2015-10-04 20:17:40 +03:00
parent 7d041899a7
commit f54c727f92
78 changed files with 21 additions and 5433 deletions

View file

@ -733,8 +733,6 @@ install(FILES
Plasma/AbstractDialogManager Plasma/AbstractDialogManager
Plasma/AbstractRunner Plasma/AbstractRunner
Plasma/AbstractToolBox Plasma/AbstractToolBox
Plasma/Animation
Plasma/Animator
Plasma/Applet Plasma/Applet
Plasma/AppletScript Plasma/AppletScript
Plasma/BusyWidget Plasma/BusyWidget

View file

@ -1 +0,0 @@
#include "../../plasma/animation.h"

View file

@ -1 +0,0 @@
#include "../../plasma/animator.h"

View file

@ -51,25 +51,6 @@ set(plasma_LIB_SRCS
package.cpp package.cpp
abstractrunner.cpp abstractrunner.cpp
abstracttoolbox.cpp abstracttoolbox.cpp
animator.cpp
animations/animation.cpp
animations/animationscriptengine.cpp
animations/bindings/easingcurve.cpp
animations/easinganimation.cpp
animations/fade.cpp
animations/grow.cpp
animations/javascriptanimation.cpp
animations/pendulumcurve.cpp
animations/pixmaptransition.cpp
animations/pulser.cpp
animations/rotation.cpp
animations/rotationstacked.cpp
animations/slide.cpp
animations/stackedlayout.cpp
animations/geometry.cpp
animations/water.cpp
animations/widgetsnapshot.cpp
animations/zoom.cpp
applet.cpp applet.cpp
configloader.cpp configloader.cpp
containment.cpp containment.cpp
@ -218,8 +199,6 @@ set(plasma_LIB_INCLUDES
abstractdialogmanager.h abstractdialogmanager.h
abstractrunner.h abstractrunner.h
abstracttoolbox.h abstracttoolbox.h
animations/animation.h
animator.h
applet.h applet.h
configloader.h configloader.h
containment.h containment.h
@ -304,12 +283,6 @@ if(PHONON_FOUND)
endif(PHONON_FOUND) endif(PHONON_FOUND)
install(FILES install(FILES
animations/animation.h
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/animations COMPONENT Devel)
install(FILES
data/servicetypes/plasma-animator.desktop
data/servicetypes/plasma-applet.desktop data/servicetypes/plasma-applet.desktop
data/servicetypes/plasma-applet-popupapplet.desktop data/servicetypes/plasma-applet-popupapplet.desktop
data/servicetypes/plasma-containment.desktop data/servicetypes/plasma-containment.desktop

View file

@ -1,92 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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 "animation.h"
#include "private/animationprivate_p.h"
#include <QtCore/qmap.h>
#include <QObject>
#include <QParallelAnimationGroup>
#include <QSequentialAnimationGroup>
#include <QDebug>
#include <kdebug.h>
#include <kglobalsettings.h>
namespace Plasma
{
AnimationPrivate::AnimationPrivate()
: easingCurve(QEasingCurve::Linear),
duration(250)
{
}
Animation::Animation(QObject* parent)
: QAbstractAnimation(parent),
d(new AnimationPrivate)
{
}
Animation::~Animation()
{
delete d;
}
int Animation::duration() const
{
return d->duration;
}
void Animation::setDuration(int duration)
{
d->duration = qMax(0, duration);
}
void Animation::setTargetWidget(QGraphicsWidget* widget)
{
d->animObject = widget;
if (parent() == 0) {
setParent(widget);
}
}
QGraphicsWidget* Animation::targetWidget() const
{
return d->animObject.data();
}
void Animation::setEasingCurve(const QEasingCurve &curve)
{
d->easingCurve = curve;
}
QEasingCurve Animation::easingCurve() const
{
return d->easingCurve;
}
void Animation::updateCurrentTime(int currentTime)
{
Q_UNUSED(currentTime)
}
} //namespace Plasma
#include "moc_animation.cpp"

View file

@ -1,153 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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.
*/
/**
* @file This file contains the abstract base class for all singular
* animations.
*/
#ifndef PLASMA_ANIMATION_H
#define PLASMA_ANIMATION_H
#include <QtGui/QGraphicsWidget>
#include <QtCore/QObject>
#include <QtCore/QPropertyAnimation>
#include <QtCore/QAbstractAnimation>
#include <QtCore/QEasingCurve>
#include <plasma/plasma_export.h>
#include <plasma/plasma.h>
namespace Plasma
{
class AnimationPrivate;
/**
* @brief Abstract representation of a single animation.
* @since 4.4
*/
class PLASMA_EXPORT Animation : public QAbstractAnimation
{
Q_OBJECT
Q_ENUMS(Reference)
Q_ENUMS(MovementDirection)
Q_PROPERTY(int duration READ duration WRITE setDuration)
Q_PROPERTY(QEasingCurve easingCurve READ easingCurve WRITE setEasingCurve)
Q_PROPERTY(QGraphicsWidget *targetWidget READ targetWidget WRITE setTargetWidget)
public:
/**
* Get the animation duration. It can be set using the property duration.
* @return duration in ms.
*/
int duration() const;
/**
* Animation movement reference (used by \ref RotationAnimation).
*/
enum ReferenceFlag {
Center = 0,
Up = 0x1,
Down = 0x2,
Left = 0x4,
Right = 0x8
};
Q_DECLARE_FLAGS(Reference, ReferenceFlag)
/**
* Animation movement direction.
*/
enum MovementDirectionFlag {
MoveAny = 0,
MoveUp = 0x1,
MoveRight = 0x2,
MoveDown = 0x4,
MoveLeft = 0x8
};
Q_DECLARE_FLAGS(MovementDirection, MovementDirectionFlag)
/**
* Default constructor.
*
* @param parent Object parent (might be set when using
* \ref Animator::create factory).
*
*/
explicit Animation(QObject* parent = 0);
/**
* Destructor.
*/
~Animation() = 0;
/**
* Set the widget on which the animation is to be performed.
* @param widget The QGraphicsWidget to be animated.
*/
void setTargetWidget(QGraphicsWidget* widget);
/**
* @return The widget that the animation will be performed upon
*/
QGraphicsWidget *targetWidget() const;
/**
* Set the animation easing curve type
*/
void setEasingCurve(const QEasingCurve &curve);
/**
* Get the animation easing curve type
*/
QEasingCurve easingCurve() const;
protected:
/**
* Change the animation duration. Default is 250ms.
* @param duration The new duration of the animation.
*/
virtual void setDuration(int duration = 250);
/**
* QAbstractAnimation will call this method while the animation
* is running. Each specialized animation class should implement
* the correct behavior for it.
* @param currentTime Slapsed time using the \ref duration as reference
* (it will be from duration up to zero if the animation is running
* backwards).
*/
virtual void updateCurrentTime(int currentTime);
private:
/**
* Internal pimple (actually is used as a data structure, see
* \ref AnimationPrivate).
*/
AnimationPrivate *const d;
};
} //namespace Plasma
#endif

View file

@ -1,219 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* 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.
*/
/* TODO:
*
* - cleanup debug messages
*/
#include "animationscriptengine_p.h"
#include <QFile>
#include <QtCore/qmetaobject.h>
#include <QParallelAnimationGroup>
#include <QPauseAnimation>
#include <QSequentialAnimationGroup>
#include <QTextStream>
#include <kdebug.h>
#include <klocale.h>
#include "animator.h"
#include "javascriptanimation_p.h"
namespace Plasma
{
QScriptValue constructEasingCurveClass(QScriptEngine *engine);
namespace AnimationScriptEngine
{
QScriptEngine* inst = 0;
QHash<QString, QScriptValue> s_animFuncs;
QSet<QString> s_animFailures;
QString s_prefix;
QScriptValue animation(const QString &anim)
{
return s_animFuncs.value(anim);
}
bool isAnimationRegistered(const QString &anim)
{
return s_animFuncs.contains(anim);
}
void addToLoadFailures(const QString &anim)
{
s_animFailures.insert(anim);
}
bool animationFailedToLoad(const QString &anim)
{
return s_animFailures.contains(anim);
}
void clearAnimations()
{
s_animFuncs.clear();
s_animFailures.clear();
delete inst;
inst = 0;
}
QScriptValue registerAnimation(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() > 1) {
const QString name = s_prefix + context->argument(0).toString();
if (!s_animFuncs.contains(name)) {
const QScriptValue func = context->argument(1);
if (func.isFunction()) {
s_animFuncs.insert(name, func);
}
}
}
return engine->undefinedValue();
}
QObject *extractParent(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
return context->thisObject().property("__plasma_javascriptanimation").toQObject();
}
QScriptValue animationGroup(QScriptContext *context, QScriptEngine *engine)
{
QObject *parent = extractParent(context, engine);
if (!parent) {
return engine->undefinedValue();
}
QSequentialAnimationGroup *group = new QSequentialAnimationGroup(parent);
return engine->newQObject(group);
}
QScriptValue parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine)
{
QObject *parent = extractParent(context, engine);
if (!parent) {
return engine->undefinedValue();
}
QParallelAnimationGroup *group = new QParallelAnimationGroup(parent);
return engine->newQObject(group);
}
void registerEnums(QScriptValue &scriptValue, const QMetaObject &meta)
{
//manually create enum values. ugh
QScriptEngine *engine = scriptValue.engine();
for (int i = 0; i < meta.enumeratorCount(); ++i) {
QMetaEnum e = meta.enumerator(i);
//kDebug() << e.name();
for (int i=0; i < e.keyCount(); ++i) {
//kDebug() << e.key(i) << e.value(i);
scriptValue.setProperty(e.key(i), QScriptValue(engine, e.value(i)));
}
}
}
QScriptValue animation(QScriptContext *context, QScriptEngine *engine)
{
if (context->argumentCount() != 1) {
return context->throwError(i18n("animation() takes one argument"));
}
QObject *parent = extractParent(context, engine);
QAbstractAnimation *anim = 0;
if (context->argument(0).isString()) {
const QString animName = context->argument(0).toString();
anim = Plasma::Animator::create(animName, parent);
} else {
int animId = context->argument(0).toInt32();
if (animId == JavascriptAnimation::PauseAnimation) {
anim = new QPauseAnimation(parent);
} else if (animId == JavascriptAnimation::PropertyAnimation) {
anim = new QPropertyAnimation(parent);
} else {
anim = Plasma::Animator::create(static_cast<Animator::Animation>(animId), parent);
}
}
if (anim) {
QScriptValue value = engine->newQObject(anim);
registerEnums(value, *anim->metaObject());
return value;
}
return context->throwError(i18n("%1 is not a known animation type", context->argument(0).isString()));
}
QScriptEngine *globalEngine()
{
if (!inst) {
inst = new QScriptEngine;
QScriptValue global = inst->globalObject();
global.setProperty("registerAnimation", inst->newFunction(AnimationScriptEngine::registerAnimation));
global.setProperty("AnimationGroup", inst->newFunction(AnimationScriptEngine::animationGroup));
global.setProperty("ParallelAnimationGroup", inst->newFunction(AnimationScriptEngine::parallelAnimationGroup));
global.setProperty("QEasingCurve", constructEasingCurveClass(inst));
kDebug() << "........... first js animation, creating the engine!";
}
return inst;
}
bool loadScript(const QString &path, const QString &prefix)
{
QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
kError() << "failed to open script file" << path;
return false;
}
QTextStream buffer(&file);
QString tmp(buffer.readAll());
QScriptEngine *engine = AnimationScriptEngine::globalEngine();
engine->pushContext();
s_prefix = prefix;
QScriptValue def(engine->evaluate(tmp, path));
s_prefix.clear();
engine->popContext();
if (engine->hasUncaughtException()) {
const QScriptValue error = engine->uncaughtException();
QString file = error.property("fileName").toString();
const QString failureMsg = QString("Error in %1 on line %2.\n%3")
.arg(file)
.arg(error.property("lineNumber").toString())
.arg(error.toString());
kError() << failureMsg;
return false;
}
return true;
}
} // namespace AnimationEngine
} // namespace Plasma

View file

@ -1,49 +0,0 @@
/*
* Copyright 2010 Aaron Seigo <aseigo@kde.org>
* Copyright 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* 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 __ENGINE__
#define __ENGINE__
#include <QScriptEngine>
#include <QScriptString>
#include <QScriptValue>
#include <QScriptContext>
#include <QDebug>
/* Plasma-shell will have an engine */
namespace Plasma
{
namespace AnimationScriptEngine
{
void clearAnimations();
bool isAnimationRegistered(const QString &anim);
QScriptEngine* globalEngine();
QScriptValue animation(const QString &anim);
bool loadScript(const QString &path, const QString &prefix = QString());
void addToLoadFailures(const QString &anim);
bool animationFailedToLoad(const QString &anim);
}
} // namespace Plasma
#endif

View file

@ -1,172 +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 version 2 as
* published by the Free Software Foundation
*
* 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 <QEasingCurve>
#include <QtCore/qmetaobject.h>
#include <QScriptValue>
#include <QScriptEngine>
#include <QScriptContext>
#include <QScriptable>
Q_DECLARE_METATYPE(QEasingCurve)
Q_DECLARE_METATYPE(QEasingCurve*)
#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \
__c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__))
#define DECLARE_SELF(Class, __fn__) \
Class* self = qscriptvalue_cast<Class*>(ctx->thisObject()); \
if (!self) { \
return ctx->throwError(QScriptContext::TypeError, \
QString::fromLatin1("%0.prototype.%1: this object is not a %0") \
.arg(#Class).arg(#__fn__)); \
}
namespace Plasma
{
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
{
if (ctx->argumentCount() > 0) {
QScriptValue arg = ctx->argument(0);
if (arg.isNumber()) {
qint32 type = arg.toInt32();
if (type > -1 && type < QEasingCurve::Custom) {
return qScriptValueFromValue(eng, QEasingCurve(static_cast<QEasingCurve::Type>(type)));
}
}
}
return qScriptValueFromValue(eng, QEasingCurve());
}
static QScriptValue toString(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, toString);
return QScriptValue(eng, QString::fromLatin1("QEasingCurve(type=%0)").arg(self->type()));
}
static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, type);
if (ctx->argumentCount()) {
QScriptValue arg = ctx->argument(0);
qint32 type = -1;
if (arg.isNumber()) {
type = arg.toInt32();
} else if (arg.isString()) {
QMetaObject meta = QEasingCurve::staticMetaObject;
QMetaEnum easingCurveEnum = meta.enumerator(meta.indexOfEnumerator("Type"));
type = easingCurveEnum.keyToValue(arg.toString().toLatin1().data());
}
if (type > -1 && type < QEasingCurve::Custom) {
self->setType(static_cast<QEasingCurve::Type>(type));
}
}
return QScriptValue(eng, self->type());
}
static QScriptValue valueForProgress(QScriptContext *ctx, QScriptEngine *eng)
{
DECLARE_SELF(QEasingCurve, valueForProgress);
if (ctx->argumentCount() < 1 || !ctx->argument(0).isNumber()) {
return eng->undefinedValue();
}
return self->valueForProgress(ctx->argument(0).toNumber());
}
QScriptValue constructEasingCurveClass(QScriptEngine *eng)
{
QScriptValue proto = qScriptValueFromValue(eng, QEasingCurve());
QScriptValue::PropertyFlags getter = QScriptValue::PropertyGetter;
QScriptValue::PropertyFlags setter = QScriptValue::PropertySetter;
proto.setProperty("type", eng->newFunction(type), getter | setter);
proto.setProperty("toString", eng->newFunction(toString), getter);
proto.setProperty("valueForProgress", eng->newFunction(valueForProgress), getter);
QScriptValue ctorFun = eng->newFunction(ctor, proto);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, Linear);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuad);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCubic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuart);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInQuint);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInSine);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInExpo);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInCirc);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInElastic);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutInBack);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InOutBounce);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, InCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, OutCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, SineCurve);
ADD_ENUM_VALUE(ctorFun, QEasingCurve, CosineCurve);
eng->setDefaultPrototype(qMetaTypeId<QEasingCurve>(), proto);
eng->setDefaultPrototype(qMetaTypeId<QEasingCurve*>(), proto);
return ctorFun;
}
}

View file

@ -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"

View file

@ -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

View file

@ -1,86 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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 "fade_p.h"
#include <QRect>
#include <kdebug.h>
namespace Plasma
{
FadeAnimation::FadeAnimation(QObject *parent)
: EasingAnimation(parent),
m_startOpacity(0),
m_targetOpacity(1)
{
}
FadeAnimation::~FadeAnimation()
{
}
void FadeAnimation::setStartOpacity(qreal factor)
{
m_startOpacity = qBound(qreal(0.0), factor, qreal(1.0));
}
qreal FadeAnimation::startOpacity() const
{
return m_startOpacity;
}
void FadeAnimation::setTargetOpacity(qreal factor)
{
m_targetOpacity = qBound(qreal(0.0), factor, qreal(1.0));
}
qreal FadeAnimation::targetOpacity() const
{
return m_targetOpacity;
}
void FadeAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QGraphicsWidget *w = targetWidget();
if (!w) {
return;
}
if (oldState == Stopped && newState == Running) {
w->setOpacity(direction() == Forward ? m_startOpacity : m_targetOpacity);
} else if (newState == Stopped) {
w->setOpacity(direction() == Forward ? m_targetOpacity : m_startOpacity);
}
}
void FadeAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w) {
qreal delta = currentTime / qreal(duration());
delta *= m_startOpacity - m_targetOpacity;
w->setOpacity(m_startOpacity - delta);
}
}
} //namespace Plasma
#include "moc_fade_p.cpp"

View file

@ -1,99 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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.
*/
/**
* @file This file contains the definition for the Fade effect.
*/
#ifndef PLASMA_ANIMATIONS_FADE_P_H
#define PLASMA_ANIMATIONS_FADE_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class Fade plasma/animations/fade.h
* @short Fade effect
*
* Effect that slowly transforms the opacity of the object from a starting
* value to a target value. The range is 0 (full translucent) to 1 (full
* opaque).
*/
class FadeAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal startOpacity READ startOpacity WRITE setStartOpacity)
Q_PROPERTY(qreal targetOpacity READ targetOpacity WRITE setTargetOpacity)
public:
/** Default constructor */
explicit FadeAnimation(QObject *parent = 0);
/** Destructor */
virtual ~FadeAnimation();
/**
* Access start opacity of the target widget.
*
* You can set both a start and an end opacity for an widget when
* using this animation class. See \ref setStartOpacity.
* @return The opacity (range is 0 to 1).
*/
qreal startOpacity() const;
/**
* Set the start opacity of the target widget.
*
* See also \ref targetOpacity.
* @param qreal The opacity (range is 0 to 1).
*/
void setStartOpacity(qreal);
/**
* Access final opacity of the target widget.
*
* You can set both a start and an end opacity for an widget when
* using this animation class. See \ref setTargetOpacity.
* @return The opacity (range is 0 to 1).
*/
qreal targetOpacity() const;
/**
* Set the final opacity of the target widget.
*
* See also \ref startOpacity.
* @param qreal The opacity (range is 0 to 1).
*/
void setTargetOpacity(qreal);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/** Initial opacity */
qreal m_startOpacity;
/** Final opacity */
qreal m_targetOpacity;
};
}
#endif // PLASMA_ANIMATIONS_FADE_P_H

View file

@ -1,99 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* 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 "geometry_p.h"
#include <QRect>
#include <kdebug.h>
namespace Plasma
{
GeometryAnimation::GeometryAnimation(QObject *parent)
: EasingAnimation(parent),
m_startGeometry(-1, -1, -1, -1)
{
}
GeometryAnimation::~GeometryAnimation()
{
}
void GeometryAnimation::setStartGeometry(const QRectF &geometry)
{
m_startGeometry = geometry;
}
QRectF GeometryAnimation::startGeometry() const
{
return m_startGeometry;
}
void GeometryAnimation::setTargetGeometry(const QRectF &geometry)
{
m_targetGeometry = geometry;
}
QRectF GeometryAnimation::targetGeometry() const
{
return m_targetGeometry;
}
void GeometryAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QGraphicsWidget *w = targetWidget();
if (!w) {
return;
}
if (m_startGeometry == QRectF(-1, -1, -1, -1)) {
m_startGeometry = w->geometry();
}
if (oldState == Stopped && newState == Running) {
w->setGeometry(direction() == Forward ? m_startGeometry : m_targetGeometry);
} else if (newState == Stopped) {
w->setGeometry(direction() == Forward ? m_targetGeometry : m_startGeometry);
}
}
void GeometryAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w) {
const qreal delta = 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)));
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)));
} else {
newGeo.setSize(m_targetGeometry.size());
}
w->setGeometry(newGeo);
}
}
} //namespace Plasma
#include "moc_geometry_p.cpp"

View file

@ -1,97 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* 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.
*/
/**
* @file This file contains the definition for the Geometry effect.
*/
#ifndef PLASMA_ANIMATIONS_GEOMETRY_P_H
#define PLASMA_ANIMATIONS_GEOMETRY_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class GeometryAnimation plasma/animations/geo_p.h
* @short Geometry Animation
* 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
{
Q_OBJECT
Q_PROPERTY(QRectF startGeometry READ startGeometry WRITE setStartGeometry)
Q_PROPERTY(QRectF targetGeometry READ targetGeometry WRITE setTargetGeometry)
public:
/** Default constructor */
explicit GeometryAnimation(QObject *parent = 0);
/** Destructor */
virtual ~GeometryAnimation();
/**
* Access the initial geometry of animated widget.
*
* If no geometry is set, it will use the widget current geometry
* when the animation is first run).
* @return Start geometry.
*/
QRectF startGeometry() const;
/**
* Set the initial geometry of animated widget.
*
* If no geometry is set, it will use the widget current geometry
* when the animation is first run).
* @param geometry The initial geometry.
*/
void setStartGeometry(const QRectF &geometry);
/**
* Access the final geometry of animated widget.
*
* \todo: check if it was set and case negative, handle the error.
* @return Target geometry.
*/
QRectF targetGeometry() const;
/**
* Set the final geometry of animated widget.
*
* See also \ref setStartGeometry.
* @param geometry Returns the target geometry of animated widget.
*/
void setTargetGeometry(const QRectF &geometry);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/** Initial geometry */
QRectF m_startGeometry;
/** Final geometry */
QRectF m_targetGeometry;
};
} // PLASMA_ANIMATIONS_GEOMETRY_P_H
#endif

View file

@ -1,99 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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 "grow_p.h"
#include <QRect>
#include <kdebug.h>
namespace Plasma
{
GrowAnimation::GrowAnimation(QObject *parent, qreal factor)
: EasingAnimation(parent), m_animFactor(factor)
{
}
void GrowAnimation::setFactor(const qreal factor)
{
m_animFactor = qMax(qreal(0.0), factor);
}
qreal GrowAnimation::factor() const
{
return m_animFactor;
}
void GrowAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w && state() == QAbstractAnimation::Running) {
const qreal delta = currentTime / qreal(duration());
QRectF geometry;
geometry.setTopLeft(m_startGeometry.topLeft() * (1-delta) + (m_targetGeometry.topLeft() * delta));
geometry.setSize(m_startGeometry.size() * (1-delta) + (m_targetGeometry.size() * delta));
w->setGeometry(geometry);
}
}
void GrowAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) {
QGraphicsWidget *widget = targetWidget();
if (!widget) {
return;
}
QSizeF minimum = widget->effectiveSizeHint(Qt::MinimumSize);
QSizeF maximum = widget->effectiveSizeHint(Qt::MaximumSize);
m_startGeometry = widget->geometry();
qreal w = m_startGeometry.width();
qreal h = m_startGeometry.height();
qreal factor = m_animFactor;
//compute new geometry values
qreal newWidth;
qreal newHeight;
if (direction() == QAbstractAnimation::Forward) {
newWidth = qBound(minimum.width(), w * factor, maximum.width());
newHeight = qBound(minimum.height(), h * factor, maximum.height());
} else {
newWidth = qBound(minimum.width(), w / factor, maximum.width());
newHeight = qBound(minimum.height(), h / factor, maximum.height());
}
qreal newX;
qreal newY;
newX = m_startGeometry.x() - (newWidth - w)/2;
newY = m_startGeometry.y() - (newHeight - h)/2;
if (direction() == QAbstractAnimation::Forward) {
//the end geometry gets rounded to prevent things looking ugly
m_targetGeometry = QRect(newX, newY, newWidth, newHeight);
} else {
m_targetGeometry = m_startGeometry;
m_startGeometry = QRectF(newX, newY, newWidth, newHeight);
}
}
}
} //namespace Plasma
#include "moc_grow_p.cpp"

View file

@ -1,89 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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.
*/
/**
* @file This file contains the definition for the Grow effect.
*/
#ifndef PLASMA_ANIMATIONS_GROW_P_H
#define PLASMA_ANIMATIONS_GROW_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class GrowAnimation plasma/animations/grow.h
* @short Grow effect
*
* Effect that grows any QGraphicsWidget by a multiple given in the
* constructor. The center of the object stays in place while the sides grow
* (it does the animation by changing the objects geometry). Also see
* \ref ZoomAnimation.
*/
class GrowAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal factor READ factor WRITE setFactor)
public:
/** Default Constructor
* @param parent Animation object parent.
* @param factor Expand factor (default is twice the size of
* animated widget).
*/
explicit GrowAnimation(QObject *parent = 0, qreal factor = 2);
/** Destructor */
virtual ~GrowAnimation(){};
/**
* Access expansion factor of the shadow pulsable copy.
*
* If not set, the default is twice (2x) the size of animated widget.
* See \ref setFactor.
* @return Expansion factor.
*/
qreal factor() const;
/**
* Set expansion factor of target widget.
*
* If not set, the default is twice (2x) the size of animated widget.
* @param factor A expansion factor
*/
void setFactor(const qreal factor);
protected:
void updateEffectiveTime(int currentTime);
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
private:
/** Animation grow factor */
qreal m_animFactor;
/** Widget start geometry */
QRectF m_startGeometry;
/** Widget final geometry */
QRectF m_targetGeometry;
};
}
#endif // PLASMA_ANIMATIONS_GROW_P_H

View file

@ -1,124 +0,0 @@
/*
* Copyright (C) 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* 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 "javascriptanimation_p.h"
#include <kdebug.h>
#include "animationscriptengine_p.h"
/* TODO:
* - support passing more parameters to the js animation object
* - support more properties: angle, direction, etc
* - support calling a 'resetAnimation' in js class when animation is stopped
*/
#define ADD_ENUM_VALUE(__c__, __ns__, __v__) \
__c__.setProperty(#__v__, QScriptValue(__c__.engine(), __ns__::__v__))
namespace Plasma
{
JavascriptAnimation::JavascriptAnimation(const QString &name, QObject *parent)
: EasingAnimation(parent),
#ifdef PLASMA_JSANIM_FPS
m_fps(0),
#endif
m_name(name)
{
}
JavascriptAnimation::~JavascriptAnimation()
{
}
void JavascriptAnimation::prepInstance()
{
QScriptEngine *engine = AnimationScriptEngine::globalEngine();
m_instance.setProperty("__plasma_javascriptanimation", engine->newQObject(this),
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, FadeAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, AppearAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, DisappearAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, ActivateAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, FadeAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, GrowAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, PulseAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, RotationAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, RotationStackedAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, SlideAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, GeometryAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, ZoomAnimation);
ADD_ENUM_VALUE(m_instance, Plasma::Animator, PixmapTransitionAnimation);
ADD_ENUM_VALUE(m_instance, JavascriptAnimation, PauseAnimation);
ADD_ENUM_VALUE(m_instance, JavascriptAnimation, PropertyAnimation);
}
void JavascriptAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
//kDebug() << ".................. state: " << newState;
if (oldState == Stopped && newState == Running) {
if (!m_method.isFunction()) {
//Define the class and create an instance
m_instance = AnimationScriptEngine::animation(m_name).construct();
kDebug() << "trying for" << m_name << m_instance.isFunction();
//Get the method of the object
m_method = m_instance.property(QString("updateCurrentTime"));
if (!m_method.isFunction()) {
qDebug() << "**************** ERROR! Name: " << m_name << " ************";
m_instance = m_method = QScriptValue();
} else {
prepInstance();
//TODO: this really should be done in the bindings provided
//Center the widget for transformation
qreal x = targetWidget()->geometry().height()/2;
qreal y = targetWidget()->geometry().width()/2;
targetWidget()->setTransformOriginPoint(x, y);
}
}
if (m_method.isFunction()) {
m_instance.setProperty("duration", duration(), QScriptValue::ReadOnly);
m_instance.setProperty("target", m_instance.engine()->newQObject(targetWidget()), QScriptValue::ReadOnly);
}
#ifdef PLASMA_JSANIM_FPS
m_fps = 0;
} else if (oldState == Running && newState == Stopped) {
kDebug() << ".........." << m_name << " fps: " << m_fps * 1000/duration();
#endif
}
}
void JavascriptAnimation::updateEffectiveTime(int currentTime)
{
if (m_method.isFunction()) {
#ifdef PLASMA_JSANIM_FPS
++m_fps;
#endif
QScriptValueList args;
args << currentTime;
m_method.call(m_instance, args);
}
}
} //namespace Plasma
#include "moc_javascriptanimation_p.cpp"

View file

@ -1,68 +0,0 @@
/*
* Copyright (C) 2010 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* 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_ANIMATIONS_JS_P_H
#define PLASMA_ANIMATIONS_JS_P_H
#include <QScriptValue>
#include "animator.h"
#include "easinganimation_p.h"
#include "plasma_export.h"
class QString;
class QScriptEngine;
//#define PLASMA_JSANIM_FPS
namespace Plasma
{
class JavascriptAnimation: public EasingAnimation
{
Q_OBJECT
public:
enum { PauseAnimation = Animator::LastAnimation + 1,
PropertyAnimation = Animator::LastAnimation + 2
};
explicit JavascriptAnimation(const QString &name, QObject *parent = 0);
~JavascriptAnimation();
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
void prepInstance();
#ifdef PLASMA_JSANIM_FPS
int m_fps;
#endif
QString m_name;
QScriptValue m_instance;
QScriptValue m_method;
};
}
#endif

View file

@ -1,54 +0,0 @@
/*
* Copyright (C) 2010 Bruno Abinader <bruno.abinader@indt.org.br>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include "pendulumcurve_p.h"
/**
* This static method is used to create a custom easing curve type.
* @param progress animation progress value
* @return pendulum easing curve progress value
*/
static qreal pendulumFunction(qreal progress)
{
if (progress <= 0.25) {
progress *= 4;
} else if (progress <= 0.50) {
progress -= 0.25;
progress *= 4;
progress = 1 - progress;
} else if (progress <= 0.75) {
progress -= 0.50;
progress *= -4;
} else {
progress -= 0.75;
progress *= 4;
progress = 1 - progress;
progress *= -1;
}
return progress;
}
namespace Plasma
{
PendulumCurve::PendulumCurve()
: QEasingCurve()
{
setCustomType(pendulumFunction);
}
} // namespace Plasma

View file

@ -1,44 +0,0 @@
/*
* Copyright (C) 2010 Bruno Abinader <bruno.abinader@indt.org.br>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
#define PLASMA_ANIMATIONS_PENDULUMCURVE_P_H
#include <QtCore/QEasingCurve>
namespace Plasma
{
/*
* @class PendulumCurve plasma/animations/pendulumcurve.h
* @shot Pendulum Easing Curve
*
* 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 PendulumCurve : public QEasingCurve
{
public:
/**
* default constructor
*/
PendulumCurve();
};
} // namespace Plasma
#endif // PLASMA_ANIMATIONS_PENDULUMCURVE_P_H

View file

@ -1,180 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
* Copyright 2010 Marco Martin <notmart@gmail.com>
*
* 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 "pixmaptransition_p.h"
#include <QPainter>
#include <QPixmap>
#include <kdebug.h>
#include "paintutils.h"
namespace Plasma
{
PixmapTransition::PixmapTransition(QObject *parent)
: EasingAnimation(parent),
m_cache(false),
m_dirty(false)
{
}
PixmapTransition::~PixmapTransition()
{
}
void PixmapTransition::setStartPixmap(const QPixmap &pixmap)
{
if (state() == Running) {
stop();
}
m_startPixmap = pixmap;
//this will center the pixmaps if needed
updateEffectiveTime(0);
}
QPixmap PixmapTransition::startPixmap() const
{
return m_startPixmap;
}
void PixmapTransition::setTargetPixmap(const QPixmap &pixmap)
{
if (state() == Running) {
stop();
}
m_targetPixmap = pixmap;
updateEffectiveTime(0);
}
void PixmapTransition::setUsesCache(bool cache)
{
m_cache = cache;
}
bool PixmapTransition::usesCache() const
{
return m_cache;
}
QPixmap PixmapTransition::targetPixmap() const
{
return m_targetPixmap;
}
QPixmap PixmapTransition::currentPixmap() const
{
if (m_cache && !m_dirty) {
return m_currentPixmap;
}
QPixmap currentPixmap;
qreal delta = currentTime() / qreal(duration());
if (!m_startPixmap.isNull() && !m_targetPixmap.isNull()) {
//kDebug() << "transitioning";
currentPixmap = Plasma::PaintUtils::transition(m_startPixmap, m_targetPixmap, delta);
} else if (m_startPixmap.isNull()) {
if (qFuzzyCompare(delta, qreal(1.0))) {
currentPixmap = alignedTargetPixmap();
return currentPixmap;
}
if (currentPixmap.isNull()) {
currentPixmap = QPixmap(m_pixmapSize);
}
currentPixmap.fill(QColor(0, 0, 0, (int)(((qreal)255)*delta)));
QPainter p(&currentPixmap);
p.setCompositionMode(QPainter::CompositionMode_SourceIn);
//kDebug() << "painting" << m_targetPixmap.rect() << "into" << m_targetRect << "in size" << currentPixmap.size();
p.drawPixmap(m_targetRect, m_targetPixmap);
p.end();
} else if (m_targetPixmap.isNull()) {
currentPixmap = alignedStartPixmap();
if (qFuzzyCompare(delta, qreal(1.0))) {
return m_currentPixmap;
}
//kDebug() << "painting" << m_startPixmap.rect() << "into" << m_targetRect << "in size" << currentPixmap.size();
QPainter p(&currentPixmap);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.fillRect(currentPixmap.rect(), QColor(0, 0, 0, (int)(254 - ((qreal)254)*delta)));
p.end();
}
if (m_cache) {
const_cast<PixmapTransition *>(this)->m_currentPixmap = currentPixmap;
}
return currentPixmap;
}
QPixmap PixmapTransition::alignedTargetPixmap() const
{
QPixmap pm(m_pixmapSize);
pm.fill(Qt::transparent);
QPainter p(&pm);
p.drawPixmap(m_targetRect, m_targetPixmap);
return pm;
}
QPixmap PixmapTransition::alignedStartPixmap() const
{
QPixmap pm(m_pixmapSize);
pm.fill(Qt::transparent);
QPainter p(&pm);
p.drawPixmap(m_startRect, m_startPixmap);
return pm;
}
void PixmapTransition::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (oldState == Stopped && newState == Running) {
m_targetRect = m_targetPixmap.rect();
m_startRect = m_startPixmap.rect();
m_pixmapSize = m_startRect.size().expandedTo(m_targetRect.size());
QRect actualRect = QRect(QPoint(0,0), m_pixmapSize);
m_targetRect.moveCenter(actualRect.center());
m_startRect.moveCenter(actualRect.center());
} else if (QGraphicsWidget *w = targetWidget()) {
w->update();
}
m_dirty = true;
}
void PixmapTransition::updateEffectiveTime(int currentTime)
{
Q_UNUSED(currentTime)
m_dirty = true;
QGraphicsWidget *w = targetWidget();
if (w) {
w->update();
}
}
} //namespace Plasma
#include "moc_pixmaptransition_p.cpp"

View file

@ -1,111 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
* Copyright 2010 Marco Martin <notmart@gmail.com>
*
* 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.
*/
/**
* @file This file contains the definition for the PixmapTransition effect.
*/
#ifndef PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H
#define PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class Fade plasma/animations/pixmaptransition.h
* @short PixmapTransition effect
*
* Effect that paints a transition between two pixmaps
*/
class PixmapTransition : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(QPixmap startPixmap READ startPixmap WRITE setStartPixmap)
Q_PROPERTY(QPixmap targetPixmap READ targetPixmap WRITE setTargetPixmap)
Q_PROPERTY(bool usesCache READ usesCache WRITE setUsesCache)
Q_PROPERTY(QPixmap currentPixmap READ currentPixmap)
public:
explicit PixmapTransition(QObject *parent = 0);
virtual ~PixmapTransition();
/**
* @return The first pixmap of the animation
*/
QPixmap startPixmap() const;
/**
* Set the first pixmap of the animation
*/
void setStartPixmap(const QPixmap &);
/**
* The pixmap the animation will evolve to
*/
QPixmap targetPixmap() const;
/**
* Set the pixmap the animation will evolve to
*/
void setTargetPixmap(const QPixmap &);
/**
* @return the current pixmap
*/
QPixmap currentPixmap() const;
/**
* Enable caching of the resulting pixmap, otherwise it will be regenerated on
* each call to currentPixmap; for elements which already have their own caching
* this is not a problem.
*/
void setUsesCache(bool cache);
/**
* @return whether or not caching is on
*/
bool usesCache() const;
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
QPixmap alignedTargetPixmap() const;
QPixmap alignedStartPixmap() const;
private:
QPixmap m_startPixmap;
QPixmap m_targetPixmap;
QPixmap m_currentPixmap;
QRect m_startRect;
QRect m_targetRect;
QSize m_pixmapSize;
bool m_cache;
bool m_dirty;
};
}
#endif // PLASMA_ANIMATIONS_PIXMAPTRANSITION_P_H

View file

@ -1,144 +0,0 @@
/* Copyright (C) 2009 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* 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 "widgetsnapshot_p.h"
#include "pulser_p.h"
#include <QEvent>
#include <QGraphicsWidget>
#include <QParallelAnimationGroup>
#include <QPropertyAnimation>
#include <QtCore/qsharedpointer.h>
#include <kdebug.h>
namespace Plasma
{
PulseAnimation::PulseAnimation(QObject *parent)
: EasingAnimation(parent),
m_zvalue(0),
m_scale(0),
m_opacity(0),
m_endScale(1.5)
{
}
PulseAnimation::~PulseAnimation()
{
delete m_under.data();
}
void PulseAnimation::setTargetScale(qreal scale)
{
m_endScale = scale;
}
qreal PulseAnimation::targetScale() const
{
return m_endScale;
}
void PulseAnimation::setCopy()
{
QGraphicsWidget *target = targetWidget();
if (!target) {
m_under.clear();
return;
}
if (!m_under.data()) {
m_under = new WidgetSnapShot;
}
m_under.data()->setTarget(target);
m_zvalue = target->zValue() - 1;
m_scale = target->scale();
m_under.data()->setOpacity(m_opacity);
m_under.data()->setScale(m_scale);
m_under.data()->setZValue(m_zvalue);
}
void PulseAnimation::resetPulser()
{
if (m_under.data()) {
m_under.data()->setOpacity(m_opacity);
m_under.data()->setScale(m_scale);
m_under.data()->setZValue(m_zvalue);
m_under.data()->hide();
}
}
void PulseAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (!targetWidget()) {
return;
}
if (oldState == Stopped && newState == Running) {
if (!m_under.data() || m_under.data()->target() != targetWidget() || m_under.data()->size() != targetWidget()->size()) {
setCopy();
}
if (m_under.data()->isIconBigger()) {
m_under.data()->setScale(0);
m_endScale = 1.0;
} else {
m_scale = 0;
m_endScale = 1.5;
}
if (m_under.data()->isVisible() == false) {
m_under.data()->setVisible(true);
}
m_under.data()->setOpacity(direction() == Forward ? 1 : 0);
m_under.data()->setScale(direction() == Forward ? m_scale : m_endScale);
} else if (newState == Stopped) {
resetPulser();
}
}
void PulseAnimation::updateEffectiveTime(int currentTime)
{
if (m_under.data()) {
qreal delta = currentTime / qreal(duration());
if (m_under.data()->isIconBigger()) {
m_under.data()->setScale(delta);
} else {
m_under.data()->setScale(delta);
delta = (1 - m_endScale) * delta;
m_under.data()->setScale(1 - delta);
}
delta = currentTime / qreal(duration());
if (direction() == Forward) {
m_under.data()->setOpacity(1.0 - delta);
} else if (direction() == Backward) {
m_under.data()->setOpacity(delta);
}
}
}
} //namespace Plasma
#include "moc_pulser_p.cpp"

View file

@ -1,110 +0,0 @@
/* Copyright (C) 2009 Adenilson Cavalcanti <cavalcantii@gmail.com>
*
* 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.
*/
/**
* @file This file contains the definition for the Pulse effect.
*/
#ifndef PLASMA_ANIMATIONS_PULSER_P_H
#define PLASMA_ANIMATIONS_PULSER_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
class WidgetSnapShot;
/**
* @class PulseAnimation plasma/animations/pulser_p.h
* @short Pulse effect
*
* 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
{
Q_OBJECT
Q_PROPERTY(qreal targetScale READ targetScale WRITE setTargetScale)
public:
/** Default Constructor */
explicit PulseAnimation(QObject *parent = 0);
/** Destructor */
~PulseAnimation();
/** Pulse scale factor.
*
* How much the pulsed shadow will expand (the default is 1.5x the
* size of pulsed widget).
*
* @param scale Pulse scale value (should be bigger than 1.0).
*/
void setTargetScale(qreal scale);
/** Returns pulsed scale factor.
*
* The amount of pulsed shadow factor used (default is 1.5x the size
* of widget).
*/
qreal targetScale() const;
/**
* Resets the shadow widget to its initial state (full translucent
* and with same geometry as the target widget). It is executed
* when the animation is over.
*/
void resetPulser();
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
void setCopy();
private:
/** Zvalue (tipically -1 than the target widget) */
qreal m_zvalue;
/** Original widget scale */
qreal m_scale;
/** Opacity of shadow widget (full translucent) */
qreal m_opacity;
/** Target scale of shadow widget (default is 1.5x the animated
* widget scale).
*/
qreal m_endScale;
/** The shadow copy (it really is a QGraphicsWidget with a pixmap
* copy of the original widget).
*/
QWeakPointer<WidgetSnapShot> m_under;
};
}
#endif // PLASMA_ANIMATIONS_PULSER_P_H

View file

@ -1,168 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#include <QtGui/qgraphicstransform.h>
#include <QEasingCurve>
#include <QVector3D>
#include "kdebug.h"
#include "rotation_p.h"
namespace Plasma
{
RotationAnimation::RotationAnimation(QObject *parent, qint8 reference, Qt::Axis axis, qreal angle)
: EasingAnimation(parent),
m_rotation(new QGraphicsRotation(this)),
m_angle(angle),
m_axis(axis),
m_reference(reference)
{
}
RotationAnimation::~RotationAnimation()
{
}
Qt::Axis RotationAnimation::axis() const
{
return m_axis;
}
void RotationAnimation::setAxis(const Qt::Axis &axis)
{
m_axis = axis;
}
qint8 RotationAnimation::reference() const
{
return m_reference;
}
void RotationAnimation::setReference(const qint8 &reference)
{
m_reference = reference;
}
qreal RotationAnimation::angle() const
{
return m_angle;
}
void RotationAnimation::setAngle(const qreal &angle)
{
m_angle = angle;
}
void RotationAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
Q_UNUSED(newState)
Q_UNUSED(oldState)
QGraphicsWidget *m_object = targetWidget();
if (!m_object) {
return;
}
QVector3D vector(0, 0, 0);
const qreal widgetWidth = m_object->size().width();
const qreal widgetHeight = m_object->size().height();
if (axis() == Qt::XAxis) {
switch (reference()) {
case Center:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight/2);
break;
case Up:
vector.setX(widgetWidth/2);
vector.setY(0);
break;
case Down:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight);
break;
}
} else if(axis() == Qt::YAxis) {
switch (reference()) {
case Center:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight/2);
break;
case Left:
vector.setX(0);
vector.setY(widgetHeight/2);
break;
case Right:
vector.setX(widgetWidth);
vector.setY(widgetHeight/2);
break;
}
} else if (axis() == Qt::ZAxis) {
switch (reference()) {
case Center:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight/2);
break;
case Center|Up:
vector.setX(widgetWidth/2);
vector.setY(0);
break;
case Center|Down:
vector.setX(widgetWidth/2);
vector.setY(widgetHeight);
break;
case Center|Left:
vector.setX(0);
vector.setY(widgetHeight/2);
break;
case Center|Right:
vector.setX(widgetWidth);
vector.setY(widgetHeight/2);
break;
}
}
m_rotation->setOrigin(vector);
m_rotation->setAxis(axis());
QList<QGraphicsTransform *> transformation;
transformation.append(m_rotation);
m_object->setTransformations(transformation);
}
void RotationAnimation::updateEffectiveTime(int currentTime)
{
if (targetWidget()) {
qreal delta = currentTime * angle() / qreal(duration());
m_rotation->setAngle(delta);
}
}
}
#include "moc_rotation_p.cpp"

View file

@ -1,123 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
/**
* @file This file contains the definition for the 2D Rotation effect.
*/
#ifndef PLASMA_ROTATION_P_H
#define PLASMA_ROTATION_P_H
#include <plasma/animations/easinganimation_p.h>
class QGraphicsRotation;
namespace Plasma {
/**
* @class RotationAnimation plasma/animations/rotation_p.h
* @short 2D rotation animation.
*
* This animation rotates a QGraphicsWidget in a axis (reference and
* axis can be defined using properties). See also
* \ref StackedRotationAnimation.
*/
class RotationAnimation : public EasingAnimation
{
Q_OBJECT
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)
public:
/**
* Default constructor
*
* @param parent Animation object parent.
* @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,
qint8 reference = Center,
Qt::Axis axis = Qt::ZAxis,
qreal angle = 180);
/** Destructor */
~RotationAnimation();
/**
* get animation rotation axis (e.g. YAxis, ZAxis, XAxis)
*/
Qt::Axis axis() const;
/**
* Rotation reference (e.g. Center, Up, Down, Left, Right) can
* be combined (i.e. Center|Up)
*/
qint8 reference() const;
/**
* Animation rotation angle (e.g. 45, 180, etc)
*/
qreal angle() const;
/**
* Reimplemented from Plasma::Animation
* @param curve Easing curve
*/
void setEasingCurve(const QEasingCurve &curve);
public slots:
/**
* set animation rotation axis
* @param axis Rotation (e.g. YAxis, ZAxis, XAxis)
*/
void setAxis(const Qt::Axis &axis);
/**
* Set rotation reference (e.g. Center, Up, Down, Left, Right) can
* be combined (i.e. Center|Up)
* @param reference The reference
*/
void setReference(const qint8 &reference);
/**
* Set animation rotation angle (e.g. 45, 180, etc)
* @param angle The angle
*/
void setAngle(const qreal &angle);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/** Rotation transform object */
QGraphicsRotation *m_rotation;
/** Rotation angle */
qreal m_angle;
/** Axis where to perform the rotation */
Qt::Axis m_axis;
/** Reference, the default is Up (see \ref Animation::Reference) */
qint8 m_reference;
};
} // Plasma
#endif

View file

@ -1,188 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#include "rotationstacked_p.h"
#include <QtGui/qgraphicstransform.h>
#include <QSequentialAnimationGroup>
#include <QtCore/qsharedpointer.h>
#include <kdebug.h>
#include "stackedlayout.h"
#include "plasma.h"
namespace Plasma
{
const int RotationStackedAnimation::s_sideAngle = 90;
RotationStackedAnimation::RotationStackedAnimation(QObject *parent)
: EasingAnimation(parent)
{
m_backRotation = new QGraphicsRotation(this);
m_frontRotation = new QGraphicsRotation(this);
m_wLayout = new StackedLayout;
}
RotationStackedAnimation::~RotationStackedAnimation()
{
delete m_wLayout.data();
}
void RotationStackedAnimation::setMovementDirection(const Animation::MovementDirection &direction)
{
m_animDirection = direction;
QVector3D animDirection(0, 0, 0);
if (m_animDirection.testFlag(MoveUp)) {
animDirection.setX(1);
} else if (m_animDirection.testFlag(MoveDown)) {
animDirection.setX(-1);
}
if (m_animDirection.testFlag(MoveLeft)) {
animDirection.setY(-1);
} else if (m_animDirection.testFlag(MoveRight)) {
animDirection.setY(1);
}
m_frontRotation->setAxis(animDirection);
m_backRotation->setAxis(animDirection);
updateTransformations();
}
Animation::MovementDirection RotationStackedAnimation::movementDirection() const
{
return m_animDirection;
}
void RotationStackedAnimation::setReference(const Animation::Reference &reference)
{
m_animReference = reference;
if (!targetWidget() || !backWidget()) {
return;
}
const QSizeF transformArea = targetWidget()->size().expandedTo(backWidget()->size());
QVector3D frontTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
QVector3D backTransformOrigin(transformArea.width()/2, transformArea.height()/2, 0);
if (m_animReference.testFlag(Up)) {
frontTransformOrigin.setY(0);
backTransformOrigin.setY(0);
} else if (m_animReference.testFlag(Down)) {
frontTransformOrigin.setY(transformArea.height());
backTransformOrigin.setY(transformArea.height());
}
if (m_animReference.testFlag(Left)) {
frontTransformOrigin.setX(0);
backTransformOrigin.setX(0);
} else if (m_animReference.testFlag(Right)) {
frontTransformOrigin.setX(transformArea.width());
backTransformOrigin.setX(transformArea.width());
}
m_frontRotation->setOrigin(frontTransformOrigin);
m_backRotation->setOrigin(backTransformOrigin);
updateTransformations();
}
Animation::Reference RotationStackedAnimation::reference() const
{
return m_animReference;
}
QGraphicsWidget *RotationStackedAnimation::backWidget()
{
return m_backWidget.data();
}
void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget)
{
m_backWidget = backWidget;
StackedLayout *layout = m_wLayout.data();
if(targetWidget() && backWidget && layout) {
layout->addWidget(targetWidget());
layout->addWidget(backWidget);
}
}
QGraphicsLayoutItem *RotationStackedAnimation::layout()
{
return m_wLayout.data();
}
void RotationStackedAnimation::updateState(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState)
{
if (oldState == Stopped && newState == Running) {
setReference(reference());
}
}
void RotationStackedAnimation::updateEffectiveTime(int currentTime)
{
if (!targetWidget() || !backWidget()) {
return;
}
StackedLayout *layout = m_wLayout.data();
if (!layout) {
return;
}
qreal delta;
if (currentTime <= duration()/2) {
layout->setCurrentWidgetIndex(0);
delta = (currentTime*2) / qreal(duration());
delta *= s_sideAngle;
m_frontRotation->setAngle(delta);
} else {
layout->setCurrentWidgetIndex(1);
delta = 1 - (((currentTime*2) - duration()) / qreal(duration()));
delta = -delta;
delta *= s_sideAngle;
m_backRotation->setAngle(delta);
}
}
void RotationStackedAnimation::updateTransformations()
{
if (!targetWidget() || !backWidget()) {
return;
}
QList<QGraphicsTransform *> frontTransformation;
QList<QGraphicsTransform *> backTransformation;
frontTransformation.append(m_frontRotation);
backTransformation.append(m_backRotation);
targetWidget()->setTransformations(frontTransformation);
backWidget()->setTransformations(backTransformation);
}
} //namespace Plasma
#include "moc_rotationstacked_p.cpp"

View file

@ -1,126 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
/**
* @file This file contains the definition for the StackedRotationAnimation.
*/
#ifndef PLASMA_ROTATIONSTACKED_P_H
#define PLASMA_ROTATIONSTACKED_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
#include <QGraphicsLayoutItem>
class QGraphicsRotation;
class StackedLayout;
namespace Plasma {
/* TODO:
* create a parent class for rotations
*/
/**
* @class RotationStackedAnimation plasma/animations/rotationstacked_p.h
* @short 3D like rotation animation
* Use this class when you want to rotate a widget along an axis (e.g. Y)
* and display a 'hidden' widget behind it. See also \ref RotationAnimation.
*/
class RotationStackedAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(Reference reference READ reference WRITE setReference)
Q_PROPERTY(QGraphicsLayoutItem* layout READ layout)
Q_PROPERTY(QGraphicsWidget* backWidget READ backWidget WRITE setBackWidget)
public:
explicit RotationStackedAnimation(QObject *parent = 0);
~RotationStackedAnimation();
/**
* Set the animation movement direction (e.g. MoveAny, MoveUp, MoveDown,
* MoveLeft, MoveRight) which can be combined (i.e. MoveUp|MoveLeft).
* @param direction animation direction
*/
void setMovementDirection(const Animation::MovementDirection &direction);
/**
* Get the animation movement direction.
*/
Animation::MovementDirection movementDirection() const;
/**
* Set the animation rotation reference (e.g. Center, Up, Down, Left,
* Right) which can be combined (i.e. Center|Up).
* @param reference animation reference
*/
void setReference(const Animation::Reference &reference);
/**
* Get the animation rotation reference.
*/
Animation::Reference reference() const;
/**
* Get the layout where the widgetToAnimate and backWidget are.
*/
QGraphicsLayoutItem *layout();
/**
* Get the back widget
*/
QGraphicsWidget *backWidget();
/**
* Set the back widget that is used after the animation to be finished
* @param backWidget The back widget
*/
void setBackWidget(QGraphicsWidget *backWidget);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
/**
* Updates the front and back widget rotation animation transformations,
* according to the given animation reference point and direction.
*/
void updateTransformations();
/** Animation reference (see \ref Animation::Reference) */
Animation::Reference m_animReference;
/** Animation movement direction (see \ref Animation::MovementDirection) */
Animation::MovementDirection m_animDirection;
/** Object the animation(s) should act upon. */
QWeakPointer<QGraphicsWidget> m_backWidget;
/** Layout where widget would be added */
QWeakPointer<StackedLayout> m_wLayout;
/** Back Widget Rotation transform object */
QGraphicsRotation *m_backRotation;
/** Front Widget Rotation transform object */
QGraphicsRotation *m_frontRotation;
static const int s_sideAngle;
};
} // Plasma
#endif // PLASMA_ROTATIONSTACKED_P_H

View file

@ -1,129 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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 "slide_p.h"
#include <QtCore/qpoint.h>
#include <kdebug.h>
namespace Plasma
{
void SlideAnimation::setDistance(qreal distance)
{
m_animDistance = QPointF(distance, 0.0);
}
qreal SlideAnimation::distance() const
{
return m_animDistance.x();
}
void SlideAnimation::setDistancePointF(const QPointF &distance)
{
m_animDistance = distance;
}
QPointF SlideAnimation::distancePointF() const
{
return m_animDistance;
}
SlideAnimation::~SlideAnimation()
{
}
SlideAnimation::SlideAnimation(QObject *parent,
MovementDirection direction,
qreal distance) : EasingAnimation(parent)
{
setMovementDirection(direction);
setDistance(distance);
setEasingCurve(QEasingCurve::OutCirc);
}
void SlideAnimation::setMovementDirection(const Animation::MovementDirection &direction)
{
m_animDirection = direction;
}
Animation::MovementDirection SlideAnimation::movementDirection() const
{
return m_animDirection;
}
void SlideAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w && state() == QAbstractAnimation::Running) {
const qreal delta = currentTime / qreal(duration());
w->setPos(m_startPos * (1-delta) + (m_targetPos * delta));
}
}
void SlideAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
if (oldState == QAbstractAnimation::Stopped && newState == QAbstractAnimation::Running) {
if (!targetWidget()) {
return;
}
m_startPos = targetWidget()->pos();
qreal newX = m_startPos.x();
qreal newY = m_startPos.y();
QPointF actualDistance = (direction() == \
QAbstractAnimation::Forward ? \
distancePointF():-distancePointF());
bool moveAnyOnly = true;
if (m_animDirection.testFlag(MoveUp)) {
newY -= actualDistance.x();
moveAnyOnly = false;
} else if (m_animDirection.testFlag(MoveDown)) {
newY += actualDistance.x();
moveAnyOnly = false;
}
if (m_animDirection.testFlag(MoveRight)) {
newX += actualDistance.x();
moveAnyOnly = false;
} else if (m_animDirection.testFlag(MoveLeft)) {
newX -= actualDistance.x();
moveAnyOnly = false;
}
if (moveAnyOnly && m_animDirection.testFlag(MoveAny)) {
newX += actualDistance.x();
newY += actualDistance.y();
}
if (direction() == QAbstractAnimation::Forward) {
m_targetPos = QPointF(newX, newY);
} else {
m_targetPos = m_startPos;
m_startPos = QPointF(newX, newY);
}
}
}
} //namespace Plasma
#include "moc_slide_p.cpp"

View file

@ -1,99 +0,0 @@
/*
* Copyright 2009 Mehmet Ali Akmanalp <makmanalp@wpi.edu>
*
* 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.
*/
/**
* @file This file contains the definition for the Slide effect.
*/
#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"
namespace Plasma
{
class SlideAnimationPrivate;
/**
* @class Slide plasma/animations/slide.h
* @short Slide effect
*
* 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
{
Q_OBJECT
Q_PROPERTY(qreal distance READ distance WRITE setDistance)
Q_PROPERTY(MovementDirection movementDirection READ movementDirection WRITE setMovementDirection)
Q_PROPERTY(QPointF distancePointF READ distancePointF WRITE setDistancePointF)
public:
explicit SlideAnimation(QObject *parent = 0, MovementDirection direction = MoveUp, qreal distance = 0);
~SlideAnimation();
/**
* Set the animation distance
* @distance animation distance
*/
void setDistance(qreal distance);
/**
* Get the animation distance
*/
qreal distance() const;
void setDistancePointF(const QPointF &distance);
QPointF distancePointF() const;
/**
* Set the animation direction
* @param direction animation direction
*/
void setMovementDirection(const Animation::MovementDirection&direction);
/**
* Get the animation direction
*/
Animation::MovementDirection movementDirection() const;
protected:
void updateEffectiveTime(int currentTime);
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
private:
/**
* Animation direction: where the animation will move.
*/
Animation::MovementDirection m_animDirection;
/**
* Animation distance: displacement factor for animations where
* there is change in the position of animated widget.
*/
QPointF m_animDistance;
QPointF m_startPos;
QPointF m_targetPos;
};
}
#endif // PLASMA_ANIMATIONS_SLIDE_P_H

View file

@ -1,108 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#include "stackedlayout.h"
#include <QGraphicsWidget>
#include <QDebug>
StackedLayout::StackedLayout(QGraphicsLayoutItem *parent)
: QObject(0),
QGraphicsLayout(parent),
m_currentWidgetIndex(-1)
{
}
StackedLayout::~StackedLayout()
{
}
void StackedLayout::setGeometry(const QRectF &rect)
{
QGraphicsLayout::setGeometry(rect);
const QRectF effectiveRect = geometry();
for(int i = 0; i < items.size(); i++) {
itemAt(i)->setGeometry(effectiveRect);
}
}
QSizeF StackedLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
Q_UNUSED(which);
Q_UNUSED(constraint);
qreal left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
if (m_currentWidgetIndex <= 0 || !itemAt(m_currentWidgetIndex)) {
return QSizeF();
}
QSizeF currentWidgetSize = itemAt(m_currentWidgetIndex)->effectiveSizeHint(which, constraint);
return QSizeF( left + right + currentWidgetSize.width(), right + bottom + currentWidgetSize.height());
}
int StackedLayout::count() const
{
return items.count();
}
QGraphicsLayoutItem *StackedLayout::itemAt(int i) const
{
return items.at(i);
}
void StackedLayout::insertWidget(QGraphicsLayoutItem *item, int pos)
{
if(!pos && (m_currentWidgetIndex == -1)) {
m_currentWidgetIndex = 0;
} else {
item->graphicsItem()->hide();
}
items.insert(pos, item);
activate();
}
void StackedLayout::addWidget(QGraphicsLayoutItem *item)
{
insertWidget(item, items.size());
}
void StackedLayout::removeAt(int index)
{
items.removeAt(index);
}
void StackedLayout::setCurrentWidgetIndex(qint32 index)
{
QGraphicsItem *currentWidget = itemAt(m_currentWidgetIndex)->graphicsItem();
QGraphicsItem *hiddenWidget = itemAt(index)->graphicsItem();
currentWidget->hide();
hiddenWidget->show();
m_currentWidgetIndex = index;
}
qint32 StackedLayout::currentWidgetIndex() const
{
return m_currentWidgetIndex;
}

View file

@ -1,54 +0,0 @@
/*
Copyright (C) 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef STACKEDLAYOUT_H
#define STACKEDLAYOUT_H
/* TODO: document the methods */
#include <QGraphicsLayout>
#include <QList>
#include <QObject>
class StackedLayout : public QObject, public QGraphicsLayout
{
Q_OBJECT
Q_INTERFACES(QGraphicsLayout)
public:
explicit StackedLayout(QGraphicsLayoutItem *parent = 0);
~StackedLayout();
void setGeometry(const QRectF &rect);
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const;
int count() const;
QGraphicsLayoutItem *itemAt(int i) const;
void insertWidget(QGraphicsLayoutItem *item, int pos);
void addWidget(QGraphicsLayoutItem *item);
void removeAt(int index);
qint32 currentWidgetIndex() const;
void setCurrentWidgetIndex(qint32 index);
private:
QList<QGraphicsLayoutItem *> items;
qint32 m_currentWidgetIndex;
};
#endif

View file

@ -1,69 +0,0 @@
/*
* Copyright (C) 2010 Bruno Abinader <bruno.abinader@indt.org.br>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include <plasma/private/effects/ripple_p.h>
#include "water_p.h"
namespace Plasma
{
WaterAnimation::WaterAnimation(QObject *parent)
: EasingAnimation(parent),
m_offset(1)
{
}
qint8 WaterAnimation::offset() const
{
return m_offset;
}
void WaterAnimation::setOffset(qint8 offset)
{
m_offset = offset;
}
void WaterAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QGraphicsWidget *widget = targetWidget();
if (!widget) {
return;
}
RippleEffect *effect = qobject_cast<RippleEffect*>(widget->graphicsEffect());
if (!effect) {
effect = new RippleEffect(widget);
widget->setGraphicsEffect(effect);
}
if (oldState == Stopped && newState == Running) {
effect->setOffset(m_offset);
effect->setEnabled(true);
} else if (newState == Stopped) {
effect->setEnabled(false);
}
}
void WaterAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *widget = targetWidget();
if (widget && widget->graphicsEffect()) {
widget->graphicsEffect()->setProperty("opacity", currentTime / qreal(duration()));
}
}
} // namespace Plasma

View file

@ -1,68 +0,0 @@
/*
* Copyright (C) 2010 Bruno Abinader <bruno.abinader@indt.org.br>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_ANIMATIONS_WATER_P_H
#define PLASMA_ANIMATIONS_WATER_P_H
#include <plasma/animations/easinganimation_p.h>
namespace Plasma
{
/*
* @class Water plasma/animations/water_p.h
* @short Water animation using ripple effect
*
* Simulates a water animation using ripple effect
*/
class WaterAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qint8 offset READ offset WRITE setOffset)
public:
/**
* Default constructor
* @param parent Animation object parent
*/
explicit WaterAnimation(QObject *parent = 0);
/**
* Returns the ripple offset. The ripple offset is the distance between neighbour pixels used to
* calculate the wave propagation.
* @return ripple offset
*/
qint8 offset() const;
public slots:
/**
* Sets the ripple offset
* @param offset ripple offset
*/
void setOffset(qint8 offset);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
qint8 m_offset; /** Ripple offset (default is 1) */
};
} // namespace Plasma
#endif // PLASMA_ANIMATIONS_WATER_P_H

View file

@ -1,128 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#include "widgetsnapshot_p.h"
#include <QPainter>
#include <QImage>
#include <QPixmap>
#include <QtGui/qstyleoption.h>
#include <QDebug>
static const int RECURSION_MAX = 20;
namespace Plasma
{
WidgetSnapShot::WidgetSnapShot(QGraphicsItem *parent)
: QGraphicsWidget(parent),
m_iconBig(false),
stack(0),
m_target(0)
{
}
WidgetSnapShot::~WidgetSnapShot()
{
}
void WidgetSnapShot::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawPixmap(option->exposedRect, m_snapShot, option->exposedRect);
}
void WidgetSnapShot::paintSubChildren(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QGraphicsItem *target)
{
++stack;
QList<QGraphicsItem *> list = target->childItems();
QGraphicsItem *tmp;
if (list.size() > 0) {
for (int i = 0; i < list.size(); ++i) {
tmp = list.value(i);
if ((tmp->childItems().size() > 0) && (stack < RECURSION_MAX)) {
paintSubChildren(painter, option, tmp);
}
if (tmp->isVisible()) {
tmp->paint(painter, option, 0);
}
}
}
--stack;
}
void WidgetSnapShot::setTarget(QGraphicsWidget *target)
{
stack = 0;
m_target = target;
setParentItem(target);
QSize size(target->size().toSize());
m_iconBig = false;
if (m_target->property("iconRepresentation").isValid()) {
m_iconBig = true;
m_snapShot = QPixmap::fromImage(
m_target->property("iconRepresentation").value<QImage>());
if ((m_snapShot.height() > 0) && (m_snapShot.width() > 0)) {
resize(m_snapShot.size());
setTransformOriginPoint(target->geometry().center());
return;
}
}
resize(target->size());
m_snapShot = QPixmap(size);
m_snapShot.fill(Qt::transparent);
QPainter painter(&m_snapShot);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.fillRect(target->rect(), Qt::transparent);
QStyleOptionGraphicsItem style;
style.exposedRect = target->boundingRect();
style.rect = target->rect().toRect();
target->paint(&painter, &style, 0);
paintSubChildren(&painter, &style, target);
painter.end();
setTransformOriginPoint(geometry().center());
}
QGraphicsWidget *WidgetSnapShot::target() const
{
return m_target;
}
bool WidgetSnapShot::isIconBigger() const
{
return m_iconBig;
}
QPixmap WidgetSnapShot::snapShot() const
{
return m_snapShot;
}
}

View file

@ -1,59 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_WIDGETSNAPSHOT_P_H
#define PLASMA_WIDGETSNAPSHOT_P_H
#include <QGraphicsWidget>
namespace Plasma
{
class WidgetSnapShot : public QGraphicsWidget
{
Q_OBJECT
Q_PROPERTY(QGraphicsWidget *target READ target WRITE setTarget)
public:
explicit WidgetSnapShot(QGraphicsItem *parent = 0);
virtual ~WidgetSnapShot();
virtual void setTarget(QGraphicsWidget *target);
QGraphicsWidget *target() const;
virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget);
bool isIconBigger() const;
QPixmap snapShot() const;
private:
void paintSubChildren(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QGraphicsItem *target);
bool m_iconBig;
int stack;
QPixmap m_snapShot;
QGraphicsWidget *m_target;
};
} // namespace Plasma
#endif // PLASMA_WIDGETSNAPSHOT_P_H

View file

@ -1,76 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* 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 "zoom_p.h"
#include <kdebug.h>
namespace Plasma
{
ZoomAnimation::ZoomAnimation(QObject *parent)
: EasingAnimation(parent),
m_zoom(0)
{
}
ZoomAnimation::~ZoomAnimation()
{
}
void ZoomAnimation::setZoom(qreal zoom)
{
m_zoom = zoom;
}
qreal ZoomAnimation::zoom() const
{
return m_zoom;
}
void ZoomAnimation::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
{
QGraphicsWidget *w = targetWidget();
if (!w) {
return;
}
if (oldState == Stopped && newState == Running) {
w->setTransformOriginPoint(w->size().width()/2, w->size().height()/2);
w->setScale(direction() == Forward ? 1 : m_zoom);
} else if (newState == Stopped) {
w->setScale(direction() == Forward ? m_zoom : 1);
}
}
void ZoomAnimation::updateEffectiveTime(int currentTime)
{
QGraphicsWidget *w = targetWidget();
if (w) {
qreal delta = currentTime / qreal(duration());
if (m_zoom != 1) {
delta = (1 - m_zoom) * delta;
w->setScale(1 - delta);
} else {
w->setScale(delta);
}
}
}
} //namespace Plasma

View file

@ -1,60 +0,0 @@
/*
* Copyright 2009 Igor Trindade Oliveira <igor.oliveira@indt.org.br>
*
* 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.
*/
/**
* @file This file contains the definition for the Zoom animation.
*/
#ifndef PLASMA_ANIMATIONS_ZOOM_P_H
#define PLASMA_ANIMATIONS_ZOOM_P_H
#include <plasma/animations/easinganimation_p.h>
#include <plasma/plasma_export.h>
namespace Plasma
{
/**
* @class ZoomAnimation plasma/animations/zoom_p.h
* @short Zoom Animation
*
*/
class ZoomAnimation : public EasingAnimation
{
Q_OBJECT
Q_PROPERTY(qreal zoom READ zoom WRITE setZoom)
public:
explicit ZoomAnimation(QObject *parent = 0);
virtual ~ZoomAnimation();
qreal zoom() const;
void setZoom(qreal);
protected:
void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateEffectiveTime(int currentTime);
private:
qreal m_zoom;
};
}
#endif // PLASMA_ANIMATIONS_ZOOM_P_H

View file

@ -1,216 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#include "animator.h"
#include "private/animator_p.h"
#include <kdebug.h>
#include "animations/animation.h"
#include "animations/animationscriptengine_p.h"
#include "animations/fade_p.h"
#include "animations/grow_p.h"
#include "animations/pulser_p.h"
#include "animations/rotation_p.h"
#include "animations/slide_p.h"
#include "animations/rotationstacked_p.h"
#include "animations/geometry_p.h"
#include "animations/zoom_p.h"
#include "animations/pixmaptransition_p.h"
#include "animations/water_p.h"
#include "animations/pendulumcurve_p.h"
#include "animations/javascriptanimation_p.h"
#include "theme.h"
namespace Plasma
{
QHash<Animator::Animation, Animator::Animation> AnimatorPrivate::s_stockAnimMappings;
QHash<Animator::Animation, QString> AnimatorPrivate::s_loadableAnimMappings;
void AnimatorPrivate::mapAnimation(Animator::Animation from, Animator::Animation to)
{
if (from == to) {
return;
}
s_loadableAnimMappings.remove(from);
s_stockAnimMappings.insert(from, to);
}
void AnimatorPrivate::mapAnimation(Animator::Animation from, const QString &to)
{
s_stockAnimMappings.remove(from);
s_loadableAnimMappings.insert(from, to);
}
Plasma::Animation* Animator::create(Animator::Animation type, QObject *parent)
{
if (AnimatorPrivate::s_stockAnimMappings.contains(type)) {
return create(AnimatorPrivate::s_stockAnimMappings.value(type));
} else if (AnimatorPrivate::s_loadableAnimMappings.contains(type)) {
const QString anim = AnimatorPrivate::s_loadableAnimMappings.value(type);
return create(anim, parent);
}
Plasma::Animation *result = 0;
switch (type) {
case FadeAnimation:
result = create("FadeAnimation", parent);
if (!result) {
result = new Plasma::FadeAnimation(parent);
}
break;
case GrowAnimation:
result = create("GrowAnimation", parent);
if (!result) {
result = new Plasma::GrowAnimation(parent);
}
break;
case PulseAnimation:
result = create("PulseAnimation", parent);
if (!result) {
result = new Plasma::PulseAnimation(parent);
}
break;
case RotationAnimation:
result = create("RotationAnimation", parent);
if (!result) {
result = new Plasma::RotationAnimation(parent);
}
break;
case RotationStackedAnimation:
result = create("RotationStackedAnimation", parent);
if (!result) {
result = new Plasma::RotationStackedAnimation(parent);
}
break;
case SlideAnimation:
result = create("SlideAnimation", parent);
if (!result) {
result = new Plasma::SlideAnimation(parent);
}
break;
case GeometryAnimation:
result = create("GeometryAnimation", parent);
if (!result) {
result = new Plasma::GeometryAnimation(parent);
}
break;
case ZoomAnimation:
result = create("ZoomAnimation", parent);
if (!result) {
result = new Plasma::ZoomAnimation(parent);
}
break;
case PixmapTransitionAnimation:
result = create("PixmapTransitionAnimation", parent);
if (!result) {
result = new Plasma::PixmapTransition(parent);
}
break;
case WaterAnimation:
result = create("WaterAnimation", parent);
if (!result) {
result = new Plasma::WaterAnimation(parent);
}
break;
default:
//kDebug() << "Unsupported animation type.";
break;
}
return result;
}
QEasingCurve Animator::create(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;
}
Plasma::Animation *Animator::create(const QString &anim, QObject *parent)
{
if (AnimationScriptEngine::animationFailedToLoad(anim)) {
return 0;
}
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
const QString path = Theme::defaultTheme()->animationPath(anim);
if (path.isEmpty()) {
AnimationScriptEngine::addToLoadFailures(anim);
//kError() << "************ failed to find script file for animation" << anim;
return 0;
}
if (!AnimationScriptEngine::loadScript(path)) {
AnimationScriptEngine::addToLoadFailures(anim);
return 0;
}
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
//kError() << "successfully loaded script file" << path << ", but did not get animation object for" << anim;
AnimationScriptEngine::addToLoadFailures(anim);
return 0;
}
}
return new Plasma::JavascriptAnimation(anim, parent);
}
} // namespace Plasma
#include "moc_animator.cpp"

View file

@ -1,219 +0,0 @@
/*
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
* 2007 Alexis Ménard <darktears31@gmail.com>
*
* 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_ANIMATOR_H
#define PLASMA_ANIMATOR_H
#include <QtGui/QImage>
#include <QtCore/QObject>
#include <QtCore/QAbstractAnimation>
#include <QtCore/QEasingCurve>
#include <plasma/plasma_export.h>
class QGraphicsItem;
class QGraphicsWidget;
class QTimeLine;
namespace Plasma
{
class AnimatorPrivate;
class Animation;
/**
* @class Animator plasma/animator.h <Plasma/Animator>
*
* @short A system for applying effects to Plasma elements
*/
class PLASMA_EXPORT Animator : public QObject
{
Q_OBJECT
Q_ENUMS(Animation)
Q_ENUMS(CurveShape)
Q_ENUMS(Movement)
public:
enum Animation {
AppearAnimation = 0, /*<< Animate the appearance of an element */
DisappearAnimation, /*<< Animate the disappearance of an element */
ActivateAnimation, /*<< When something is activated or launched,
such as an app icon being clicked */
FadeAnimation, /*<< Can be used for both fade in and out */
GrowAnimation, /*<< Grow animated object geometry */
PulseAnimation, /*<< Pulse animated object (opacity/geometry/scale) */
RotationAnimation, /*<< Rotate an animated object */
RotationStackedAnimation, /*<< for flipping one object with another */
SlideAnimation, /*<< Move the position of animated object */
GeometryAnimation, /*<< Geometry animation*/
ZoomAnimation, /*<<Zoom animation */
PixmapTransitionAnimation, /*<< Transition between two pixmaps*/
WaterAnimation /*<< Water animation using ripple effect */,
LastAnimation = 1024
};
enum CurveShape {
EaseInCurve = 0,
EaseOutCurve,
EaseInOutCurve,
LinearCurve,
PendularCurve
};
enum Movement {
SlideInMovement = 0,
SlideOutMovement,
FastSlideInMovement,
FastSlideOutMovement
};
/**
* Singleton accessor
**/
/**
* Factory to build new animation objects. To control their behavior,
* check \ref AbstractAnimation properties.
* @since 4.4
**/
static Plasma::Animation *create(Animator::Animation type, QObject *parent = 0);
/**
* Factory to build new animation objects from Javascript files. To control their behavior,
* check \ref AbstractAnimation properties.
* @since 4.5
**/
static Plasma::Animation *create(const QString &animationName, QObject *parent = 0);
/**
* Factory to build new custom easing curves.
* @since 4.5
*/
static QEasingCurve create(Animator::CurveShape type);
/**
* Starts a standard animation on a QGraphicsItem.
*
* @param item the item to animate in some fashion
* @param anim the type of animation to perform
* @return the id of the animation
* @deprecated use new Animator API with Qt Kinetic
**/
/**
* Stops an item animation before the animation is complete.
* Note that it is not necessary to call
* this on normal completion of the animation.
*
* @param id the id of the animation as returned by animateItem
* @deprecated use new Animator API with Qt Kinetic
*/
/**
* Starts a standard animation on a QGraphicsItem.
*
* @param item the item to animate in some fashion
* @param anim the type of animation to perform
* @return the id of the animation
* @deprecated use new Animator API with Qt Kinetic
**/
/**
* Stops an item movement before the animation is complete.
* Note that it is not necessary to call
* this on normal completion of the animation.
*
* @param id the id of the animation as returned by moveItem
* @deprecated use new Animator API with Qt Kinetic
*/
/**
* Starts a custom animation, preventing the need to create a timeline
* with its own timer tick.
*
* @param frames the number of frames this animation should persist for
* @param duration the length, in milliseconds, the animation will take
* @param curve the curve applied to the frame rate
* @param receive the object that will handle the actual animation
* @param method the method name of slot to be invoked on each update.
* It must take a qreal. So if the slot is animate(qreal),
* pass in "animate" as the method parameter.
* It has an optional integer paramenter that takes an
* integer that reapresents the animation id, useful if
* you want to manage multiple animations with a sigle slot
*
* @return an id that can be used to identify this animation.
* @deprecated use new Animator API with Qt Kinetic
*/
/**
* Stops a custom animation. Note that it is not necessary to call
* this on object destruction, as custom animations associated with
* a given QObject are cleaned up automatically on QObject destruction.
*
* @param id the id of the animation as returned by customAnimation
* @deprecated use new Animator API with Qt Kinetic
*/
/**
* Can be used to query if there are other animations happening. This way
* heavy operations can be delayed until all animations are finished.
* @return true if there are animations going on.
* @since 4.1
* @deprecated use new Animator API with Qt Kinetic
*/
/**
* Register a widget as a scrolling widget.
* This function is deprecated:
* use a ScrollWidget, with setWidget() as your widget instead.
*
* @param widget the widget that offers a scrolling behaviour
* @since 4.4
*/
/**
* unregister the scrolling manager of a certain widget
* This function is deprecated: use ScrollWidget instead.
*
* @param widget the widget we don't want no longer animated
* @since 4.4
*/
Q_SIGNALS:
void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim);
void movementFinished(QGraphicsItem *item);
void elementAnimationFinished(int id);
void customAnimationFinished(int id);
private:
Animator();
friend class AnimatorPrivate;
AnimatorPrivate * const d;
};
} // namespace Plasma
#endif

View file

@ -25,8 +25,6 @@
#include "config-plasma.h" #include "config-plasma.h"
#include <plasma/animations/animation.h>
#include <cmath> #include <cmath>
#include <limits> #include <limits>
@ -480,14 +478,7 @@ void Applet::destroy()
d->transient = true; d->transient = true;
if (isContainment()) { d->cleanUpAndDelete();
d->cleanUpAndDelete();
} else {
Animation *zoomAnim = Plasma::Animator::create(Plasma::Animator::ZoomAnimation);
connect(zoomAnim, SIGNAL(finished()), this, SLOT(cleanUpAndDelete()));
zoomAnim->setTargetWidget(this);
zoomAnim->start();
}
} }
bool Applet::destroyed() const bool Applet::destroyed() const
@ -2904,14 +2895,7 @@ AppletOverlayWidget::AppletOverlayWidget(QGraphicsWidget *parent)
void AppletOverlayWidget::destroy() void AppletOverlayWidget::destroy()
{ {
Animation *anim = Plasma::Animator::create(Plasma::Animator::DisappearAnimation); overlayAnimationComplete();
if (anim) {
connect(anim, SIGNAL(finished()), this, SLOT(overlayAnimationComplete()));
anim->setTargetWidget(this);
anim->start();
} else {
overlayAnimationComplete();
}
} }
void AppletOverlayWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) void AppletOverlayWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
@ -2959,12 +2943,6 @@ void AppletOverlayWidget::paint(QPainter *painter,
painter->fillPath(backgroundShape, wash); painter->fillPath(backgroundShape, wash);
} }
// in QGraphicsWidget now; preserve BC by implementing it as a protected method
void Applet::geometryChanged()
{
emit QGraphicsWidget::geometryChanged();
}
} // Plasma namespace } // Plasma namespace
#include "moc_applet.cpp" #include "moc_applet.cpp"

View file

@ -33,7 +33,6 @@
#include <plasma/configloader.h> #include <plasma/configloader.h>
#include <plasma/packagestructure.h> #include <plasma/packagestructure.h>
#include <plasma/plasma.h> #include <plasma/plasma.h>
#include <plasma/animator.h>
#include <plasma/version.h> #include <plasma/version.h>
#include <plasma/framesvg.h> #include <plasma/framesvg.h>
@ -720,9 +719,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
*/ */
void releaseVisualFocus(); void releaseVisualFocus();
protected:
void geometryChanged(); // in QGraphicsWidget now; preserve BC
Q_SIGNALS: Q_SIGNALS:
/** /**
* Emitted when the user completes a transformation of the applet. * Emitted when the user completes a transformation of the applet.

View file

@ -53,7 +53,6 @@
#endif #endif
#include "abstracttoolbox.h" #include "abstracttoolbox.h"
#include "animator.h"
#include "containmentactions.h" #include "containmentactions.h"
#include "containmentactionspluginsconfig.h" #include "containmentactionspluginsconfig.h"
#include "corona.h" #include "corona.h"
@ -69,7 +68,6 @@
#include "private/wallpaper_p.h" #include "private/wallpaper_p.h"
#include "plasma/plasma.h" #include "plasma/plasma.h"
#include "animations/animation.h"
namespace Plasma namespace Plasma
{ {
@ -880,17 +878,7 @@ void Containment::addApplet(Applet *applet, const QPointF &pos, bool delayInit)
if (!delayInit && !currentContainment) { if (!delayInit && !currentContainment) {
applet->restore(*applet->d->mainConfigGroup()); applet->restore(*applet->d->mainConfigGroup());
applet->init(); applet->init();
Plasma::Animation *anim = Plasma::Animator::create(Plasma::Animator::AppearAnimation); d->appletAppeared(applet);
if (anim) {
connect(anim, SIGNAL(finished()), this, SLOT(appletAppearAnimationComplete()));
anim->setTargetWidget(applet);
//FIXME: small hack until we have proper js anim support; allows 'zoom' to work in the
//'right' direction for appearance
anim->setDirection(QAbstractAnimation::Backward);
anim->start(QAbstractAnimation::DeleteWhenStopped);
} else {
d->appletAppeared(applet);
}
} }
applet->setFlag(QGraphicsItem::ItemIsMovable, true); applet->setFlag(QGraphicsItem::ItemIsMovable, true);
@ -2124,17 +2112,6 @@ void ContainmentPrivate::appletDestroyed(Plasma::Applet *applet)
emit q->configNeedsSaving(); emit q->configNeedsSaving();
} }
void ContainmentPrivate::appletAppearAnimationComplete()
{
Animation *anim = qobject_cast<Animation *>(q->sender());
if (anim) {
Applet *applet = qobject_cast<Applet*>(anim->targetWidget());
if (applet) {
appletAppeared(applet);
}
}
}
void ContainmentPrivate::appletAppeared(Applet *applet) void ContainmentPrivate::appletAppeared(Applet *applet)
{ {
//kDebug() << type << Containment::DesktopContainment; //kDebug() << type << Containment::DesktopContainment;

View file

@ -30,7 +30,6 @@
#include <ksharedconfig.h> #include <ksharedconfig.h>
#include <plasma/applet.h> #include <plasma/applet.h>
#include <plasma/animator.h>
namespace Plasma namespace Plasma
@ -615,7 +614,6 @@ Q_SIGNALS:
Containment(const QString &packagePath, uint appletId, const QVariantList &args); Containment(const QString &packagePath, uint appletId, const QVariantList &args);
Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*)) Q_PRIVATE_SLOT(d, void appletDestroyed(Plasma::Applet*))
Q_PRIVATE_SLOT(d, void appletAppearAnimationComplete())
Q_PRIVATE_SLOT(d, void triggerShowAddWidgets()) Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
Q_PRIVATE_SLOT(d, void positionToolBox()) Q_PRIVATE_SLOT(d, void positionToolBox())
Q_PRIVATE_SLOT(d, void requestConfiguration()) Q_PRIVATE_SLOT(d, void requestConfiguration())

View file

@ -43,12 +43,10 @@
#include <kshortcutsdialog.h> #include <kshortcutsdialog.h>
#include <kwindowsystem.h> #include <kwindowsystem.h>
#include "animator.h"
#include "abstracttoolbox.h" #include "abstracttoolbox.h"
#include "containment.h" #include "containment.h"
#include "containmentactionspluginsconfig.h" #include "containmentactionspluginsconfig.h"
#include "view.h" #include "view.h"
#include "private/animator_p.h"
#include "private/applet_p.h" #include "private/applet_p.h"
#include "private/containment_p.h" #include "private/containment_p.h"
#include "tooltipmanager.h" #include "tooltipmanager.h"
@ -356,16 +354,6 @@ Containment *Corona::addContainmentDelayed(const QString &name, const QVariantLi
return 0; return 0;
} }
void Corona::mapAnimation(Animator::Animation from, Animator::Animation to)
{
AnimatorPrivate::mapAnimation(from, to);
}
void Corona::mapAnimation(Animator::Animation from, const QString &to)
{
AnimatorPrivate::mapAnimation(from, to);
}
void Corona::addOffscreenWidget(QGraphicsWidget *widget) void Corona::addOffscreenWidget(QGraphicsWidget *widget)
{ {
foreach (QGraphicsWidget *w, d->offscreenWidgets) { foreach (QGraphicsWidget *w, d->offscreenWidgets) {

View file

@ -456,24 +456,6 @@ protected:
**/ **/
virtual void loadDefaultLayout(); virtual void loadDefaultLayout();
/**
* Maps a stock animation to one of the semantic animations. Used to control things such
* as what animation is used to make a Plasma::Appear appear in a containment.
* @param from the animation to map a new value to
* @param to the animation value to map to from
* @since 4.5
*/
void mapAnimation(Animator::Animation from, Animator::Animation to);
/**
* Maps a loadable animation to one of the semantic animations. Used to control things such
* as what animation is used to make a Plasma::Appear appear in a containment.
* @param from the animation to map a new value to
* @param to the animation value to map to from; this must map to a Javascript animation
* @since 4.5
*/
void mapAnimation(Animator::Animation from, const QString &to);
/** /**
* @return The preferred toolbox plugin name for a given containment type. * @return The preferred toolbox plugin name for a given containment type.
* @param type the containment type of which we want to know the preferred toolbox plugin. * @param type the containment type of which we want to know the preferred toolbox plugin.

View file

@ -1,83 +0,0 @@
[Desktop Entry]
Type=ServiceType
X-KDE-ServiceType=Plasma/Animator
Comment=Plasma Animation Engine
Comment[ar]=محرك تحريك البلازما
Comment[as]=Plasma Animation Engine
Comment[ast]=Motor d'animación Plasma
Comment[be@latin]=Systema animacyi Plasma
Comment[bg]=Ядро за анимации на Plasma
Comment[bn]= ি ি
Comment[bn_IN]=Plasma ি ি
Comment[bs]=Plazma motor animacija
Comment[ca]=Motor d'animació del Plasma
Comment[ca@valencia]=Motor d'animació del Plasma
Comment[cs]=Animační nástroj Plasma
Comment[da]=Plasma-animationsmotor
Comment[de]=Plasma-Animations-Treiber
Comment[el]=Μηχανή εφέ κίνησης του Plasma
Comment[en_GB]=Plasma Animation Engine
Comment[eo]=Viviga motoro de Plasma
Comment[es]=Motor de animación para Plasma
Comment[et]=Plasma animatsiooni mootor
Comment[eu]=Plasma animazio motorra
Comment[fi]=Plasma-animointimoottori
Comment[fr]=Moteur d'animation Plasma
Comment[fy]=Plasma animaasje motor
Comment[ga]=Inneall Beochana Plasma
Comment[gl]=Motor de animación de Plasma
Comment[gu]= િ િ
Comment[he]=מנוע אנימציה של Plasma
Comment[hne]= ि ि
Comment[hr]=Plasmin animatorski mehanizam
Comment[hsb]=Plasma-engine za animacije
Comment[hu]=Plasma animációkezelő
Comment[hy]=Պլազմա կենդանության գործիք
Comment[ia]=Motor de animation Plasma
Comment[id]=Mesin Animasi Plasma
Comment[is]=Plasma hreyfingastjóri
Comment[it]=Motore animazione Plasma
Comment[ja]=Plasma
Comment[kk]=Plasma анимация тетігі
Comment[km]=
Comment[kn]= (ಿ)
Comment[ko]=Plasma
Comment[ku]=Motora Zindîkirina Plasma
Comment[lt]=Plasma animacijos varikliukas
Comment[lv]=Plasma animācijas dzinējs
Comment[mai]= ि
Comment[ml]= ി ി
Comment[mr]= ि
Comment[nb]=Plasma animasjonsmotor
Comment[nds]=Plasma-Animeerkarn
Comment[nl]=Plasma-animatie-engine
Comment[nn]=Plasma-animasjonsmotor
Comment[pa]=
Comment[pl]=Silnik animacji Plazmy
Comment[pt]=Motor de Animação do Plasma
Comment[pt_BR]=Mecanismo de animação do Plasma
Comment[ro]=Motor de animație Plasma
Comment[ru]=Движок анимации для Plasma
Comment[se]=Plasma-animerenmohtor
Comment[si]=Plasma
Comment[sk]=Animačný nástroj Plasma
Comment[sl]=Animacijski pogon za Plasmo
Comment[sr]=Плазма мотор анимација
Comment[sr@ijekavian]=Плазма мотор анимација
Comment[sr@ijekavianlatin]=Plasma motor animacija
Comment[sr@latin]=Plasma motor animacija
Comment[sv]=Animeringsgränssnitt i Plasma
Comment[ta]=ி ி
Comment[tg]=Системаи аниматсионии Plasma
Comment[th]=
Comment[tr]=Plasma Canlandırma Motoru
Comment[tt]=Plasma анимация өчен корал
Comment[ug]=Plasma جانلاندۇرۇم ماتورى
Comment[uk]=Рушій анімації Плазми
Comment[vi]=Cơ chế hot nh Plasma
Comment[wa]=Moteur d' animåcion di Plasma
Comment[x-test]=xxPlasma Animation Enginexx
Comment[zh_CN]=Plasma
Comment[zh_TW]=Plasma

View file

@ -328,11 +328,10 @@ void DataEngine::removeAllSources()
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
Plasma::DataContainer *s = it.value(); Plasma::DataContainer *s = it.value();
const QString source = it.key();
it.remove(); it.remove();
s->disconnect(this); s->disconnect(this);
s->deleteLater(); s->deleteLater();
emit sourceRemoved(source); emit sourceRemoved(it.key());
} }
} }

View file

@ -46,7 +46,6 @@
#include <netwm.h> #include <netwm.h>
#include "plasma/applet.h" #include "plasma/applet.h"
#include "plasma/animator.h"
#include "plasma/containment.h" #include "plasma/containment.h"
#include "plasma/corona.h" #include "plasma/corona.h"
#include "plasma/extenders/extender.h" #include "plasma/extenders/extender.h"

View file

@ -1,69 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_ABSTRACTANIMATIONPRIVATE_P_H
#define PLASMA_ABSTRACTANIMATIONPRIVATE_P_H
#include <QEasingCurve>
#include <QtCore/qsharedpointer.h>
class QAbstractAnimation;
namespace Plasma
{
class AnimationPrivate
{
public:
AbstractAnimationPrivate();
/**
* Object the animation(s) should act upon.
*/
QWeakPointer<QGraphicsWidget> animObject;
/**
* Animation direction: where the animation will move.
*/
qint8 animDirection;
/**
* Animation distance: displacement factor for animations where
* there is change in the position of animated widget.
*/
qreal animDistance;
/**
* Animation easing curve type
*/
QEasingCurve easingCurve;
/**
* Animation direction, the idea is to offer a way
* to rewind the animation by setDirection(QAbstractAnimation::Backward).
*/
bool forwards;
/**
* Duration of the animation. Default is 250ms.
*/
int duration;
};
}
#endif // PLASMA_ABSTRACTANIMATIONPRIVATE_P_H

View file

@ -1,51 +0,0 @@
/*
Copyright (C) 2009 Adenilson Cavalcanti <adenilson.silva@idnt.org.br>
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, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_ANIMATIONPRIVATE_P_H
#define PLASMA_ANIMATIONPRIVATE_P_H
#include <QEasingCurve>
#include <QtCore/qsharedpointer.h>
class QAbstractAnimation;
namespace Plasma
{
class AnimationPrivate
{
public:
AnimationPrivate();
/**
* Object the animation(s) should act upon.
*/
QWeakPointer<QGraphicsWidget> animObject;
/**
* Animation easing curve type
*/
QEasingCurve easingCurve;
/**
* Duration of the animation. Default is 250ms.
*/
int duration;
};
}
#endif // PLASMA_ANIMATIONPRIVATE_P_H

View file

@ -1,146 +0,0 @@
/*
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
* 2007 Alexis Ménard <darktears31@gmail.com>
*
* 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 ANIMATOR_P_H
#define ANIMATOR_P_H
#include <QHash>
#include <QPixmap>
#include <QSet>
#include <QtCore/qdatetime.h>
#include <QTimeLine>
class QGraphicsItem;
namespace Plasma
{
class AnimationDriver;
class KineticScrolling;
struct AnimationState
{
QGraphicsItem *item;
QObject *qobj;
Animator::Animation animation;
Animator::CurveShape curve;
int interval;
int currentInterval;
int frames;
int currentFrame;
int id;
};
struct ElementAnimationState
{
QGraphicsItem *item;
QObject *qobj;
Animator::CurveShape curve;
Animator::Animation animation;
int interval;
int currentInterval;
int frames;
int currentFrame;
int id;
QPixmap pixmap;
};
struct MovementState
{
QGraphicsItem *item;
QObject *qobj;
Animator::CurveShape curve;
Animator::Movement movement;
int interval;
int currentInterval;
int frames;
int currentFrame;
QPoint start;
QPoint destination;
int id;
};
struct CustomAnimationState
{
Animator::CurveShape curve;
int frames;
int currentFrame;
int frameInterval;
int interval;
int currentInterval;
int id;
QObject *receiver;
char *slot;
};
class Animator;
class AnimatorPrivate
{
public:
AnimatorPrivate(Animator *parent);
~AnimatorPrivate();
qreal calculateProgress(int time, int duration, Animator::CurveShape curve);
void performAnimation(qreal amount, const AnimationState *state);
void performMovement(qreal amount, const MovementState *state);
void init(Animator *q);
void cleanupStates();
void animatedItemDestroyed(QObject*);
void movingItemDestroyed(QObject*);
void animatedElementDestroyed(QObject*);
void customAnimReceiverDestroyed(QObject*);
void scrollStateChanged(QAbstractAnimation::State newState,
QAbstractAnimation::State oldState);
Animator *q;
AnimationDriver *driver;
int animId;
int timerId;
QTime time;
QTimeLine timeline;
// active items
QHash<QGraphicsItem *, AnimationState *> animatedItems;
QHash<QGraphicsItem *, MovementState *> movingItems;
QHash<int, ElementAnimationState *> animatedElements;
QHash<int, CustomAnimationState *> customAnims;
// items to cull
QSet<AnimationState *> animatedItemsToDelete;
QSet<MovementState *> movingItemsToDelete;
QSet<ElementAnimationState *> animatedElementsToDelete;
QSet<CustomAnimationState *> customAnimsToDelete;
QHash<QGraphicsWidget *, KineticScrolling *> scrollingManagers;
static void mapAnimation(Animator::Animation from, Animator::Animation to);
static void mapAnimation(Animator::Animation from, const QString &to);
static QHash<Animator::Animation, Animator::Animation> s_stockAnimMappings;
static QHash<Animator::Animation, QString> s_loadableAnimMappings;
};
}
#endif

View file

@ -28,7 +28,6 @@
#include <kactioncollection.h> #include <kactioncollection.h>
#include <kconfigdialog.h> #include <kconfigdialog.h>
#include "plasma/animator.h"
#include "plasma/private/applethandle_p.h" #include "plasma/private/applethandle_p.h"
#include "plasma/private/dataengineconsumer_p.h" #include "plasma/private/dataengineconsumer_p.h"

View file

@ -28,7 +28,6 @@
#include <QtGui/qgraphicsview.h> #include <QtGui/qgraphicsview.h>
#include <QtGui/qgraphicsitem.h> #include <QtGui/qgraphicsitem.h>
#include "animator.h"
#include "svg.h" #include "svg.h"
class QGraphicsView; class QGraphicsView;

View file

@ -27,8 +27,6 @@
#include <plasma/theme.h> #include <plasma/theme.h>
#include <plasma/framesvg.h> #include <plasma/framesvg.h>
#include <plasma/animator.h>
namespace Plasma namespace Plasma
{ {
@ -59,15 +57,6 @@ void FocusIndicator::init(QGraphicsWidget *parent)
m_background->setCacheAllRenderedFrames(true); m_background->setCacheAllRenderedFrames(true);
m_fade = Animator::create(Animator::FadeAnimation, this);
m_fade->setTargetWidget(this);
m_fade->setProperty("startOpacity", 0.0);
m_fade->setProperty("targetOpacity", 1.0);
m_hoverAnimation = Animator::create(Animator::PixmapTransitionAnimation);
m_hoverAnimation->setProperty("duration", 250);
m_hoverAnimation->setTargetWidget(this);
m_testPrefix = "hover"; m_testPrefix = "hover";
if (m_background->hasElementPrefix("shadow") || if (m_background->hasElementPrefix("shadow") ||
m_background->hasElement("shadow")) { m_background->hasElement("shadow")) {
@ -81,7 +70,6 @@ void FocusIndicator::init(QGraphicsWidget *parent)
FocusIndicator::~FocusIndicator() FocusIndicator::~FocusIndicator()
{ {
m_parent->removeEventFilter(this); m_parent->removeEventFilter(this);
delete m_fade;
} }
void FocusIndicator::setCustomGeometry(const QRectF &geometry) void FocusIndicator::setCustomGeometry(const QRectF &geometry)
@ -138,18 +126,10 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
if (!m_parent->hasFocus()) { if (!m_parent->hasFocus()) {
m_prefix = m_customPrefix % "hover"; m_prefix = m_customPrefix % "hover";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop();
if (m_background->hasElementPrefix(m_testPrefix)) { if (m_background->hasElementPrefix(m_testPrefix)) {
m_background->setElementPrefix(m_customPrefix % "shadow"); m_background->setElementPrefix(m_customPrefix % "shadow");
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
m_background->setElementPrefix(m_customPrefix % "hover"); m_background->setElementPrefix(m_customPrefix % "hover");
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
} else if (m_background->hasElement(m_testPrefix)) {
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow"));
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "hover"));
} }
m_hoverAnimation->start();
} }
break; break;
@ -157,18 +137,11 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
if (!m_parent->hasFocus()) { if (!m_parent->hasFocus()) {
m_prefix = m_customPrefix % "shadow"; m_prefix = m_customPrefix % "shadow";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop();
if (m_background->hasElementPrefix(m_testPrefix)) { if (m_background->hasElementPrefix(m_testPrefix)) {
m_background->setElementPrefix(m_customPrefix % "hover"); m_background->setElementPrefix(m_customPrefix % "hover");
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
m_background->setElementPrefix(m_customPrefix % "shadow"); m_background->setElementPrefix(m_customPrefix % "shadow");
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
} else if (m_background->hasElement(m_testPrefix)) {
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "hover"));
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow"));
} }
m_hoverAnimation->start();
} }
break; break;
@ -179,38 +152,23 @@ bool FocusIndicator::eventFilter(QObject *watched, QEvent *event)
case QEvent::FocusIn: case QEvent::FocusIn:
m_prefix = m_customPrefix % "focus"; m_prefix = m_customPrefix % "focus";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop();
if (m_background->hasElementPrefix(m_customPrefix % "focus")) { if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
//m_background->setElementPrefix(m_customPrefix % "shadow"); //m_background->setElementPrefix(m_customPrefix % "shadow");
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
m_background->setElementPrefix(m_customPrefix % "focus"); m_background->setElementPrefix(m_customPrefix % "focus");
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
} else if (m_background->hasElement(m_customPrefix % "focus")) {
//m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "shadow"));
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "focus"));
} }
m_hoverAnimation->start();
break; break;
case QEvent::FocusOut: case QEvent::FocusOut:
if (!m_isUnderMouse) { if (!m_isUnderMouse) {
m_prefix = m_customPrefix % "shadow"; m_prefix = m_customPrefix % "shadow";
syncGeometry(); syncGeometry();
m_hoverAnimation->stop();
if (m_background->hasElementPrefix(m_customPrefix % "focus")) { if (m_background->hasElementPrefix(m_customPrefix % "focus")) {
m_background->setElementPrefix("focus"); m_background->setElementPrefix("focus");
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
m_background->setElementPrefix("shadow"); m_background->setElementPrefix("shadow");
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
} else if (m_background->hasElement(m_customPrefix % "focus")) {
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_customPrefix % "focus"));
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_customPrefix % "shadow"));
} }
m_hoverAnimation->start();
} }
break; break;
@ -238,40 +196,17 @@ void FocusIndicator::resizeEvent(QGraphicsSceneResizeEvent *)
m_background->resizeFrame(size()); m_background->resizeFrame(size());
} }
if (m_hoverAnimation->state() == QAbstractAnimation::Running) {
m_hoverAnimation->stop();
}
if (m_background->hasElementPrefix(m_testPrefix)) { if (m_background->hasElementPrefix(m_testPrefix)) {
m_background->setElementPrefix(m_prefix); m_background->setElementPrefix(m_prefix);
m_hoverAnimation->setProperty("startPixmap", m_background->framePixmap());
m_hoverAnimation->setProperty("targetPixmap", m_background->framePixmap());
} else if (m_background->hasElement(m_testPrefix)) {
m_hoverAnimation->setProperty("startPixmap", m_background->pixmap(m_prefix));
m_hoverAnimation->setProperty("targetPixmap", m_background->pixmap(m_prefix));
} }
} }
void FocusIndicator::animateVisibility(const bool visible)
{
m_fade->setProperty("startOpacity", opacity());
if (visible) {
m_fade->setProperty("targetOpacity", 1.0);
} else {
m_fade->setProperty("targetOpacity", 0);
}
m_fade->start();
}
void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void FocusIndicator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
Q_UNUSED(painter)
Q_UNUSED(option) Q_UNUSED(option)
Q_UNUSED(widget) Q_UNUSED(widget)
#pragma remove? it is a stub now...
painter->drawPixmap(
option->rect,
m_hoverAnimation->property("currentPixmap").value<QPixmap>());
} }
void FocusIndicator::syncGeometry() void FocusIndicator::syncGeometry()

View file

@ -22,8 +22,6 @@
#include <QGraphicsWidget> #include <QGraphicsWidget>
#include <plasma/animations/animation.h>
namespace Plasma namespace Plasma
{ {
class FrameSvg; class FrameSvg;
@ -40,7 +38,6 @@ public:
void setCustomGeometry(const QRectF &geometry); void setCustomGeometry(const QRectF &geometry);
void setCustomPrefix(const QString &prefix); void setCustomPrefix(const QString &prefix);
void animateVisibility(const bool visible);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setFrameSvg(FrameSvg *svg); void setFrameSvg(FrameSvg *svg);
@ -57,8 +54,6 @@ private:
void init(QGraphicsWidget *parent); void init(QGraphicsWidget *parent);
QGraphicsWidget *m_parent; QGraphicsWidget *m_parent;
Plasma::FrameSvg *m_background; Plasma::FrameSvg *m_background;
Animation *m_fade;
Animation *m_hoverAnimation;
QRectF m_customGeometry; QRectF m_customGeometry;
QString m_prefix; QString m_prefix;
QString m_customPrefix; QString m_customPrefix;

View file

@ -28,10 +28,7 @@
#include <QApplication> #include <QApplication>
#include <QStyleOption> #include <QStyleOption>
#include <QToolButton> #include <QToolButton>
#include <QPropertyAnimation>
#include <QtCore/qsharedpointer.h> #include <QtCore/qsharedpointer.h>
#include <QtGui/qbrush.h>
#include <QtGui/qbrush.h> #include <QtGui/qbrush.h>
// KDE // KDE
@ -43,7 +40,6 @@
#include "plasma/plasma.h" #include "plasma/plasma.h"
#include "plasma/theme.h" #include "plasma/theme.h"
#include "plasma/animator.h"
#include "plasma/framesvg.h" #include "plasma/framesvg.h"
#include "plasma/paintutils.h" #include "plasma/paintutils.h"
@ -107,8 +103,6 @@ public:
QList<bool> highlightedTabs; QList<bool> highlightedTabs;
QWeakPointer<QPropertyAnimation> anim;
QRect currentAnimRect; QRect currentAnimRect;
QRect startAnimRect; QRect startAnimRect;
QPoint mousePressOffset; QPoint mousePressOffset;
@ -140,13 +134,11 @@ NativeTabBar::NativeTabBar(QWidget *parent)
: KTabBar(parent), : KTabBar(parent),
d(new NativeTabBarPrivate(this)) d(new NativeTabBarPrivate(this))
{ {
connect(this, SIGNAL(currentChanged(int)), this, SLOT(startAnimation()));
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
} }
NativeTabBar::~NativeTabBar() NativeTabBar::~NativeTabBar()
{ {
d->anim.clear();
delete d; delete d;
} }
@ -263,13 +255,7 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
} }
// Drawing Tabborders // Drawing Tabborders
QRect movingRect; const QRect movingRect = d->currentAnimRect;
if (d->currentAnimRect.isNull() || !d->anim || d->anim.data()->state() != QAbstractAnimation::Running) {
movingRect = tabRect(currentIndex());
} else {
movingRect = d->currentAnimRect;
}
//resizing here because in resizeevent the first time is invalid (still no tabs) //resizing here because in resizeevent the first time is invalid (still no tabs)
d->buttonSvg->resizeFrame(movingRect.size()); d->buttonSvg->resizeFrame(movingRect.size());
@ -445,42 +431,9 @@ void NativeTabBar::tabLayoutChange()
} }
} }
void NativeTabBar::startAnimation()
{
d->storeLastIndex();
QPropertyAnimation *anim = d->anim.data();
if (anim) {
anim->stop();
d->anim.clear();
}
anim = new QPropertyAnimation(this, "onValueChanged", this);
d->anim = anim;
anim->setDuration(150);
QRect rect = tabRect(currentIndex());
QRect lastRect = d->startAnimRect.isNull() ? tabRect(lastIndex())
: d->startAnimRect;
int x = isHorizontal() ? (int)(lastRect.x() - (lastRect.x() - rect.x())) : rect.x();
int y = isHorizontal() ? rect.y() : (int)(lastRect.y() - (lastRect.y() - rect.y()));
QSizeF sz = lastRect.size() - (lastRect.size() - rect.size());
d->currentAnimRect = QRect(x, y, (int)(sz.width()), (int)(sz.height()));
anim->setStartValue(lastRect);
anim->setEndValue(d->currentAnimRect);
anim->start(QAbstractAnimation::DeleteWhenStopped);
}
void NativeTabBar::setOnValueChanged(QRectF value) void NativeTabBar::setOnValueChanged(QRectF value)
{ {
if (value == d->anim.data()->endValue()) { Q_UNUSED(value);
d->animProgress = 1;
animationFinished();
return;
}
d->currentAnimRect = value.toRect();
update(); update();
} }
@ -489,13 +442,6 @@ QRectF NativeTabBar::onValueChanged() const
return d->currentAnimRect; return d->currentAnimRect;
} }
void NativeTabBar::animationFinished()
{
d->startAnimRect = QRect();
d->currentAnimRect = QRect();
update();
}
bool NativeTabBar::isVertical() const bool NativeTabBar::isVertical() const
{ {
switch (shape()) { switch (shape()) {

View file

@ -74,8 +74,6 @@ protected:
void mouseReleaseEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event);
protected slots: protected slots:
void animationFinished();
void startAnimation();
void setOnValueChanged(QRectF val); void setOnValueChanged(QRectF val);
QRectF onValueChanged() const; QRectF onValueChanged() const;

View file

@ -22,8 +22,6 @@
#include "kconfig.h" #include "kconfig.h"
#include "kconfigdialog.h" #include "kconfigdialog.h"
#include "animations/animationscriptengine_p.h"
#include "animator.h"
#include "applet.h" #include "applet.h"
#include "package.h" #include "package.h"
#include "private/applet_p.h" #include "private/applet_p.h"
@ -181,46 +179,6 @@ bool AppletScript::isRegisteredAsDragHandle(QGraphicsItem *item)
return false; return false;
} }
Animation *AppletScript::loadAnimationFromPackage(const QString &name, QObject *parent)
{
if (applet()) {
const QString scopedName = applet()->pluginName() + ":" + name;
if (!AnimationScriptEngine::isAnimationRegistered(scopedName)) {
KConfig conf(applet()->package()->path() + "/metadata.desktop", KConfig::SimpleConfig);
KConfigGroup animConf(&conf, "Animations");
QString file;
foreach (const QString &possibleFile, animConf.keyList()) {
const QStringList anims = animConf.readEntry(possibleFile, QStringList());
if (anims.contains(name)) {
file = possibleFile;
break;
}
}
if (file.isEmpty()) {
return 0;
}
const QString path = applet()->package()->filePath("animations", file);
if (path.isEmpty()) {
kDebug() << "file path was empty for" << file;
return 0;
}
if (!AnimationScriptEngine::loadScript(path, applet()->pluginName() + ':') ||
!AnimationScriptEngine::isAnimationRegistered(scopedName)) {
kDebug() << "script engine loading failed for" << path;
return 0;
}
}
Animation *anim = Animator::create(scopedName, parent ? parent : this);
return anim;
}
return 0;
}
void AppletScript::configChanged() void AppletScript::configChanged()
{ {
} }

View file

@ -252,14 +252,6 @@ protected:
*/ */
bool isRegisteredAsDragHandle(QGraphicsItem *item); bool isRegisteredAsDragHandle(QGraphicsItem *item);
/**
* Loads an animation from the applet package
* @param animation the animation to load
* @return an Animation object on success, a NULL pointer on failure
* @since 4.5
*/
Animation *loadAnimationFromPackage(const QString &name, QObject *parent);
private: private:
friend class Applet; friend class Applet;
friend class PopupApplet; friend class PopupApplet;

View file

@ -44,8 +44,6 @@
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <kwindowsystem.h> #include <kwindowsystem.h>
#include "animations/animationscriptengine_p.h"
#include "libplasma-theme-global.h" #include "libplasma-theme-global.h"
#include "private/packages_p.h" #include "private/packages_p.h"
#include "windoweffects.h" #include "windoweffects.h"
@ -190,7 +188,6 @@ public:
QHash<QString, QPixmap> pixmapsToCache; QHash<QString, QPixmap> pixmapsToCache;
QHash<QString, QString> keysToCache; QHash<QString, QString> keysToCache;
QHash<QString, QString> idsToCache; QHash<QString, QString> idsToCache;
QHash<QString, QString> animationMapping;
QHash<styles, QString> cachedStyleSheets; QHash<styles, QString> cachedStyleSheets;
QHash<QString, QString> discoveries; QHash<QString, QString> discoveries;
QTimer *saveTimer; QTimer *saveTimer;
@ -652,28 +649,6 @@ void ThemePrivate::processWallpaperSettings(KConfigBase *metadata)
defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT); defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT);
} }
void ThemePrivate::processAnimationSettings(const QString &theme, KConfigBase *metadata)
{
KConfigGroup cg(metadata, "Animations");
const QString animDir = QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/animations/");
foreach (const QString &path, cg.keyList()) {
const QStringList anims = cg.readEntry(path, QStringList());
foreach (const QString &anim, anims) {
if (!animationMapping.contains(anim)) {
kDebug() << "Registering animation. animDir: " << animDir
<< "\tanim: " << anim
<< "\tpath: " << path << "\t*******\n\n\n";
//key: desktoptheme/default/animations/+ all.js
//value: ZoomAnimation
animationMapping.insert(anim, animDir % path);
} else {
kDebug() << "************Animation already registered!\n\n\n";
}
}
}
}
void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings) void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings)
{ {
//kDebug() << tempThemeName; //kDebug() << tempThemeName;
@ -723,10 +698,6 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
processWallpaperSettings(&metadata); processWallpaperSettings(&metadata);
AnimationScriptEngine::clearAnimations();
animationMapping.clear();
processAnimationSettings(themeName, &metadata);
KConfigGroup cg(&metadata, "Settings"); KConfigGroup cg(&metadata, "Settings");
useNativeWidgetStyle = cg.readEntry("UseNativeWidgetStyle", false); useNativeWidgetStyle = cg.readEntry("UseNativeWidgetStyle", false);
QString fallback = cg.readEntry("FallbackTheme", QString()); QString fallback = cg.readEntry("FallbackTheme", QString());
@ -752,7 +723,6 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
foreach (const QString &theme, fallbackThemes) { foreach (const QString &theme, fallbackThemes) {
QString metadataPath(KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop"))); QString metadataPath(KStandardDirs::locate("data", QLatin1Literal("desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
KConfig metadata(metadataPath); KConfig metadata(metadataPath);
processAnimationSettings(theme, &metadata);
processWallpaperSettings(&metadata); processWallpaperSettings(&metadata);
} }
} }
@ -838,17 +808,6 @@ QString Theme::styleSheet(const QString &css) const
return d->processStyleSheet(css); return d->processStyleSheet(css);
} }
QString Theme::animationPath(const QString &name) const
{
const QString path = d->animationMapping.value(name);
if (path.isEmpty()) {
//kError() << "****** FAILED TO FIND IN MAPPING!";
return path;
}
return KStandardDirs::locate("data", path);
}
QString Theme::wallpaperPath(const QSize &size) const QString Theme::wallpaperPath(const QSize &size) const
{ {
QString fullPath; QString fullPath;

View file

@ -135,15 +135,6 @@ class PLASMA_EXPORT Theme : public QObject
*/ */
Q_INVOKABLE QString imagePath(const QString &name) const; Q_INVOKABLE QString imagePath(const QString &name) const;
/**
* Retrieves the path for the script file that contains a given
* Javascript animation.
* @param the name of the animation
* @return the full path to the script file, or an emptry string on failure
* @since 4.5
*/
Q_INVOKABLE QString animationPath(const QString &name) const;
/** /**
* Retrieves the default wallpaper associated with this theme. * Retrieves the default wallpaper associated with this theme.
* *

View file

@ -31,8 +31,6 @@
#include <kdebug.h> #include <kdebug.h>
#include <plasma/animator.h>
#include <plasma/animations/animation.h>
#include <plasma/theme.h> #include <plasma/theme.h>
using namespace Plasma; using namespace Plasma;
@ -81,7 +79,6 @@ class Plasma::FlashingLabelPrivate
QFont font; QFont font;
QPixmap pixmap; QPixmap pixmap;
QWeakPointer<Plasma::Animation> anim;
QPixmap renderedPixmap; QPixmap renderedPixmap;
QTextOption textOption; QTextOption textOption;
@ -168,14 +165,6 @@ void FlashingLabel::flash(const QPixmap &pixmap, int duration, Qt::Alignment ali
void FlashingLabel::setAutohide(bool autohide) void FlashingLabel::setAutohide(bool autohide)
{ {
d->autohide = autohide; d->autohide = autohide;
if (autohide) {
if (d->anim.data()) {
connect(d->anim.data(), SIGNAL(finished()), this, SLOT(elementAnimationFinished()));
}
} else if (d->anim.data()) {
disconnect(d->anim.data(), SIGNAL(finished()), this, SLOT(elementAnimationFinished()));
}
} }
bool FlashingLabel::autohide() const bool FlashingLabel::autohide() const
@ -199,19 +188,6 @@ void FlashingLabel::fadeIn()
} }
d->state = FlashingLabelPrivate::Visible; d->state = FlashingLabelPrivate::Visible;
if (!d->anim.data()) {
d->anim = Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
Plasma::Animation *animation = d->anim.data();
animation->setProperty("startPixmap", d->renderedPixmap);
animation->setTargetWidget(this);
animation->start();
} else {
Plasma::Animation *animation = d->anim.data();
if (animation->state() == QAbstractAnimation::Running) {
animation->stop();
animation->start();
}
}
} }
void FlashingLabel::fadeOut() void FlashingLabel::fadeOut()
@ -221,18 +197,6 @@ void FlashingLabel::fadeOut()
} }
d->state = FlashingLabelPrivate::Invisible; d->state = FlashingLabelPrivate::Invisible;
if (d->anim.data()) {
Plasma::Animation *animation = d->anim.data();
animation->setProperty("direction", QAbstractAnimation::Backward);
animation->start(QAbstractAnimation::DeleteWhenStopped);
} else {
d->anim = Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation);
Plasma::Animation *animation = d->anim.data();
animation->setProperty("direction", QAbstractAnimation::Backward);
animation->setProperty("startPixmap", d->renderedPixmap);
animation->setTargetWidget(this);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
} }
void FlashingLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void FlashingLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@ -240,10 +204,7 @@ void FlashingLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
Q_UNUSED(option) Q_UNUSED(option)
Q_UNUSED(widget) Q_UNUSED(widget)
if (d->anim.data() && d->anim.data()->state() == QAbstractAnimation::Running) { if (d->state == FlashingLabelPrivate::Visible) {
Plasma::Animation *animation = d->anim.data();
painter->drawPixmap(0, 0, qvariant_cast<QPixmap>(animation->property("currentPixmap")));
} else if (d->state == FlashingLabelPrivate::Visible) {
painter->drawPixmap(0, 0, d->renderedPixmap); painter->drawPixmap(0, 0, d->renderedPixmap);
} }
} }
@ -291,11 +252,6 @@ void FlashingLabelPrivate::renderPixmap(const QSize &size)
painter.drawPixmap(p, pixmap); painter.drawPixmap(p, pixmap);
} }
painter.end(); painter.end();
if (anim.data()) {
Plasma::Animation *animation = anim.data();
animation->setProperty("startPixmap", renderedPixmap);
}
} }
void FlashingLabelPrivate::setupFlash(int duration) void FlashingLabelPrivate::setupFlash(int duration)
@ -317,7 +273,7 @@ void FlashingLabelPrivate::setupFlash(int duration)
void FlashingLabelPrivate::elementAnimationFinished() void FlashingLabelPrivate::elementAnimationFinished()
{ {
if (autohide && state == FlashingLabelPrivate::Invisible && anim.data()) { if (autohide && state == FlashingLabelPrivate::Invisible) {
q->hide(); q->hide();
} }
} }

View file

@ -44,8 +44,6 @@
#include <kmimetype.h> #include <kmimetype.h>
#include <kurl.h> #include <kurl.h>
#include "animator.h"
#include "animations/animation.h"
#include "paintutils.h" #include "paintutils.h"
#include "private/themedwidgetinterface_p.h" #include "private/themedwidgetinterface_p.h"
#include "theme.h" #include "theme.h"
@ -77,11 +75,6 @@ bool IconHoverAnimation::fadeIn() const
return m_fadeIn; return m_fadeIn;
} }
QPropertyAnimation *IconHoverAnimation::animation() const
{
return m_animation.data();
}
void IconHoverAnimation::setValue(qreal value) void IconHoverAnimation::setValue(qreal value)
{ {
m_value = value; m_value = value;
@ -94,11 +87,6 @@ void IconHoverAnimation::setFadeIn(bool fadeIn)
m_fadeIn = fadeIn; m_fadeIn = fadeIn;
} }
void IconHoverAnimation::setAnimation(QPropertyAnimation *animation)
{
m_animation = animation;
}
IconWidgetPrivate::IconWidgetPrivate(IconWidget *i) IconWidgetPrivate::IconWidgetPrivate(IconWidget *i)
: ActionWidgetInterface<IconWidget>(i), : ActionWidgetInterface<IconWidget>(i),
iconSvg(0), iconSvg(0),
@ -170,38 +158,13 @@ IconAction::IconAction(IconWidget *icon, QAction *action)
void IconAction::show() void IconAction::show()
{ {
Animation *animation = m_animation.data();
if (!animation) {
animation = Plasma::Animator::create(Plasma::Animator::PixmapTransitionAnimation, m_icon);
animation->setTargetWidget(m_icon);
m_animation = animation;
} else if (animation->state() == QAbstractAnimation::Running) {
animation->pause();
}
rebuildPixmap(); rebuildPixmap();
m_visible = true; m_visible = true;
animation->setProperty("targetPixmap", m_pixmap);
animation->setDirection(QAbstractAnimation::Forward);
animation->start();
} }
void IconAction::hide() void IconAction::hide()
{ {
if (!m_animation) {
return;
}
Animation *animation = m_animation.data();
if (animation->state() == QAbstractAnimation::Running) {
animation->pause();
}
m_visible = false; m_visible = false;
animation->setDirection(QAbstractAnimation::Backward);
animation->start(QAbstractAnimation::DeleteWhenStopped);
} }
bool IconAction::isVisible() const bool IconAction::isVisible() const
@ -209,11 +172,6 @@ bool IconAction::isVisible() const
return m_visible; return m_visible;
} }
bool IconAction::isAnimating() const
{
return !m_animation.isNull();
}
bool IconAction::isPressed() const bool IconAction::isPressed() const
{ {
return m_pressed; return m_pressed;
@ -339,12 +297,8 @@ void IconAction::paint(QPainter *painter) const
return; return;
} }
Animation *animation = m_animation.data(); if (m_visible) {
if (m_visible && !animation) {
painter->drawPixmap(m_rect.toRect(), m_pixmap); painter->drawPixmap(m_rect.toRect(), m_pixmap);
} else {
painter->drawPixmap(m_rect.toRect(),
animation->property("currentPixmap").value<QPixmap>());
} }
} }
@ -748,21 +702,6 @@ void IconWidgetPrivate::animateMainIcon(bool show, const IconWidgetStates state)
hoverAnimation->setFadeIn(show); hoverAnimation->setFadeIn(show);
QPropertyAnimation *animation = hoverAnimation->animation();
if (!animation) {
animation = new QPropertyAnimation(hoverAnimation, "value");
animation->setDuration(150);
animation->setEasingCurve(QEasingCurve::OutQuad);
animation->setStartValue(0.0);
animation->setEndValue(1.0);
hoverAnimation->setAnimation(animation);
q->connect(animation, SIGNAL(finished()), q, SLOT(hoverAnimationFinished()));
} else if (animation->state() == QAbstractAnimation::Running) {
animation->pause();
}
animation->setDirection(show ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
animation->start(show ? QAbstractAnimation::KeepWhenStopped : QAbstractAnimation::DeleteWhenStopped);
q->update(); q->update();
} }
@ -1163,11 +1102,10 @@ void IconWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
painter->drawPixmap(iconPos, icon); painter->drawPixmap(iconPos, icon);
} }
#pragma probably drop the loop interly
// Draw corner actions // Draw corner actions
foreach (const IconAction *action, d->cornerActions) { foreach (const IconAction *action, d->cornerActions) {
if (action->isAnimating()) { action->paint(painter);
action->paint(painter);
}
} }
// Draw text last because it is overlayed // Draw text last because it is overlayed

View file

@ -30,11 +30,9 @@
#include <QtGui/QGraphicsWidget> #include <QtGui/QGraphicsWidget>
#include <plasma/dataengine.h> #include <plasma/dataengine.h>
#include <plasma/animator.h>
#include <plasma/plasma_export.h> #include <plasma/plasma_export.h>
class QAction; class QAction;
class QPropertyAnimation;
/** /**
* @class IconWidget plasma/widgets/iconwidget.h <Plasma/Widgets/IconWidget> * @class IconWidget plasma/widgets/iconwidget.h <Plasma/Widgets/IconWidget>

View file

@ -79,7 +79,6 @@ public:
void show(); void show();
void hide(); void hide();
bool isVisible() const; bool isVisible() const;
bool isAnimating() const;
QAction *action() const; QAction *action() const;

View file

@ -28,7 +28,6 @@
#include <kdebug.h> #include <kdebug.h>
#include <plasma/framesvg.h> #include <plasma/framesvg.h>
#include <plasma/animator.h>
#include <plasma/theme.h> #include <plasma/theme.h>
namespace Plasma namespace Plasma
{ {
@ -63,9 +62,6 @@ ItemBackground::ItemBackground(QGraphicsWidget *parent)
d(new ItemBackgroundPrivate(this)) d(new ItemBackgroundPrivate(this))
{ {
d->frameSvg = new Plasma::FrameSvg(this); d->frameSvg = new Plasma::FrameSvg(this);
d->anim = new QPropertyAnimation(this, "animationUpdate", this);
d->anim->setStartValue(0);
d->anim->setEndValue(1);
d->opacity = 1; d->opacity = 1;
d->fading = false; d->fading = false;
d->fadeIn = false; d->fadeIn = false;
@ -122,10 +118,6 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
d->newGeometry = d->newGeometry.intersected(QRectF(QPointF(0,0), pw->size())); d->newGeometry = d->newGeometry.intersected(QRectF(QPointF(0,0), pw->size()));
} }
if (d->anim->state() != QAbstractAnimation::Stopped) {
d->anim->stop();
}
if (d->target && d->target->isVisible() && !isVisible()) { if (d->target && d->target->isVisible() && !isVisible()) {
setZValue(d->target->zValue()-1); setZValue(d->target->zValue()-1);
setGeometry(newGeometry); setGeometry(newGeometry);
@ -134,7 +126,6 @@ void ItemBackground::setTarget(const QRectF &newGeometry)
} else { } else {
d->fading = false; d->fading = false;
d->opacity = 1; d->opacity = 1;
d->anim->start();
} }
} }
@ -241,19 +232,12 @@ QVariant ItemBackground::itemChange(GraphicsItemChange change, const QVariant &v
if (change == ItemVisibleChange) { if (change == ItemVisibleChange) {
bool visible = value.toBool(); bool visible = value.toBool();
bool retVisible = visible; bool retVisible = visible;
if (visible == isVisible() || d->anim->state() == QAbstractAnimation::Stopped) { if (visible == isVisible()) {
retVisible = true; retVisible = true;
} }
d->fading = true; d->fading = true;
d->fadeIn = visible; d->fadeIn = visible;
if (d->anim->state() != QAbstractAnimation::Stopped) {
d->anim->stop();
}
d->anim->setDuration(250);
d->anim->start();
return retVisible; return retVisible;
} }

View file

@ -24,12 +24,10 @@
#include <QPainter> #include <QPainter>
#include <QTimeLine> #include <QTimeLine>
#include <QPropertyAnimation>
#include <kdebug.h> #include <kdebug.h>
#include <kglobalsettings.h> #include <kglobalsettings.h>
#include "plasma/animator.h"
#include "plasma/framesvg.h" #include "plasma/framesvg.h"
#include "plasma/theme.h" #include "plasma/theme.h"
@ -271,13 +269,10 @@ Meter::Meter(QGraphicsItem *parent) :
d(new MeterPrivate(this)) d(new MeterPrivate(this))
{ {
d->setSizePolicyAndPreferredSize(); d->setSizePolicyAndPreferredSize();
d->animation = new QPropertyAnimation(d, "meterValue");
} }
Meter::~Meter() Meter::~Meter()
{ {
delete d->animation;
delete d; delete d;
} }
@ -315,19 +310,11 @@ void Meter::setValue(int value)
d->targetValue = qBound(d->minimum, value, d->maximum); d->targetValue = qBound(d->minimum, value, d->maximum);
int delta = abs(d->value - d->targetValue); int delta = abs(d->value - d->targetValue);
if (d->animation->state() != QAbstractAnimation::Running) {
d->animation->stop();
}
//kDebug() << d->targetValue << d->value << delta; //kDebug() << d->targetValue << d->value << delta;
if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) || if (!(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ||
delta / qreal(d->maximum) < 0.1) { delta / qreal(d->maximum) < 0.1) {
d->value = value; d->value = value;
update(); update();
} else {
d->animation->setStartValue(d->value);
d->animation->setEndValue(value);
d->animation->start();
} }
emit valueChanged(value); emit valueChanged(value);
} }

View file

@ -30,8 +30,6 @@
#include <kmimetype.h> #include <kmimetype.h>
#include <kpushbutton.h> #include <kpushbutton.h>
#include "animator.h"
#include "animations/animation.h"
#include "framesvg.h" #include "framesvg.h"
#include "paintutils.h" #include "paintutils.h"
#include "private/actionwidgetinterface_p.h" #include "private/actionwidgetinterface_p.h"
@ -102,15 +100,6 @@ public:
static_cast<KPushButton*>(q->widget())->setIcon(KIcon(pm)); static_cast<KPushButton*>(q->widget())->setIcon(KIcon(pm));
} }
void pressedChanged()
{
if (q->nativeWidget()->isDown() || q->nativeWidget()->isChecked()) {
focusIndicator->animateVisibility(false);
} else {
focusIndicator->animateVisibility(true);
}
}
void syncFrame() void syncFrame()
{ {
if (background) { if (background) {
@ -122,11 +111,9 @@ public:
background->setElementPrefix("normal"); background->setElementPrefix("normal");
background->resizeFrame(q->size()); background->resizeFrame(q->size());
hoverAnimation->setProperty("startPixmap", background->framePixmap());
background->setElementPrefix("active"); background->setElementPrefix("active");
background->resizeFrame(activeRect.size()); background->resizeFrame(activeRect.size());
hoverAnimation->setProperty("targetPixmap", background->framePixmap());
} }
} }
@ -138,8 +125,6 @@ public:
qreal opacity; qreal opacity;
QRectF activeRect; QRectF activeRect;
Animation *hoverAnimation;
FocusIndicator *focusIndicator; FocusIndicator *focusIndicator;
QString imagePath; QString imagePath;
QString absImagePath; QString absImagePath;
@ -189,14 +174,9 @@ PushButton::PushButton(QGraphicsWidget *parent)
d->background->setElementPrefix("normal"); d->background->setElementPrefix("normal");
d->hoverAnimation = Animator::create(Animator::PixmapTransitionAnimation);
d->hoverAnimation->setTargetWidget(this);
KPushButton *native = new KPushButton; KPushButton *native = new KPushButton;
connect(native, SIGNAL(pressed()), this, SIGNAL(pressed())); connect(native, SIGNAL(pressed()), this, SIGNAL(pressed()));
connect(native, SIGNAL(pressed()), this, SLOT(pressedChanged()));
connect(native, SIGNAL(released()), this, SIGNAL(released())); connect(native, SIGNAL(released()), this, SIGNAL(released()));
connect(native, SIGNAL(released()), this, SLOT(pressedChanged()));
connect(native, SIGNAL(clicked()), this, SIGNAL(clicked())); connect(native, SIGNAL(clicked()), this, SIGNAL(clicked()));
connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); connect(native, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
setWidget(native); setWidget(native);
@ -378,17 +358,7 @@ void PushButton::paint(QPainter *painter,
painter->drawPixmap(0, 0, bufferPixmap); painter->drawPixmap(0, 0, bufferPixmap);
} }
//if is under mouse draw the animated glow overlay if (isEnabled()) {
if (!nativeWidget()->isDown() && !nativeWidget()->isChecked() && isEnabled() && acceptHoverEvents() && d->background->hasElementPrefix("active")) {
if (d->hoverAnimation->state() == QAbstractAnimation::Running && !isUnderMouse() && !nativeWidget()->isDefault()) {
d->background->setElementPrefix("active");
d->background->paintFrame(painter, d->activeRect.topLeft());
} else {
painter->drawPixmap(
d->activeRect.topLeft(),
d->hoverAnimation->property("currentPixmap").value<QPixmap>());
}
} else if (isEnabled()) {
d->background->paintFrame(painter); d->background->paintFrame(painter);
} }
@ -473,15 +443,9 @@ void PushButton::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
return; return;
} }
d->hoverAnimation->setProperty("duration", 75);
d->background->setElementPrefix("normal"); d->background->setElementPrefix("normal");
d->hoverAnimation->setProperty("startPixmap", d->background->framePixmap());
d->background->setElementPrefix("active"); d->background->setElementPrefix("active");
d->hoverAnimation->setProperty("targetPixmap", d->background->framePixmap());
d->hoverAnimation->start();
QGraphicsProxyWidget::hoverEnterEvent(event); QGraphicsProxyWidget::hoverEnterEvent(event);
} }
@ -498,15 +462,9 @@ void PushButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
return; return;
} }
d->hoverAnimation->setProperty("duration", 150);
d->background->setElementPrefix("active"); d->background->setElementPrefix("active");
d->hoverAnimation->setProperty("startPixmap", d->background->framePixmap());
d->background->setElementPrefix("normal"); d->background->setElementPrefix("normal");
d->hoverAnimation->setProperty("targetPixmap", d->background->framePixmap());
d->hoverAnimation->start();
QGraphicsProxyWidget::hoverLeaveEvent(event); QGraphicsProxyWidget::hoverLeaveEvent(event);
} }

View file

@ -229,7 +229,6 @@ protected:
private: private:
Q_PRIVATE_SLOT(d, void syncBorders()) Q_PRIVATE_SLOT(d, void syncBorders())
Q_PRIVATE_SLOT(d, void setPixmap()) Q_PRIVATE_SLOT(d, void setPixmap())
Q_PRIVATE_SLOT(d, void pressedChanged())
Q_PRIVATE_SLOT(d, void syncToAction()) Q_PRIVATE_SLOT(d, void syncToAction())
Q_PRIVATE_SLOT(d, void clearAction()) Q_PRIVATE_SLOT(d, void clearAction())
Q_PRIVATE_SLOT(d, void setPalette()) Q_PRIVATE_SLOT(d, void setPalette())

View file

@ -30,8 +30,6 @@
#include <QWidget> #include <QWidget>
#include <QTimer> #include <QTimer>
#include <QtCore/qdatetime.h> #include <QtCore/qdatetime.h>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QLabel> #include <QLabel>
@ -49,7 +47,6 @@
#include <plasma/widgets/label.h> #include <plasma/widgets/label.h>
#include <plasma/widgets/textedit.h> #include <plasma/widgets/textedit.h>
#include <plasma/widgets/textbrowser.h> #include <plasma/widgets/textbrowser.h>
#include <plasma/animator.h>
#include <plasma/svg.h> #include <plasma/svg.h>
@ -158,17 +155,6 @@ public:
layout->setRowSpacing(0, 0); layout->setRowSpacing(0, 0);
layout->setRowSpacing(1, 0); layout->setRowSpacing(1, 0);
flickAnimationX = 0;
flickAnimationY = 0;
fixupAnimation.groupX = 0;
fixupAnimation.startX = 0;
fixupAnimation.endX = 0;
fixupAnimation.groupY = 0;
fixupAnimation.startY = 0;
fixupAnimation.endY = 0;
fixupAnimation.snapX = 0;
fixupAnimation.snapY = 0;
directMoveAnimation = 0;
stealEvent = false; stealEvent = false;
hasOvershoot = true; hasOvershoot = true;
@ -340,215 +326,6 @@ public:
return dist; return dist;
} }
void animateMoveTo(const QPointF &pos)
{
qreal duration = 800;
QPointF start = q->scrollPosition();
QSizeF threshold = q->viewportGeometry().size();
QPointF diff = pos - start;
//reduce if it's within the viewport
if (qAbs(diff.x()) < threshold.width() ||
qAbs(diff.y()) < threshold.height())
duration /= 2;
fixupAnimation.groupX->stop();
fixupAnimation.groupY->stop();
fixupAnimation.snapX->stop();
fixupAnimation.snapY->stop();
directMoveAnimation->setStartValue(start);
directMoveAnimation->setEndValue(pos);
directMoveAnimation->setDuration(duration);
directMoveAnimation->start();
}
void flick(QPropertyAnimation *anim,
qreal velocity,
qreal val,
qreal minExtent,
qreal maxExtent,
qreal size)
{
qreal deceleration = 500;
qreal maxDistance = -1;
qreal target = 0;
// -ve velocity means list is moving up
if (velocity > 0) {
if (val < minExtent)
maxDistance = qAbs(minExtent - val + (hasOvershoot?overShootDistance(velocity,size):0));
target = minExtent;
deceleration = -deceleration;
} else {
if (val > maxExtent)
maxDistance = qAbs(maxExtent - val) + (hasOvershoot?overShootDistance(velocity,size):0);
target = maxExtent;
}
if (maxDistance > 0) {
qreal v = velocity;
if (MaxVelocity != -1 && MaxVelocity < qAbs(v)) {
if (v < 0)
v = -MaxVelocity;
else
v = MaxVelocity;
}
qreal duration = qAbs(v / deceleration);
qreal diffY = v * duration + (0.5 * deceleration * duration * duration);
qreal startY = val;
qreal endY = startY + diffY;
if (velocity > 0) {
if (endY > target)
endY = startY + maxDistance;
} else {
if (endY < target)
endY = startY - maxDistance;
}
duration = qAbs((endY-startY)/ (-v/2));
if (hasYProperty) {
startY = -startY;
endY = -endY;
}
#if DEBUG
qDebug()<<"XXX velocity = "<<v <<", target = "<< target
<<", maxDist = "<<maxDistance;
qDebug()<<"duration = "<<duration<<" secs, ("
<< (duration * 1000) <<" msecs)";
qDebug()<<"startY = "<<startY;
qDebug()<<"endY = "<<endY;
qDebug()<<"overshoot = "<<overShootDistance(v, size);
qDebug()<<"avg velocity = "<< ((endY-startY)/duration);
#endif
anim->setStartValue(startY);
anim->setEndValue(endY);
anim->setDuration(duration * 1000);
anim->start();
} else {
if (anim == flickAnimationX)
fixupX();
else
fixupY();
}
}
void flickX(qreal velocity)
{
flick(flickAnimationX, velocity, widgetX(), minXExtent(), maxXExtent(),
q->viewportGeometry().width());
}
void flickY(qreal velocity)
{
flick(flickAnimationY, velocity, widgetY(),minYExtent(), maxYExtent(),
q->viewportGeometry().height());
}
void fixup(QAnimationGroup *group,
QPropertyAnimation *start, QPropertyAnimation *end,
qreal val, qreal minExtent, qreal maxExtent)
{
if (val > minExtent || maxExtent > minExtent) {
if (!qFuzzyCompare(val, minExtent)) {
if (FixupDuration) {
//TODO: we should consider the case where there is one axis available not the other
if (hasXProperty && hasYProperty) {
val = -val;
minExtent = -minExtent;
}
qreal dist = minExtent - val;
start->setStartValue(val);
start->setEndValue(minExtent - dist/2);
end->setStartValue(minExtent - dist/2);
end->setEndValue(minExtent);
start->setDuration(FixupDuration/4);
end->setDuration(3*FixupDuration/4);
group->start();
} else {
QObject *obj = start->targetObject();
obj->setProperty(start->propertyName(), minExtent);
}
}
} else if (val < maxExtent) {
if (FixupDuration) {
if (hasXProperty && hasYProperty) {
val = -val;
maxExtent = -maxExtent;
}
qreal dist = maxExtent - val;
start->setStartValue(val);
start->setEndValue(maxExtent - dist/2);
end->setStartValue(maxExtent - dist/2);
end->setEndValue(maxExtent);
start->setDuration(FixupDuration/4);
end->setDuration(3*FixupDuration/4);
group->start();
} else {
QObject *obj = start->targetObject();
obj->setProperty(start->propertyName(), maxExtent);
}
} else if (end == fixupAnimation.endX && snapSize.width() > 1 &&
q->contentsSize().width() > q->viewportGeometry().width()) {
int target = snapSize.width() * round(val/snapSize.width());
fixupAnimation.snapX->setStartValue(val);
fixupAnimation.snapX->setEndValue(target);
fixupAnimation.snapX->setDuration(FixupDuration);
fixupAnimation.snapX->start();
} else if (end == fixupAnimation.endY && snapSize.height() > 1 &&
q->contentsSize().height() > q->viewportGeometry().height()) {
int target = snapSize.height() * round(val/snapSize.height());
fixupAnimation.snapY->setStartValue(val);
fixupAnimation.snapY->setEndValue(target);
fixupAnimation.snapY->setDuration(FixupDuration);
fixupAnimation.snapY->start();
}
}
void fixupX()
{
fixup(fixupAnimation.groupX, fixupAnimation.startX, fixupAnimation.endX,
widgetX(), minXExtent(), maxXExtent());
}
void fixupY()
{
fixup(fixupAnimation.groupY, fixupAnimation.startY, fixupAnimation.endY,
widgetY(), minYExtent(), maxYExtent());
}
void makeRectVisible()
{
if (!widget) {
return;
}
QRectF viewRect = scrollingWidget->boundingRect();
//ensure the rect is not outside the widget bounding rect
QRectF mappedRect = QRectF(QPointF(qBound((qreal)0.0, rectToBeVisible.x(), widget.data()->size().width() - rectToBeVisible.width()),
qBound((qreal)0.0, rectToBeVisible.y(), widget.data()->size().height() - rectToBeVisible.height())),
rectToBeVisible.size());
mappedRect = widget.data()->mapToItem(scrollingWidget, mappedRect).boundingRect();
if (viewRect.contains(mappedRect)) {
return;
}
QPointF delta(0, 0);
if (mappedRect.top() < 0) {
delta.setY(-mappedRect.top());
} else if (mappedRect.bottom() > viewRect.bottom()) {
delta.setY(viewRect.bottom() - mappedRect.bottom());
}
if (mappedRect.left() < 0) {
delta.setX(-mappedRect.left());
} else if (mappedRect.right() > viewRect.right()) {
delta.setX(viewRect.right() - mappedRect.right());
}
animateMoveTo(q->scrollPosition() - delta);
}
void makeItemVisible(QGraphicsItem *itemToBeVisible) void makeItemVisible(QGraphicsItem *itemToBeVisible)
{ {
if (!widget) { if (!widget) {
@ -557,8 +334,6 @@ public:
QRectF rect(widget.data()->mapFromScene(itemToBeVisible->scenePos()), itemToBeVisible->boundingRect().size()); QRectF rect(widget.data()->mapFromScene(itemToBeVisible->scenePos()), itemToBeVisible->boundingRect().size());
rectToBeVisible = rect; rectToBeVisible = rect;
makeRectVisible();
} }
void makeItemVisible() void makeItemVisible()
@ -568,14 +343,6 @@ public:
} }
} }
void stopAnimations()
{
flickAnimationX->stop();
flickAnimationY->stop();
fixupAnimation.groupX->stop();
fixupAnimation.groupY->stop();
}
void setWidgetX(qreal x) void setWidgetX(qreal x)
{ {
if (hasXProperty) { if (hasXProperty) {
@ -642,15 +409,6 @@ public:
event->ignore(); event->ignore();
return; return;
} }
fixupAnimation.groupX->stop();
fixupAnimation.groupY->stop();
fixupAnimation.snapX->stop();
fixupAnimation.snapY->stop();
directMoveAnimation->setStartValue(start);
directMoveAnimation->setEndValue(end);
directMoveAnimation->setDuration(200);
directMoveAnimation->start();
} }
void handleMousePressEvent(QGraphicsSceneMouseEvent *event) void handleMousePressEvent(QGraphicsSceneMouseEvent *event)
@ -661,7 +419,6 @@ public:
pressScrollPos = -q->scrollPosition(); pressScrollPos = -q->scrollPosition();
pressTime = QTime::currentTime(); pressTime = QTime::currentTime();
velocity = QPointF(); velocity = QPointF();
stopAnimations();
} }
void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event) void handleMouseMoveEvent(QGraphicsSceneMouseEvent *event)
@ -756,42 +513,6 @@ public:
lastPos = event->scenePos(); lastPos = event->scenePos();
} }
void handleMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
stealEvent = false;
if (lastPosTime.isNull())
return;
if (elapsed(lastPosTime) > 100) {
// if we drag then pause before release we should not cause a flick.
velocity = QPointF();
}
if (qAbs(velocity.y()) > 10 &&
qAbs(event->scenePos().y() - pressPos.y()) > FlickThreshold) {
qreal vVelocity = velocity.y();
// Minimum velocity to avoid annoyingly slow flicks.
if (qAbs(vVelocity) < MinimumFlickVelocity)
vVelocity = vVelocity < 0 ? -MinimumFlickVelocity : MinimumFlickVelocity;
flickY(vVelocity);
} else {
fixupY();
}
if (qAbs(velocity.x()) > 10 &&
qAbs(event->scenePos().x() - pressPos.x()) > FlickThreshold) {
qreal hVelocity = velocity.x();
// Minimum velocity to avoid annoyingly slow flicks.
if (qAbs(hVelocity) < MinimumFlickVelocity)
hVelocity = hVelocity < 0 ? -MinimumFlickVelocity : MinimumFlickVelocity;
flickX(hVelocity);
} else {
fixupX();
}
lastPosTime = QTime();
}
void handleWheelEvent(QGraphicsSceneWheelEvent *event) void handleWheelEvent(QGraphicsSceneWheelEvent *event)
{ {
//only scroll when the animation is done, this avoids to receive too many events and getting mad when they arrive from a touchpad //only scroll when the animation is done, this avoids to receive too many events and getting mad when they arrive from a touchpad
@ -832,14 +553,6 @@ public:
} }
} }
fixupAnimation.groupX->stop();
fixupAnimation.groupY->stop();
fixupAnimation.snapX->stop();
fixupAnimation.snapY->stop();
directMoveAnimation->setStartValue(start);
directMoveAnimation->setEndValue(end);
directMoveAnimation->setDuration(200);
directMoveAnimation->start();
wheelTimer->start(50); wheelTimer->start(50);
} }
@ -920,114 +633,6 @@ public:
return n; return n;
} }
void createFlickAnimations()
{
if (widget.data()) {
QString xProp = QString::fromLatin1("x");
QString yProp = QString::fromLatin1("y");
if (hasXProperty)
xProp = QString::fromLatin1("scrollPositionX");
if (hasYProperty)
yProp = QString::fromLatin1("scrollPositionY");
flickAnimationX = new QPropertyAnimation(widget.data(),
xProp.toLatin1(), widget.data());
flickAnimationY = new QPropertyAnimation(widget.data(),
yProp.toLatin1(), widget.data());
QObject::connect(flickAnimationX, SIGNAL(finished()),
q, SLOT(fixupX()));
QObject::connect(flickAnimationY, SIGNAL(finished()),
q, SLOT(fixupY()));
QObject::connect(flickAnimationX,
SIGNAL(stateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)),
q, SIGNAL(scrollStateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)));
QObject::connect(flickAnimationY,
SIGNAL(stateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)),
q, SIGNAL(scrollStateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)));
flickAnimationX->setEasingCurve(QEasingCurve::OutCirc);
flickAnimationY->setEasingCurve(QEasingCurve::OutCirc);
fixupAnimation.groupX = new QSequentialAnimationGroup(widget.data());
fixupAnimation.groupY = new QSequentialAnimationGroup(widget.data());
fixupAnimation.startX = new QPropertyAnimation(widget.data(),
xProp.toLatin1(), widget.data());
fixupAnimation.startY = new QPropertyAnimation(widget.data(),
yProp.toLatin1(), widget.data());
fixupAnimation.endX = new QPropertyAnimation(widget.data(),
xProp.toLatin1(), widget.data());
fixupAnimation.endY = new QPropertyAnimation(widget.data(),
yProp.toLatin1(), widget.data());
fixupAnimation.groupX->addAnimation(
fixupAnimation.startX);
fixupAnimation.groupY->addAnimation(
fixupAnimation.startY);
fixupAnimation.groupX->addAnimation(
fixupAnimation.endX);
fixupAnimation.groupY->addAnimation(
fixupAnimation.endY);
fixupAnimation.startX->setEasingCurve(QEasingCurve::InQuad);
fixupAnimation.endX->setEasingCurve(QEasingCurve::OutQuint);
fixupAnimation.startY->setEasingCurve(QEasingCurve::InQuad);
fixupAnimation.endY->setEasingCurve(QEasingCurve::OutQuint);
fixupAnimation.snapX = new QPropertyAnimation(widget.data(),
xProp.toLatin1(), widget.data());
fixupAnimation.snapY = new QPropertyAnimation(widget.data(),
yProp.toLatin1(), widget.data());
fixupAnimation.snapX->setEasingCurve(QEasingCurve::InOutQuad);
fixupAnimation.snapY->setEasingCurve(QEasingCurve::InOutQuad);
QObject::connect(fixupAnimation.groupX,
SIGNAL(stateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)),
q, SIGNAL(scrollStateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)));
QObject::connect(fixupAnimation.groupY,
SIGNAL(stateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)),
q, SIGNAL(scrollStateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)));
directMoveAnimation = new QPropertyAnimation(q,
"scrollPosition",
q);
QObject::connect(directMoveAnimation, SIGNAL(finished()),
q, SLOT(fixupX()));
QObject::connect(directMoveAnimation, SIGNAL(finished()),
q, SLOT(fixupY()));
QObject::connect(directMoveAnimation,
SIGNAL(stateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)),
q, SIGNAL(scrollStateChanged(QAbstractAnimation::State,
QAbstractAnimation::State)));
directMoveAnimation->setEasingCurve(QEasingCurve::OutCirc);
}
}
void deleteFlickAnimations()
{
if (flickAnimationX)
flickAnimationX->stop();
if (flickAnimationY)
flickAnimationY->stop();
delete flickAnimationX;
delete flickAnimationY;
delete fixupAnimation.groupX;
delete fixupAnimation.groupY;
delete directMoveAnimation;
delete fixupAnimation.snapX;
delete fixupAnimation.snapY;
}
void setScrollX() void setScrollX()
{ {
if (horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff) { if (horizontalScrollBarPolicy != Qt::ScrollBarAlwaysOff) {
@ -1073,21 +678,6 @@ public:
QPointF lastPos; QPointF lastPos;
QTime pressTime; QTime pressTime;
QTime lastPosTime; QTime lastPosTime;
QPropertyAnimation *flickAnimationX;
QPropertyAnimation *flickAnimationY;
struct {
QAnimationGroup *groupX;
QPropertyAnimation *startX;
QPropertyAnimation *endX;
QAnimationGroup *groupY;
QPropertyAnimation *startY;
QPropertyAnimation *endY;
QPropertyAnimation *snapX;
QPropertyAnimation *snapY;
} fixupAnimation;
QPropertyAnimation *directMoveAnimation;
QSizeF snapSize; QSizeF snapSize;
bool stealEvent; bool stealEvent;
bool hasOvershoot; bool hasOvershoot;
@ -1126,7 +716,6 @@ ScrollWidget::~ScrollWidget()
void ScrollWidget::setWidget(QGraphicsWidget *widget) void ScrollWidget::setWidget(QGraphicsWidget *widget)
{ {
if (d->widget && d->widget.data() != widget) { if (d->widget && d->widget.data() != widget) {
d->deleteFlickAnimations();
d->widget.data()->removeEventFilter(this); d->widget.data()->removeEventFilter(this);
delete d->widget.data(); delete d->widget.data();
} }
@ -1138,7 +727,6 @@ void ScrollWidget::setWidget(QGraphicsWidget *widget)
d->hasOffsetProperty = widget->property("scrollPosition").isValid(); d->hasOffsetProperty = widget->property("scrollPosition").isValid();
d->hasXProperty = widget->property("scrollPositionX").isValid(); d->hasXProperty = widget->property("scrollPositionX").isValid();
d->hasYProperty = widget->property("scrollPositionY").isValid(); d->hasYProperty = widget->property("scrollPositionY").isValid();
d->createFlickAnimations();
connect(widget, SIGNAL(xChanged()), this, SLOT(setScrollX())); connect(widget, SIGNAL(xChanged()), this, SLOT(setScrollX()));
connect(widget, SIGNAL(yChanged()), this, SLOT(setScrollY())); connect(widget, SIGNAL(yChanged()), this, SLOT(setScrollY()));
@ -1200,7 +788,6 @@ void ScrollWidget::ensureRectVisible(const QRectF &rect)
} }
d->rectToBeVisible = rect; d->rectToBeVisible = rect;
d->makeRectVisible();
} }
void ScrollWidget::ensureItemVisible(QGraphicsItem *item) void ScrollWidget::ensureItemVisible(QGraphicsItem *item)
@ -1379,7 +966,6 @@ void ScrollWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
d->handleMouseReleaseEvent(event);
event->accept(); event->accept();
} }
@ -1405,7 +991,6 @@ bool ScrollWidget::eventFilter(QObject *watched, QEvent *event)
event->type() == QEvent::Move)) { event->type() == QEvent::Move)) {
emit viewportGeometryChanged(viewportGeometry()); emit viewportGeometryChanged(viewportGeometry());
} else if (watched == d->widget.data() && event->type() == QEvent::GraphicsSceneResize) { } else if (watched == d->widget.data() && event->type() == QEvent::GraphicsSceneResize) {
d->stopAnimations();
d->adjustScrollbarsTimer->start(200); d->adjustScrollbarsTimer->start(200);
updateGeometry(); updateGeometry();
@ -1499,9 +1084,6 @@ bool ScrollWidget::sceneEventFilter(QGraphicsItem *i, QEvent *e)
case QEvent::GraphicsSceneMouseMove: case QEvent::GraphicsSceneMouseMove:
d->handleMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(e)); d->handleMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(e));
break; break;
case QEvent::GraphicsSceneMouseRelease:
d->handleMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent*>(e));
break;
//Multitouch related events, we actually need only TouchUpdate //Multitouch related events, we actually need only TouchUpdate
case QEvent::TouchUpdate: { case QEvent::TouchUpdate: {

View file

@ -282,11 +282,8 @@ private:
Q_PRIVATE_SLOT(d, void verticalScroll(int value)) Q_PRIVATE_SLOT(d, void verticalScroll(int value))
Q_PRIVATE_SLOT(d, void horizontalScroll(int value)) Q_PRIVATE_SLOT(d, void horizontalScroll(int value))
Q_PRIVATE_SLOT(d, void makeRectVisible())
Q_PRIVATE_SLOT(d, void makeItemVisible()) Q_PRIVATE_SLOT(d, void makeItemVisible())
Q_PRIVATE_SLOT(d, void adjustScrollbars()) Q_PRIVATE_SLOT(d, void adjustScrollbars())
Q_PRIVATE_SLOT(d, void fixupX())
Q_PRIVATE_SLOT(d, void fixupY())
Q_PRIVATE_SLOT(d, void setScrollX()) Q_PRIVATE_SLOT(d, void setScrollX())
Q_PRIVATE_SLOT(d, void setScrollY()) Q_PRIVATE_SLOT(d, void setScrollY())

View file

@ -33,8 +33,6 @@
#include <kdebug.h> #include <kdebug.h>
#include "animator.h"
#include "animations/animation.h"
#include "private/nativetabbar_p.h" #include "private/nativetabbar_p.h"
#include "private/themedwidgetinterface_p.h" #include "private/themedwidgetinterface_p.h"
#include "theme.h" #include "theme.h"
@ -76,8 +74,6 @@ public:
tabProxy(0), tabProxy(0),
currentIndex(0), currentIndex(0),
tabWidgetMode(true), tabWidgetMode(true),
oldPageAnimId(-1),
newPageAnimId(-1),
tabBarShown(true) tabBarShown(true)
{ {
} }
@ -103,10 +99,6 @@ public:
QWeakPointer<QGraphicsWidget> oldPage; QWeakPointer<QGraphicsWidget> oldPage;
QWeakPointer<QGraphicsWidget> newPage; QWeakPointer<QGraphicsWidget> newPage;
int oldPageAnimId;
int newPageAnimId;
Animation *oldPageAnim;
Animation *newPageAnim;
QParallelAnimationGroup *animGroup; QParallelAnimationGroup *animGroup;
bool tabBarShown; bool tabBarShown;
QWeakPointer<QGraphicsWidget> firstPositionWidget; QWeakPointer<QGraphicsWidget> firstPositionWidget;
@ -162,7 +154,6 @@ void TabBarPrivate::slidingNewPageCompleted()
if (newPage) { if (newPage) {
tabWidgetLayout->addItem(newPage.data()); tabWidgetLayout->addItem(newPage.data());
} }
newPageAnimId = -1;
mainLayout->invalidate(); mainLayout->invalidate();
emit q->currentChanged(currentIndex); emit q->currentChanged(currentIndex);
@ -171,9 +162,8 @@ void TabBarPrivate::slidingNewPageCompleted()
void TabBarPrivate::slidingOldPageCompleted() void TabBarPrivate::slidingOldPageCompleted()
{ {
QGraphicsWidget *item = oldPageAnim->targetWidget(); QGraphicsWidget *item = oldPage.data();
oldPageAnimId = -1;
if (item) { if (item) {
item->hide(); item->hide();
} }
@ -249,20 +239,10 @@ TabBar::TabBar(QGraphicsWidget *parent)
d->tabBarLayout->setContentsMargins(0,0,0,0); d->tabBarLayout->setContentsMargins(0,0,0,0);
//d->tabBarLayout->setStretchFactor(d->tabProxy, 2); //d->tabBarLayout->setStretchFactor(d->tabProxy, 2);
d->newPageAnim = Animator::create(Animator::SlideAnimation);
d->oldPageAnim = Animator::create(Animator::SlideAnimation);
d->animGroup = new QParallelAnimationGroup(this);
d->animGroup->addAnimation(d->newPageAnim);
d->animGroup->addAnimation(d->oldPageAnim);
connect(d->tabProxy->native, SIGNAL(currentChanged(int)), connect(d->tabProxy->native, SIGNAL(currentChanged(int)),
this, SLOT(setCurrentIndex(int))); this, SLOT(setCurrentIndex(int)));
connect(d->tabProxy->native, SIGNAL(shapeChanged(QTabBar::Shape)), connect(d->tabProxy->native, SIGNAL(shapeChanged(QTabBar::Shape)),
this, SLOT(shapeChanged(QTabBar::Shape))); this, SLOT(shapeChanged(QTabBar::Shape)));
connect(d->newPageAnim, SIGNAL(finished()), this, SLOT(slidingNewPageCompleted()));
connect(d->oldPageAnim, SIGNAL(finished()), this, SLOT(slidingOldPageCompleted()));
d->initTheming(); d->initTheming();
} }
@ -396,27 +376,11 @@ void TabBar::setCurrentIndex(int index)
if (index > d->currentIndex) { if (index > d->currentIndex) {
d->newPage.data()->setPos(d->oldPage.data()->geometry().topRight()); d->newPage.data()->setPos(d->oldPage.data()->geometry().topRight());
d->newPageAnim->setProperty("movementDirection", Animation::MoveLeft); d->slidingNewPageCompleted();
d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0)); d->slidingOldPageCompleted();
d->newPageAnim->setTargetWidget(d->newPage.data());
d->oldPageAnim->setProperty("movementDirection", Animation::MoveLeft);
d->oldPageAnim->setProperty("distancePointF", QPointF(beforeCurrentGeom.width(), 0));
d->oldPageAnim->setTargetWidget(d->oldPage.data());
d->animGroup->start();
} else { } else {
d->newPage.data()->setPos(beforeCurrentGeom.topLeft()); d->newPage.data()->setPos(beforeCurrentGeom.topLeft());
d->newPageAnim->setProperty("movementDirection", Animation::MoveRight); d->slidingOldPageCompleted();
d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0));
d->newPageAnim->setTargetWidget(d->newPage.data());
d->oldPageAnim->setProperty("movementDirection", Animation::MoveRight);
d->oldPageAnim->setProperty("distancePointF",
QPointF(d->oldPage.data()->size().width(), 0));
d->oldPageAnim->setTargetWidget(d->oldPage.data());
d->animGroup->start();
} }
} else if (d->newPage) { } else if (d->newPage) {
d->tabWidgetLayout->addItem(d->newPage.data()); d->tabWidgetLayout->addItem(d->newPage.data());
@ -437,9 +401,6 @@ void TabBar::removeTab(int index)
return; return;
} }
d->newPageAnim->stop();
d->oldPageAnim->stop();
int oldCurrentIndex = d->tabProxy->native->currentIndex(); int oldCurrentIndex = d->tabProxy->native->currentIndex();
d->tabProxy->native->removeTab(index); d->tabProxy->native->removeTab(index);

View file

@ -278,8 +278,8 @@ private:
friend class TabBarPrivate; friend class TabBarPrivate;
Q_PRIVATE_SLOT(d, void slidingNewPageCompleted()) void slidingNewPageCompleted();
Q_PRIVATE_SLOT(d, void slidingOldPageCompleted()) void slidingOldPageCompleted();
Q_PRIVATE_SLOT(d, void shapeChanged(const QTabBar::Shape shape)) Q_PRIVATE_SLOT(d, void shapeChanged(const QTabBar::Shape shape))
Q_PRIVATE_SLOT(d, void setPalette()) Q_PRIVATE_SLOT(d, void setPalette())
}; };

View file

@ -30,7 +30,6 @@
#include <kiconeffect.h> #include <kiconeffect.h>
#include <kmimetype.h> #include <kmimetype.h>
#include "animator.h"
#include "framesvg.h" #include "framesvg.h"
#include "paintutils.h" #include "paintutils.h"
#include "private/actionwidgetinterface_p.h" #include "private/actionwidgetinterface_p.h"

View file

@ -40,7 +40,6 @@
#include <phonon/mediasource.h> #include <phonon/mediasource.h>
#include <phonon/audiooutput.h> #include <phonon/audiooutput.h>
#include <plasma/animations/animation.h>
#include <plasma/widgets/iconwidget.h> #include <plasma/widgets/iconwidget.h>
#include <plasma/widgets/slider.h> #include <plasma/widgets/slider.h>
#include <plasma/widgets/frame.h> #include <plasma/widgets/frame.h>
@ -55,7 +54,6 @@ public:
: q(video), : q(video),
ticking(false), ticking(false),
forceControlsVisible(false), forceControlsVisible(false),
animation(0),
hideTimer(0), hideTimer(0),
shownControls(VideoWidget::NoControls), shownControls(VideoWidget::NoControls),
controlsWidget(0), controlsWidget(0),
@ -100,7 +98,6 @@ public:
bool forceControlsVisible; bool forceControlsVisible;
//control widgets //control widgets
Plasma::Animation *animation;
QTimer *hideTimer; QTimer *hideTimer;
VideoWidget::Controls shownControls; VideoWidget::Controls shownControls;
Plasma::Frame *controlsWidget; Plasma::Frame *controlsWidget;
@ -198,17 +195,6 @@ void VideoWidgetPrivate::animateControlWidget(bool show)
//clip only when animating //clip only when animating
q->setFlags(q->flags()|QGraphicsItem::ItemClipsChildrenToShape); q->setFlags(q->flags()|QGraphicsItem::ItemClipsChildrenToShape);
if (!animation) {
animation = Plasma::Animator::create(Plasma::Animator::SlideAnimation, q);
animation->setTargetWidget(controlsWidget);
animation->setProperty("movementDirection", Animation::MoveDown);
q->connect(animation, SIGNAL(finished()), q, SLOT(slidingCompleted()));
}
animation->setProperty("distance", distance);
animation->setProperty("direction", show? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
animation->start();
} }
void VideoWidgetPrivate::hideControlWidget() void VideoWidgetPrivate::hideControlWidget()

View file

@ -34,7 +34,6 @@
#endif #endif
#include <kdebug.h> #include <kdebug.h>
#include "animator.h"
#include "plasma.h" #include "plasma.h"
#include "widgets/webview.h" #include "widgets/webview.h"
#include "widgets/scrollwidget.h" #include "widgets/scrollwidget.h"