From 3531a28f133b2427301d45ce99a960ce9dbd9d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Mon, 10 May 2021 16:09:29 +0800 Subject: [PATCH] add slider, slider node & pure call response --- doric-Qt/example/doric/DoricRegistry.cpp | 4 ++++ doric-Qt/example/doric/doric.pro | 2 ++ doric-Qt/example/doric/shader/DoricViewNode.cpp | 14 ++++++++++++++ doric-Qt/example/doric/shader/DoricViewNode.h | 2 ++ .../doric/shader/slider/DoricSlideItemNode.cpp | 1 + .../doric/shader/slider/DoricSlideItemNode.h | 11 +++++++++++ .../doric/shader/slider/DoricSliderNode.cpp | 9 +++++++++ .../example/doric/shader/slider/DoricSliderNode.h | 11 +++++++++++ doric-Qt/example/doric/utils/DoricConstant.cpp | 1 + doric-Qt/example/doric/utils/DoricConstant.h | 1 + 10 files changed, 56 insertions(+) create mode 100644 doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp create mode 100644 doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h diff --git a/doric-Qt/example/doric/DoricRegistry.cpp b/doric-Qt/example/doric/DoricRegistry.cpp index 75a27b94..cf12e60e 100644 --- a/doric-Qt/example/doric/DoricRegistry.cpp +++ b/doric-Qt/example/doric/DoricRegistry.cpp @@ -13,6 +13,8 @@ #include "shader/DoricStackNode.h" #include "shader/DoricTextNode.h" #include "shader/DoricVLayoutNode.h" +#include "shader/slider/DoricSlideItemNode.h" +#include "shader/slider/DoricSliderNode.h" DoricRegistry::DoricRegistry() { registerNativePlugin("shader"); @@ -28,6 +30,8 @@ DoricRegistry::DoricRegistry() { registerViewNode("Text"); registerViewNode("Scroller"); registerViewNode("Image"); + registerViewNode("Slider"); + registerViewNode("SlideItem"); } bool DoricRegistry::acquirePluginInfo(QString name) { diff --git a/doric-Qt/example/doric/doric.pro b/doric-Qt/example/doric/doric.pro index 4f0d1cf9..bc3e4a7d 100644 --- a/doric-Qt/example/doric/doric.pro +++ b/doric-Qt/example/doric/doric.pro @@ -50,6 +50,7 @@ SOURCES += \ shader/DoricTextNode.cpp \ shader/DoricVLayoutNode.cpp \ shader/DoricViewNode.cpp \ + shader/slider/DoricSlideItemNode.cpp \ shader/slider/DoricSliderNode.cpp \ utils/DoricConstant.cpp \ utils/DoricContextHolder.cpp \ @@ -125,6 +126,7 @@ HEADERS += \ shader/DoricTextNode.h \ shader/DoricVLayoutNode.h \ shader/DoricViewNode.h \ + shader/slider/DoricSlideItemNode.h \ shader/slider/DoricSliderNode.h \ template/DoricSingleton.h \ utils/DoricConstant.h \ diff --git a/doric-Qt/example/doric/shader/DoricViewNode.cpp b/doric-Qt/example/doric/shader/DoricViewNode.cpp index d6556d84..6671d637 100644 --- a/doric-Qt/example/doric/shader/DoricViewNode.cpp +++ b/doric-Qt/example/doric/shader/DoricViewNode.cpp @@ -219,6 +219,20 @@ void DoricViewNode::callJSResponse(QString funcId, QVariantList args) { return getContext()->callEntity(DoricConstant::DORIC_ENTITY_RESPONSE, nArgs); } +void DoricViewNode::pureCallJSResponse(QString funcId, QVariantList args) { + QVariantList nArgs; + nArgs.append(getContext()->getContextId()); + nArgs.append(DoricConstant::DORIC_ENTITY_RESPONSE); + QList idList = getIdList(); + nArgs.append(QVariant(idList)); + nArgs.append(funcId); + foreach (const QVariant &arg, args) + nArgs.append(arg); + + return getContext()->callEntity(DoricConstant::DORIC_CONTEXT_INVOKE_PURE, + nArgs); +} + void DoricViewNode::onClick() { if (clickFunction.isEmpty()) { return; diff --git a/doric-Qt/example/doric/shader/DoricViewNode.h b/doric-Qt/example/doric/shader/DoricViewNode.h index 43027456..76235e7d 100644 --- a/doric-Qt/example/doric/shader/DoricViewNode.h +++ b/doric-Qt/example/doric/shader/DoricViewNode.h @@ -78,5 +78,7 @@ public: void onClick(); void callJSResponse(QString funcId, QVariantList args); + + void pureCallJSResponse(QString funcId, QVariantList args); }; #endif // DORICVIEWNODE_H diff --git a/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp new file mode 100644 index 00000000..60ec7572 --- /dev/null +++ b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.cpp @@ -0,0 +1 @@ +#include "DoricSlideItemNode.h" diff --git a/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h new file mode 100644 index 00000000..6788ec57 --- /dev/null +++ b/doric-Qt/example/doric/shader/slider/DoricSlideItemNode.h @@ -0,0 +1,11 @@ +#ifndef DORICSLIDEITEMNODE_H +#define DORICSLIDEITEMNODE_H + +#include "shader/DoricStackNode.h" + +class DoricSlideItemNode : public DoricStackNode { +public: + using DoricStackNode::DoricStackNode; +}; + +#endif // DORICSLIDEITEMNODE_H diff --git a/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp b/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp index 34b84bf9..fe626693 100644 --- a/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp +++ b/doric-Qt/example/doric/shader/slider/DoricSliderNode.cpp @@ -35,3 +35,12 @@ void DoricSliderNode::blendSubNode(QJsonValue subProperties) { void DoricSliderNode::blend(QJsonValue jsValue) {} void DoricSliderNode::blend(QQuickItem *view, QString name, QJsonValue prop) {} + +void DoricSliderNode::afterBlended(QJsonValue prop) { + if (this->childNodes.length() != this->itemCount) { + QVariantList args; + args.append(this->childNodes.length()); + args.append(this->itemCount); + this->pureCallJSResponse("renderBunchedItems", args); + } +} diff --git a/doric-Qt/example/doric/shader/slider/DoricSliderNode.h b/doric-Qt/example/doric/shader/slider/DoricSliderNode.h index 792d890e..b94d899a 100644 --- a/doric-Qt/example/doric/shader/slider/DoricSliderNode.h +++ b/doric-Qt/example/doric/shader/slider/DoricSliderNode.h @@ -1,10 +1,19 @@ #ifndef DORICSLIDERNODE_H #define DORICSLIDERNODE_H +#include "DoricSlideItemNode.h" #include "shader/DoricSuperNode.h" class DoricSliderNode : public DoricSuperNode { +private: + int itemCount = 0; + QString renderPageFuncId; + int batchCount = 15; + QString onPageSelectedFuncId; + bool loop = false; + QList childNodes; + public: using DoricSuperNode::DoricSuperNode; @@ -17,6 +26,8 @@ public: virtual void blend(QJsonValue jsValue) override; virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override; + + virtual void afterBlended(QJsonValue prop) override; }; #endif // DORICSLIDERNODE_H diff --git a/doric-Qt/example/doric/utils/DoricConstant.cpp b/doric-Qt/example/doric/utils/DoricConstant.cpp index 9403e674..f89c76e8 100644 --- a/doric-Qt/example/doric/utils/DoricConstant.cpp +++ b/doric-Qt/example/doric/utils/DoricConstant.cpp @@ -27,6 +27,7 @@ const QString DoricConstant::TEMPLATE_CONTEXT_DESTROY = const QString DoricConstant::GLOBAL_DORIC = "doric"; const QString DoricConstant::DORIC_CONTEXT_INVOKE = "jsCallEntityMethod"; +const QString DoricConstant::DORIC_CONTEXT_INVOKE_PURE = "pureCallEntityMethod"; const QString DoricConstant::DORIC_TIMER_CALLBACK = "jsCallbackTimer"; const QString DoricConstant::DORIC_BRIDGE_RESOLVE = "jsCallResolve"; const QString DoricConstant::DORIC_BRIDGE_REJECT = "jsCallReject"; diff --git a/doric-Qt/example/doric/utils/DoricConstant.h b/doric-Qt/example/doric/utils/DoricConstant.h index 47bb14be..dd329425 100644 --- a/doric-Qt/example/doric/utils/DoricConstant.h +++ b/doric-Qt/example/doric/utils/DoricConstant.h @@ -24,6 +24,7 @@ public: static const QString GLOBAL_DORIC; static const QString DORIC_CONTEXT_INVOKE; + static const QString DORIC_CONTEXT_INVOKE_PURE; static const QString DORIC_TIMER_CALLBACK; static const QString DORIC_BRIDGE_RESOLVE; static const QString DORIC_BRIDGE_REJECT;