diff --git a/doric-Qt/doric/DoricContext.cpp b/doric-Qt/doric/DoricContext.cpp index 6cdd398a..56872f30 100644 --- a/doric-Qt/doric/DoricContext.cpp +++ b/doric-Qt/doric/DoricContext.cpp @@ -66,8 +66,7 @@ QObject *DoricContext::obtainPlugin(QString name) { if (mPluginMap.keys().contains(name)) { return mPluginMap.value(name); } else { - QObject *plugin = - getDriver()->getRegistry()->pluginInfoMap.createObject(name); + QObject *plugin = getDriver()->getRegistry()->plugins.createObject(name); dynamic_cast(plugin)->setContext(this); mPluginMap.insert(name, plugin); return plugin; diff --git a/doric-Qt/doric/DoricRegistry.cpp b/doric-Qt/doric/DoricRegistry.cpp index 17751f89..399d8519 100644 --- a/doric-Qt/doric/DoricRegistry.cpp +++ b/doric-Qt/doric/DoricRegistry.cpp @@ -7,5 +7,5 @@ DoricRegistry::DoricRegistry() { } bool DoricRegistry::acquirePluginInfo(QString name) { - return pluginInfoMap.acquireClass(name); + return plugins.acquireClass(name); } diff --git a/doric-Qt/doric/DoricRegistry.h b/doric-Qt/doric/DoricRegistry.h index 0d867735..60af22c0 100644 --- a/doric-Qt/doric/DoricRegistry.h +++ b/doric-Qt/doric/DoricRegistry.h @@ -7,12 +7,17 @@ class DoricRegistry { public: - DoricObjectFactory pluginInfoMap; + DoricObjectFactory plugins; + DoricObjectFactory nodes; DoricRegistry(); template void registerNativePlugin(QString name) { - pluginInfoMap.registerClass(name); + plugins.registerClass(name); + } + + template void registerViewNode(QString name) { + nodes.registerClass(name); } bool acquirePluginInfo(QString name); diff --git a/doric-Qt/doric/doric.pro.user b/doric-Qt/doric/doric.pro.user index 8749d384..6984e5ec 100644 --- a/doric-Qt/doric/doric.pro.user +++ b/doric-Qt/doric/doric.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/doric-Qt/doric/engine/DoricBridgeExtension.cpp b/doric-Qt/doric/engine/DoricBridgeExtension.cpp index 7c339d9e..3dd5f5e4 100644 --- a/doric-Qt/doric/engine/DoricBridgeExtension.cpp +++ b/doric-Qt/doric/engine/DoricBridgeExtension.cpp @@ -20,9 +20,7 @@ void DoricBridgeExtension::callNative(QString contextId, QString module, Q_ARG(QJSValue, jsValue), Q_ARG(QString, callbackId)); } - qDebug() << "contextId: " + contextId; - qDebug() << "module: " + module; - qDebug() << "methodName: " + methodName; - qDebug() << "callbackId: " + callbackId; - qDebug() << "jsValue: " + jsValue.toString(); + qDebug() << "contextId: " + contextId << "module: " + module + << "methodName: " + methodName << "callbackId: " + callbackId + << "jsValue: " + jsValue.toString(); } diff --git a/doric-Qt/doric/plugin/DoricShaderPlugin.cpp b/doric-Qt/doric/plugin/DoricShaderPlugin.cpp index e30934ab..a9ec1796 100644 --- a/doric-Qt/doric/plugin/DoricShaderPlugin.cpp +++ b/doric-Qt/doric/plugin/DoricShaderPlugin.cpp @@ -4,7 +4,6 @@ #include "DoricShaderPlugin.h" void DoricShaderPlugin::render(QJSValue jsValue, QString callbackId) { - qDebug() << getContext(); getContext()->getDriver()->asyncCall( [this, jsValue] { QString viewId = jsValue.property("id").toString(); diff --git a/doric-Qt/doric/shader/DoricGroupNode.cpp b/doric-Qt/doric/shader/DoricGroupNode.cpp index 36f22924..e101234e 100644 --- a/doric-Qt/doric/shader/DoricGroupNode.cpp +++ b/doric-Qt/doric/shader/DoricGroupNode.cpp @@ -4,9 +4,16 @@ void DoricGroupNode::blend(QQuickItem *view, QString name, QJSValue prop) { if (name == "children") { mChildViewIds.clear(); if (prop.isArray()) { - qDebug() << prop.toString(); + const int length = prop.property("length").toInt(); + for (int i = 0; i < length; ++i) { + QJSValue value = prop.property(i); + if (value.isString()) { + mChildViewIds.append(value.toString()); + } + } } } else { + qCritical() << "group node blend"; DoricSuperNode::blend(view, name, prop); } } @@ -16,4 +23,35 @@ void DoricGroupNode::blend(QJSValue jsValue) { configChildNode(); } -void DoricGroupNode::configChildNode() {} +void DoricGroupNode::configChildNode() { + for (int idx = 0; idx < mChildViewIds.size(); idx++) { + QString id = mChildViewIds.at(idx); + QJSValue model = getSubModel(id); + if (model.isUndefined()) { +// getContext()->getDriver()->getRegistry(); + continue; + } + QString type = model.property("type").toString(); + if (idx < mChildNodes.size()) { + DoricViewNode *oldNode = mChildNodes.at(idx); + if (id == oldNode->getId()) { + // The same, skip + if (mReusable) { + } else { + } + } + } else { + // Insert + } + } +} + +void DoricGroupNode::blendSubNode(QJSValue subProperties) { + QString subNodeId = subProperties.property("id").toString(); + for (DoricViewNode *node : mChildNodes) { + if (subNodeId == node->getId()) { + node->blend(subProperties.property("props")); + break; + } + } +} diff --git a/doric-Qt/doric/shader/DoricGroupNode.h b/doric-Qt/doric/shader/DoricGroupNode.h index 6b125435..0e4d6315 100644 --- a/doric-Qt/doric/shader/DoricGroupNode.h +++ b/doric-Qt/doric/shader/DoricGroupNode.h @@ -17,6 +17,8 @@ protected: QList mChildViewIds; void configChildNode(); + + virtual void blendSubNode(QJSValue subProperties) override; }; #endif // DORICGROUPNODE_H diff --git a/doric-Qt/doric/shader/DoricSuperNode.cpp b/doric-Qt/doric/shader/DoricSuperNode.cpp index 1d1f3fb4..6a8ab0bd 100644 --- a/doric-Qt/doric/shader/DoricSuperNode.cpp +++ b/doric-Qt/doric/shader/DoricSuperNode.cpp @@ -1,11 +1,53 @@ +#include + #include "DoricSuperNode.h" void DoricSuperNode::blend(QQuickItem *view, QString name, QJSValue prop) { if (name == "subviews") { if (prop.isArray()) { - qDebug() << prop.toString(); + const int length = prop.property("length").toInt(); + for (int i = 0; i < length; ++i) { + QJSValue subNode = prop.property(i); + mixinSubNode(subNode); + blendSubNode(subNode); + } } } else { + qCritical() << "super node blend"; DoricViewNode::blend(view, name, prop); } } + +void DoricSuperNode::mixinSubNode(QJSValue subNode) { + QString id = subNode.property("id").toString(); + qCritical() << id; + QList keys = subNodes.keys(); + if (keys.contains(id)) { + subNodes.insert(id, subNode); + } else { + mixin(subNode, subNodes.value(id)); + } +} + +void DoricSuperNode::mixin(QJSValue src, QJSValue target) { + QJSValue srcProps = src.property("props"); + QJSValue targetProps = target.property("props"); + QJSValueIterator it(srcProps); + while (it.hasNext()) { + it.next(); + + if (it.name() == "subviews" && it.value().isArray()) { + + } else { + targetProps.setProperty(it.name(), it.value()); + } + } +} + +QJSValue DoricSuperNode::getSubModel(QString id) { + if (subNodes.keys().contains(id)) { + return subNodes.value(id); + } else { + return QJSValue::UndefinedValue; + } +} diff --git a/doric-Qt/doric/shader/DoricSuperNode.h b/doric-Qt/doric/shader/DoricSuperNode.h index e238e8ef..388c61de 100644 --- a/doric-Qt/doric/shader/DoricSuperNode.h +++ b/doric-Qt/doric/shader/DoricSuperNode.h @@ -4,16 +4,27 @@ #include "DoricViewNode.h" class DoricSuperNode : public DoricViewNode { +private: + QMap subNodes; protected: virtual void blend(QQuickItem *view, QString name, QJSValue prop) override; void blendSubLayoutConfig(DoricViewNode *viewNode); + virtual void blendSubNode(QJSValue subProperties) = 0; + public: using DoricViewNode::DoricViewNode; bool mReusable = false; + + QJSValue getSubModel(QString id); + +private: + void mixinSubNode(QJSValue subNode); + + void mixin(QJSValue src, QJSValue target); }; #endif // DORICSUPERNODE_H diff --git a/doric-Qt/doric/shader/DoricViewNode.cpp b/doric-Qt/doric/shader/DoricViewNode.cpp index 87590ee8..d2d2d14e 100644 --- a/doric-Qt/doric/shader/DoricViewNode.cpp +++ b/doric-Qt/doric/shader/DoricViewNode.cpp @@ -23,14 +23,22 @@ void DoricViewNode::setId(QString id) { mId = id; } void DoricViewNode::blend(QJSValue jsValue) { QJSValueIterator it(jsValue); + QMap values; while (it.hasNext()) { it.next(); - qDebug() << it.name() << ": " << it.value().toString(); - blend(mView, it.name(), it.value()); + values.insert(it.name(), it.value()); + } + + auto keys = values.keys(); + for (const QString &key : keys) { + qCritical() << key << ": " << values.value(key).toString(); + qCritical() << mView; + blend(mView, key, values.value(key)); } } void DoricViewNode::blend(QQuickItem *view, QString name, QJSValue prop) { + qCritical() << "view node blend"; if (name == "width") { } else if (name == "height") {