add target node view & set width, height
This commit is contained in:
parent
4c0a177747
commit
028334e530
@ -77,3 +77,10 @@ QObject *DoricContext::obtainPlugin(QString name) {
|
||||
void DoricContext::setQmlEngine(QQmlEngine *engine) { mQmlEngine = engine; }
|
||||
|
||||
QQmlEngine *DoricContext::getQmlEngine() { return mQmlEngine; }
|
||||
|
||||
DoricViewNode *DoricContext::targetViewNode(QString id) {
|
||||
if (id == mRootNode->getId()) {
|
||||
return mRootNode;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "DoricInterfaceDriver.h"
|
||||
|
||||
class DoricViewNode;
|
||||
class DoricRootNode;
|
||||
|
||||
class DoricContext {
|
||||
@ -40,6 +41,8 @@ public:
|
||||
void setQmlEngine(QQmlEngine *engine);
|
||||
|
||||
QQmlEngine *getQmlEngine();
|
||||
|
||||
DoricViewNode *targetViewNode(QString id);
|
||||
};
|
||||
|
||||
#endif // CONTEXT_H
|
||||
|
@ -9,9 +9,15 @@ void DoricShaderPlugin::render(QJSValue jsValue, QString callbackId) {
|
||||
QString viewId = jsValue.property("id").toString();
|
||||
DoricRootNode *rootNode = getContext()->getRootNode();
|
||||
|
||||
if (rootNode->getId().isEmpty() && jsValue.property("type").toString() == "Root") {
|
||||
if (rootNode->getId().isEmpty() &&
|
||||
jsValue.property("type").toString() == "Root") {
|
||||
rootNode->setId(viewId);
|
||||
rootNode->blend(jsValue.property("props"));
|
||||
} else {
|
||||
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
|
||||
if (viewNode != nullptr) {
|
||||
viewNode->blend(jsValue.property("props"));
|
||||
}
|
||||
}
|
||||
},
|
||||
DoricThreadMode::UI);
|
||||
|
@ -35,9 +35,15 @@ void DoricViewNode::blend(QJSValue jsValue) {
|
||||
|
||||
void DoricViewNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
if (name == "width") {
|
||||
view->setWidth(100);
|
||||
if (!prop.isNumber()) {
|
||||
return;
|
||||
}
|
||||
view->setWidth(prop.toInt());
|
||||
} else if (name == "height") {
|
||||
view->setHeight(100);
|
||||
if (!prop.isNumber()) {
|
||||
return;
|
||||
}
|
||||
view->setHeight(prop.toInt());
|
||||
} else if (name == "backgroundColor") {
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user