add super node & view node
This commit is contained in:
parent
b785685802
commit
ad04078f88
@ -23,6 +23,7 @@ SOURCES += \
|
||||
native/native_empty.cpp \
|
||||
native/native_log.cpp \
|
||||
native/native_timer.cpp \
|
||||
plugin/shader_plugin.cpp \
|
||||
registry.cpp
|
||||
|
||||
RESOURCES += qml.qrc
|
||||
@ -52,5 +53,7 @@ HEADERS += \
|
||||
native/native_timer.h \
|
||||
plugin/shader_plugin.h \
|
||||
registry.h \
|
||||
shader/super_node.h \
|
||||
shader/view_node.h \
|
||||
template/singleton.h \
|
||||
utility/utility.h
|
||||
|
@ -14,6 +14,10 @@ Q_INVOKABLE void NativeBridge::function(int contextId, QString module, QString m
|
||||
qDebug() << value;
|
||||
if (value.contains("ShaderPlugin")) {
|
||||
ShaderPlugin shaderPlugin(context);
|
||||
QMetaObject::invokeMethod(&shaderPlugin, methodName.toStdString().c_str());
|
||||
QMetaObject::invokeMethod(
|
||||
&shaderPlugin,
|
||||
methodName.toStdString().c_str(),
|
||||
Qt::AutoConnection,
|
||||
Q_ARG(QJSValue, jsValue));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
#include "native_empty.h"
|
||||
|
||||
void NativeEmpty::function() {
|
||||
Q_INVOKABLE void NativeEmpty::function() {
|
||||
qDebug() << "nativeEmpty";
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "native_log.h"
|
||||
|
||||
void NativeLog::function(QString level, QString content) {
|
||||
Q_INVOKABLE void NativeLog::function(QString level, QString content) {
|
||||
if (level == 'w') {
|
||||
qWarning() << content;
|
||||
} else if (level == 'd') {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "native_timer.h"
|
||||
|
||||
void NativeTimer::setTimer(long timerId, int time, bool repeat) {
|
||||
Q_INVOKABLE void NativeTimer::setTimer(long timerId, int time, bool repeat) {
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setSingleShot(!repeat);
|
||||
connect(timer, &QTimer::timeout, this, [=] () {
|
||||
|
7
doric/plugin/shader_plugin.cpp
Normal file
7
doric/plugin/shader_plugin.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "shader_plugin.h"
|
||||
#include "shader/view_node.h"
|
||||
|
||||
Q_INVOKABLE void ShaderPlugin::render(QJSValue jsValue) {
|
||||
QString viewId = jsValue.property("id").toString();
|
||||
ViewNode<QObject> *viewNode = new ViewNode<QObject>(nullptr);
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
#define SHADER_PLUGIN_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QJSValue>
|
||||
|
||||
#include "context_holder.h"
|
||||
|
||||
@ -11,9 +12,7 @@ class ShaderPlugin : public ContextHolder {
|
||||
public:
|
||||
ShaderPlugin(Context *context) : ContextHolder(context) {}
|
||||
|
||||
Q_INVOKABLE void render() {
|
||||
qDebug() << "render";
|
||||
}
|
||||
Q_INVOKABLE void render(QJSValue jsValue);
|
||||
};
|
||||
|
||||
#endif // SHADER_PLUGIN_H
|
||||
|
25
doric/shader/super_node.h
Normal file
25
doric/shader/super_node.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef SUPER_NODE_H
|
||||
#define SUPER_NODE_H
|
||||
|
||||
#include <QJSValue>
|
||||
#include <QMap>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include "view_node.h"
|
||||
|
||||
template <typename V>
|
||||
class SuperNode : public ViewNode<V> {
|
||||
|
||||
private:
|
||||
QMap<QString, QJSValue> subNodes;
|
||||
|
||||
protected:
|
||||
bool reusable = false;
|
||||
|
||||
public:
|
||||
virtual ~SuperNode() = default;
|
||||
|
||||
virtual ViewNode<V> *getSubNodeById(QString *id) = 0;
|
||||
};
|
||||
|
||||
#endif // SUPER_NODE_H
|
24
doric/shader/view_node.h
Normal file
24
doric/shader/view_node.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef VIEW_NODE_H
|
||||
#define VIEW_NODE_H
|
||||
|
||||
#include "context_holder.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename V>
|
||||
class SuperNode;
|
||||
|
||||
template <class T>
|
||||
class ViewNode : public ContextHolder {
|
||||
|
||||
protected:
|
||||
T view;
|
||||
|
||||
private:
|
||||
QString *id;
|
||||
|
||||
public:
|
||||
ViewNode(Context *context) : ContextHolder(context) {}
|
||||
};
|
||||
|
||||
#endif // VIEW_NODE_H
|
Reference in New Issue
Block a user