add slider, slider node & pure call response

This commit is contained in:
王劲鹏 2021-05-10 16:09:29 +08:00 committed by osborn
parent 3721c856fb
commit 3531a28f13
10 changed files with 56 additions and 0 deletions

View File

@ -13,6 +13,8 @@
#include "shader/DoricStackNode.h" #include "shader/DoricStackNode.h"
#include "shader/DoricTextNode.h" #include "shader/DoricTextNode.h"
#include "shader/DoricVLayoutNode.h" #include "shader/DoricVLayoutNode.h"
#include "shader/slider/DoricSlideItemNode.h"
#include "shader/slider/DoricSliderNode.h"
DoricRegistry::DoricRegistry() { DoricRegistry::DoricRegistry() {
registerNativePlugin<DoricShaderPlugin>("shader"); registerNativePlugin<DoricShaderPlugin>("shader");
@ -28,6 +30,8 @@ DoricRegistry::DoricRegistry() {
registerViewNode<DoricTextNode>("Text"); registerViewNode<DoricTextNode>("Text");
registerViewNode<DoricScrollerNode>("Scroller"); registerViewNode<DoricScrollerNode>("Scroller");
registerViewNode<DoricImageNode>("Image"); registerViewNode<DoricImageNode>("Image");
registerViewNode<DoricSliderNode>("Slider");
registerViewNode<DoricSlideItemNode>("SlideItem");
} }
bool DoricRegistry::acquirePluginInfo(QString name) { bool DoricRegistry::acquirePluginInfo(QString name) {

View File

@ -50,6 +50,7 @@ SOURCES += \
shader/DoricTextNode.cpp \ shader/DoricTextNode.cpp \
shader/DoricVLayoutNode.cpp \ shader/DoricVLayoutNode.cpp \
shader/DoricViewNode.cpp \ shader/DoricViewNode.cpp \
shader/slider/DoricSlideItemNode.cpp \
shader/slider/DoricSliderNode.cpp \ shader/slider/DoricSliderNode.cpp \
utils/DoricConstant.cpp \ utils/DoricConstant.cpp \
utils/DoricContextHolder.cpp \ utils/DoricContextHolder.cpp \
@ -125,6 +126,7 @@ HEADERS += \
shader/DoricTextNode.h \ shader/DoricTextNode.h \
shader/DoricVLayoutNode.h \ shader/DoricVLayoutNode.h \
shader/DoricViewNode.h \ shader/DoricViewNode.h \
shader/slider/DoricSlideItemNode.h \
shader/slider/DoricSliderNode.h \ shader/slider/DoricSliderNode.h \
template/DoricSingleton.h \ template/DoricSingleton.h \
utils/DoricConstant.h \ utils/DoricConstant.h \

View File

@ -219,6 +219,20 @@ void DoricViewNode::callJSResponse(QString funcId, QVariantList args) {
return getContext()->callEntity(DoricConstant::DORIC_ENTITY_RESPONSE, nArgs); 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<QString> 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() { void DoricViewNode::onClick() {
if (clickFunction.isEmpty()) { if (clickFunction.isEmpty()) {
return; return;

View File

@ -78,5 +78,7 @@ public:
void onClick(); void onClick();
void callJSResponse(QString funcId, QVariantList args); void callJSResponse(QString funcId, QVariantList args);
void pureCallJSResponse(QString funcId, QVariantList args);
}; };
#endif // DORICVIEWNODE_H #endif // DORICVIEWNODE_H

View File

@ -0,0 +1 @@
#include "DoricSlideItemNode.h"

View File

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

View File

@ -35,3 +35,12 @@ void DoricSliderNode::blendSubNode(QJsonValue subProperties) {
void DoricSliderNode::blend(QJsonValue jsValue) {} void DoricSliderNode::blend(QJsonValue jsValue) {}
void DoricSliderNode::blend(QQuickItem *view, QString name, QJsonValue prop) {} 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);
}
}

View File

@ -1,10 +1,19 @@
#ifndef DORICSLIDERNODE_H #ifndef DORICSLIDERNODE_H
#define DORICSLIDERNODE_H #define DORICSLIDERNODE_H
#include "DoricSlideItemNode.h"
#include "shader/DoricSuperNode.h" #include "shader/DoricSuperNode.h"
class DoricSliderNode : public DoricSuperNode { class DoricSliderNode : public DoricSuperNode {
private:
int itemCount = 0;
QString renderPageFuncId;
int batchCount = 15;
QString onPageSelectedFuncId;
bool loop = false;
QList<DoricSlideItemNode *> childNodes;
public: public:
using DoricSuperNode::DoricSuperNode; using DoricSuperNode::DoricSuperNode;
@ -17,6 +26,8 @@ public:
virtual void blend(QJsonValue jsValue) override; virtual void blend(QJsonValue jsValue) override;
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override; virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
virtual void afterBlended(QJsonValue prop) override;
}; };
#endif // DORICSLIDERNODE_H #endif // DORICSLIDERNODE_H

View File

@ -27,6 +27,7 @@ const QString DoricConstant::TEMPLATE_CONTEXT_DESTROY =
const QString DoricConstant::GLOBAL_DORIC = "doric"; const QString DoricConstant::GLOBAL_DORIC = "doric";
const QString DoricConstant::DORIC_CONTEXT_INVOKE = "jsCallEntityMethod"; 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_TIMER_CALLBACK = "jsCallbackTimer";
const QString DoricConstant::DORIC_BRIDGE_RESOLVE = "jsCallResolve"; const QString DoricConstant::DORIC_BRIDGE_RESOLVE = "jsCallResolve";
const QString DoricConstant::DORIC_BRIDGE_REJECT = "jsCallReject"; const QString DoricConstant::DORIC_BRIDGE_REJECT = "jsCallReject";

View File

@ -24,6 +24,7 @@ public:
static const QString GLOBAL_DORIC; static const QString GLOBAL_DORIC;
static const QString DORIC_CONTEXT_INVOKE; static const QString DORIC_CONTEXT_INVOKE;
static const QString DORIC_CONTEXT_INVOKE_PURE;
static const QString DORIC_TIMER_CALLBACK; static const QString DORIC_TIMER_CALLBACK;
static const QString DORIC_BRIDGE_RESOLVE; static const QString DORIC_BRIDGE_RESOLVE;
static const QString DORIC_BRIDGE_REJECT; static const QString DORIC_BRIDGE_REJECT;