access to easing curves
svn path=/trunk/KDE/kdelibs/; revision=1120770
This commit is contained in:
parent
1834648ded
commit
a06b2bf70d
@ -72,22 +72,23 @@ set(plasma_LIB_SRCS
|
||||
abstracttoolbox.cpp
|
||||
animator.cpp
|
||||
animations/animation.cpp
|
||||
animations/easinganimation.cpp
|
||||
animations/animationscriptengine.cpp
|
||||
animations/pendulumcurve.cpp
|
||||
animations/bindings/animationgroup.cpp
|
||||
animations/easinganimation.cpp
|
||||
animations/fade.cpp
|
||||
animations/grow.cpp
|
||||
animations/javascriptanimation.cpp
|
||||
animations/slide.cpp
|
||||
animations/pendulumcurve.cpp
|
||||
animations/pixmaptransition.cpp
|
||||
animations/pulser.cpp
|
||||
animations/widgetsnapshot.cpp
|
||||
animations/rotation.cpp
|
||||
animations/rotationstacked.cpp
|
||||
animations/slide.cpp
|
||||
animations/stackedlayout.cpp
|
||||
animations/geometry.cpp
|
||||
animations/zoom.cpp
|
||||
animations/water.cpp
|
||||
animations/widgetsnapshot.cpp
|
||||
animations/zoom.cpp
|
||||
applet.cpp
|
||||
configloader.cpp
|
||||
containment.cpp
|
||||
|
@ -26,10 +26,14 @@
|
||||
#include "animationscriptengine_p.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QSequentialAnimationGroup>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#include "bindings/animationgroup_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -72,12 +76,42 @@ QScriptValue registerAnimation(QScriptContext *context, QScriptEngine *engine)
|
||||
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 SequentialAnimationGroup(parent);
|
||||
return engine->newQObject(group);
|
||||
}
|
||||
|
||||
QScriptValue parallelAnimationGroup(QScriptContext *context, QScriptEngine *engine)
|
||||
{
|
||||
QObject *parent = extractParent(context, engine);
|
||||
if (!parent) {
|
||||
return engine->undefinedValue();
|
||||
}
|
||||
|
||||
ParallelAnimationGroup *group = new ParallelAnimationGroup(parent);
|
||||
return engine->newQObject(group);
|
||||
}
|
||||
|
||||
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));
|
||||
qDebug() << "........... first js animation, creating the engine!";
|
||||
}
|
||||
|
||||
|
107
animations/bindings/animationgroup.cpp
Normal file
107
animations/bindings/animationgroup.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright 2009 Aaron J. 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 "animationgroup_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
ParallelAnimationGroup::ParallelAnimationGroup(QObject *parent)
|
||||
: QParallelAnimationGroup(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void ParallelAnimationGroup::addAnimation(QAbstractAnimation *animation)
|
||||
{
|
||||
QParallelAnimationGroup::addAnimation(animation);
|
||||
}
|
||||
|
||||
QAbstractAnimation *ParallelAnimationGroup::animationAt(int index) const
|
||||
{
|
||||
return QParallelAnimationGroup::animationAt(index);
|
||||
}
|
||||
|
||||
int ParallelAnimationGroup::animationCount() const
|
||||
{
|
||||
return QParallelAnimationGroup::animationCount();
|
||||
}
|
||||
|
||||
void ParallelAnimationGroup::clear()
|
||||
{
|
||||
QParallelAnimationGroup::clear();
|
||||
}
|
||||
|
||||
int ParallelAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
|
||||
{
|
||||
return QParallelAnimationGroup::indexOfAnimation(animation);
|
||||
}
|
||||
|
||||
void ParallelAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
|
||||
{
|
||||
QParallelAnimationGroup::insertAnimation(index, animation);
|
||||
}
|
||||
|
||||
void ParallelAnimationGroup::removeAnimation(QAbstractAnimation *animation)
|
||||
{
|
||||
QParallelAnimationGroup::removeAnimation(animation);
|
||||
}
|
||||
|
||||
|
||||
SequentialAnimationGroup::SequentialAnimationGroup(QObject *parent)
|
||||
: QSequentialAnimationGroup(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void SequentialAnimationGroup::addAnimation(QAbstractAnimation *animation)
|
||||
{
|
||||
QSequentialAnimationGroup::addAnimation(animation);
|
||||
}
|
||||
|
||||
QAbstractAnimation *SequentialAnimationGroup::animationAt(int index) const
|
||||
{
|
||||
return QSequentialAnimationGroup::animationAt(index);
|
||||
}
|
||||
|
||||
int SequentialAnimationGroup::animationCount() const
|
||||
{
|
||||
return QSequentialAnimationGroup::animationCount();
|
||||
}
|
||||
|
||||
void SequentialAnimationGroup::clear()
|
||||
{
|
||||
QSequentialAnimationGroup::clear();
|
||||
}
|
||||
|
||||
int SequentialAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
|
||||
{
|
||||
return QSequentialAnimationGroup::indexOfAnimation(animation);
|
||||
}
|
||||
|
||||
void SequentialAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
|
||||
{
|
||||
QSequentialAnimationGroup::insertAnimation(index, animation);
|
||||
}
|
||||
|
||||
void SequentialAnimationGroup::removeAnimation(QAbstractAnimation *animation)
|
||||
{
|
||||
QSequentialAnimationGroup::removeAnimation(animation);
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include "animationgroup_p.moc"
|
65
animations/bindings/animationgroup_p.h
Normal file
65
animations/bindings/animationgroup_p.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2009 Aaron J. 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.
|
||||
*/
|
||||
|
||||
#ifndef JAVASCRIPTANIMATIONBINDINGS_P_H
|
||||
#define JAVASCRIPTANIMATIONBINDINGS_P_H
|
||||
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QSequentialAnimationGroup>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ParallelAnimationGroup : public QParallelAnimationGroup
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ParallelAnimationGroup(QObject *parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
void addAnimation(QAbstractAnimation * animation);
|
||||
QAbstractAnimation *animationAt(int index) const;
|
||||
int animationCount() const;
|
||||
void clear();
|
||||
int indexOfAnimation(QAbstractAnimation *animation) const;
|
||||
void insertAnimation(int index, QAbstractAnimation * animation);
|
||||
void removeAnimation(QAbstractAnimation * animation);
|
||||
};
|
||||
|
||||
class SequentialAnimationGroup : public QSequentialAnimationGroup
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SequentialAnimationGroup(QObject *parent);
|
||||
|
||||
public Q_SLOTS:
|
||||
void addAnimation(QAbstractAnimation * animation);
|
||||
QAbstractAnimation *animationAt(int index) const;
|
||||
int animationCount() const;
|
||||
void clear();
|
||||
int indexOfAnimation(QAbstractAnimation *animation) const;
|
||||
void insertAnimation(int index, QAbstractAnimation * animation);
|
||||
void removeAnimation(QAbstractAnimation * animation);
|
||||
};
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#endif
|
||||
|
@ -51,10 +51,13 @@ void JavascriptAnimation::updateState(QAbstractAnimation::State newState, QAbstr
|
||||
if (oldState == Stopped && newState == Running) {
|
||||
if (!m_method.isFunction()) {
|
||||
//Define the class and create an instance
|
||||
QScriptEngine *engine = AnimationScriptEngine::globalEngine();
|
||||
QScriptValueList args;
|
||||
args << AnimationScriptEngine::globalEngine()->newQObject(targetWidget()) << duration();
|
||||
args << engine->newQObject(targetWidget()) << duration();
|
||||
m_instance = AnimationScriptEngine::animation(m_name).construct(args);
|
||||
kDebug() << "trying for" << m_name << m_instance.isFunction();
|
||||
m_instance.setProperty("__plasma_javascriptanimation", engine->newQObject(this),
|
||||
QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::SkipInEnumeration);
|
||||
|
||||
//Get the method of the object
|
||||
m_method = m_instance.property(QString("updateCurrentTime"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user