History

Allow multiple scripts to register, and allow them to specify the specific anim vars they are interested in.

Howard Stearns committed 11 years ago

Commit 4b4907c1 parent 900b07f6 files · +77 −39Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+7−4
@@ -262,7 +262,8 @@ void ScriptEngine::errorInLoadingScript(const QUrl& url) { · 261 unmodified lines
262// callAnimationStateHandler requires that the type be registered.262// callAnimationStateHandler requires that the type be registered.
263// These two are meaningful, if we ever do want to use them...263// These two are meaningful, if we ever do want to use them...
264static QScriptValue animVarMapToScriptValue(QScriptEngine* engine, const AnimVariantMap& parameters) {264static QScriptValue animVarMapToScriptValue(QScriptEngine* engine, const AnimVariantMap& parameters) {
265 return parameters.animVariantMapToScriptValue(engine);265 QStringList unused;
266 return parameters.animVariantMapToScriptValue(engine, unused, false);
266}267}
267static void animVarMapFromScriptValue(const QScriptValue& value, AnimVariantMap& parameters) {268static void animVarMapFromScriptValue(const QScriptValue& value, AnimVariantMap& parameters) {
268 parameters.animVariantMapFromScriptValue(value);269 parameters.animVariantMapFromScriptValue(value);
@@ -741,7 +742,7 @@ void ScriptEngine::stop() { · 472 unmodified lines
741}742}
742 743
743// Other threads can invoke this through invokeMethod, which causes the callback to be asynchronously executed in this script's thread.744// Other threads can invoke this through invokeMethod, which causes the callback to be asynchronously executed in this script's thread.
744void ScriptEngine::callAnimationStateHandler(QScriptValue callback, AnimVariantMap parameters, AnimVariantResultHandler resultHandler) {745void ScriptEngine::callAnimationStateHandler(QScriptValue callback, AnimVariantMap parameters, QStringList names, bool useNames, AnimVariantResultHandler resultHandler) {
745 if (QThread::currentThread() != thread()) {746 if (QThread::currentThread() != thread()) {
746#ifdef THREAD_DEBUGGING747#ifdef THREAD_DEBUGGING
747 qDebug() << "*** WARNING *** ScriptEngine::callAnimationStateHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;748 qDebug() << "*** WARNING *** ScriptEngine::callAnimationStateHandler() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] name:" << name;
@@ -749,14 +750,16 @@ void ScriptEngine::callAnimationStateHandler(QScriptValue callback, AnimVariantM · 1 unmodified line
749 QMetaObject::invokeMethod(this, "callAnimationStateHandler",750 QMetaObject::invokeMethod(this, "callAnimationStateHandler",
750 Q_ARG(QScriptValue, callback),751 Q_ARG(QScriptValue, callback),
751 Q_ARG(AnimVariantMap, parameters),752 Q_ARG(AnimVariantMap, parameters),
753 Q_ARG(QStringList, names),
754 Q_ARG(bool, useNames),
752 Q_ARG(AnimVariantResultHandler, resultHandler));755 Q_ARG(AnimVariantResultHandler, resultHandler));
753 return;756 return;
754 }757 }
755 QScriptValue javascriptParametgers = parameters.animVariantMapToScriptValue(this);758 QScriptValue javascriptParametgers = parameters.animVariantMapToScriptValue(this, names, useNames);
756 QScriptValueList callingArguments;759 QScriptValueList callingArguments;
757 callingArguments << javascriptParametgers;760 callingArguments << javascriptParametgers;
758 QScriptValue result = callback.call(QScriptValue(), callingArguments);761 QScriptValue result = callback.call(QScriptValue(), callingArguments);
759 resultHandler(callback, result);762 resultHandler(result);
760}763}
761 764
762void ScriptEngine::timerFired() {765void ScriptEngine::timerFired() {