add node hierarchy

This commit is contained in:
王劲鹏 2021-02-09 15:54:22 +08:00 committed by osborn
parent b406460a8d
commit 915814fc2a
11 changed files with 84 additions and 3 deletions

View File

@ -31,7 +31,10 @@ SOURCES += \
engine/DoricTimerExtension.cpp \ engine/DoricTimerExtension.cpp \
main.cpp \ main.cpp \
plugin/DoricShaderPlugin.cpp \ plugin/DoricShaderPlugin.cpp \
shader/DoricGroupNode.cpp \
shader/DoricRootNode.cpp \ shader/DoricRootNode.cpp \
shader/DoricStackNode.cpp \
shader/DoricSuperNode.cpp \
shader/DoricViewNode.cpp \ shader/DoricViewNode.cpp \
utils/DoricConstant.cpp \ utils/DoricConstant.cpp \
utils/DoricContextHolder.cpp utils/DoricContextHolder.cpp
@ -71,7 +74,10 @@ HEADERS += \
engine/DoricTimerExtension.h \ engine/DoricTimerExtension.h \
plugin/DoricNativePlugin.h \ plugin/DoricNativePlugin.h \
plugin/DoricShaderPlugin.h \ plugin/DoricShaderPlugin.h \
shader/DoricGroupNode.h \
shader/DoricRootNode.h \ shader/DoricRootNode.h \
shader/DoricStackNode.h \
shader/DoricSuperNode.h \
shader/DoricViewNode.h \ shader/DoricViewNode.h \
template/DoricSingleton.h \ template/DoricSingleton.h \
utils/DoricConstant.h \ utils/DoricConstant.h \

View File

@ -2,7 +2,7 @@
<qresource prefix="/"> <qresource prefix="/">
<file>main.qml</file> <file>main.qml</file>
<file>qtquickcontrols2.conf</file> <file>qtquickcontrols2.conf</file>
<file>view.qml</file> <file>stack.qml</file>
</qresource> </qresource>
<qresource prefix="/doric"> <qresource prefix="/doric">
<file alias="doric-sandbox.js">../../doric-js/bundle/doric-sandbox.js</file> <file alias="doric-sandbox.js">../../doric-js/bundle/doric-sandbox.js</file>

View File

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

View File

@ -0,0 +1,11 @@
#ifndef DORICGROUPNODE_H
#define DORICGROUPNODE_H
#include "DoricSuperNode.h"
class DoricGroupNode : public DoricSuperNode {
public:
using DoricSuperNode::DoricSuperNode;
};
#endif // DORICGROUPNODE_H

View File

@ -0,0 +1,14 @@
#include "DoricStackNode.h"
QQmlComponent *DoricStackNode::build() {
QQmlComponent *component = new QQmlComponent();
const QUrl url(QStringLiteral("qrc:/stack.qml"));
component->loadUrl(url);
return component;
}
void DoricStackNode::blendLayoutConfig() {
DoricViewNode::blendLayoutConfig();
}

View File

@ -0,0 +1,16 @@
#ifndef DORICSTACKNODE_H
#define DORICSTACKNODE_H
#include "DoricGroupNode.h"
class DoricStackNode : public DoricGroupNode
{
public:
using DoricGroupNode::DoricGroupNode;
QQmlComponent *build() override;
void blendLayoutConfig() override;
};
#endif // DORICSTACKNODE_H

View File

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

View File

@ -0,0 +1,14 @@
#ifndef DORICSUPERNODE_H
#define DORICSUPERNODE_H
#include "DoricViewNode.h"
class DoricSuperNode : public DoricViewNode {
protected:
void blendSubLayoutConfig(DoricViewNode *viewNode);
public:
using DoricViewNode::DoricViewNode;
};
#endif // DORICSUPERNODE_H

View File

@ -1 +1,5 @@
#include "DoricViewNode.h" #include "DoricViewNode.h"
void DoricViewNode::blendLayoutConfig(){
}

View File

@ -1,9 +1,23 @@
#ifndef DORICVIEWNODE_H #ifndef DORICVIEWNODE_H
#define DORICVIEWNODE_H #define DORICVIEWNODE_H
#include <QQmlComponent>
#include "../utils/DoricContextHolder.h" #include "../utils/DoricContextHolder.h"
class DoricViewNode : public DoricContextHolder { class DoricViewNode : public DoricContextHolder {
protected:
QQmlComponent mView;
virtual QQmlComponent *build() = 0;
virtual void blendLayoutConfig();
private:
QString mId;
QString mType;
public: public:
using DoricContextHolder::DoricContextHolder; using DoricContextHolder::DoricContextHolder;
}; };

View File

@ -1,6 +1,6 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Controls 2.5 import QtQuick.Controls 2.5
Rectangle { StackView {
color: 'red'
} }