add blend layout config

This commit is contained in:
王劲鹏 2021-03-02 17:18:23 +08:00 committed by osborn
parent 78629497aa
commit 692397be2e
10 changed files with 53 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.0, 2021-03-01T18:01:24. -->
<!-- Written by QtCreator 4.14.0, 2021-03-02T10:23:38. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -271,7 +271,7 @@ Rectangle {
}
function updatePositions() {
if (flex.height != 0 && flex.width != 0) {
if (flex.height !== 0 && flex.width !== 0) {
var rootNode = flexLayoutService.createNode();
processNode(flex, rootNode);
var nodes = []

View File

@ -18,9 +18,9 @@ void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJSValue prop) {
if (name == "space") {
view->setProperty("spacing", prop.toInt());
} else if (name == "gravity") {
qWarning() << "gravity: " << prop.toInt();
switch (prop.toInt()) {
case 1:
view->setProperty("alignItems", "center");
break;
}
} else {

View File

@ -14,4 +14,12 @@ QQuickItem *DoricStackNode::build() {
return item;
}
void DoricStackNode::blendLayoutConfig() { DoricViewNode::blendLayoutConfig(); }
void DoricStackNode::blendLayoutConfig(QJSValue jsValue) {
DoricViewNode::blendLayoutConfig(jsValue);
QJSValue maxWidth = jsValue.property("maxWidth");
if (maxWidth.isNumber()) {
}
QJSValue maxHeight = jsValue.property("maxHeight");
if (maxHeight.isNumber()) {
}
}

View File

@ -9,7 +9,7 @@ public:
QQuickItem *build() override;
void blendLayoutConfig() override;
void blendLayoutConfig(QJSValue jsValue) override;
};
#endif // DORICSTACKNODE_H

View File

@ -49,3 +49,8 @@ QJSValue DoricSuperNode::getSubModel(QString id) {
return QJSValue::UndefinedValue;
}
}
void DoricSuperNode::blendSubLayoutConfig(DoricViewNode *viewNode,
QJSValue jsValue) {
viewNode->blendLayoutConfig(jsValue);
}

View File

@ -10,8 +10,6 @@ private:
protected:
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
void blendSubLayoutConfig(DoricViewNode *viewNode);
virtual void blendSubNode(QJSValue subProperties) = 0;
public:
@ -21,6 +19,8 @@ public:
QJSValue getSubModel(QString id);
void blendSubLayoutConfig(DoricViewNode *viewNode, QJSValue jsValue);
private:
void mixinSubNode(QJSValue subNode);

View File

@ -18,9 +18,9 @@ void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJSValue prop) {
if (name == "space") {
view->setProperty("spacing", prop.toInt());
} else if (name == "gravity") {
qWarning() << "gravity: " << prop.toInt();
switch (prop.toInt()) {
case 1:
view->setProperty("alignItems", "center");
break;
}
} else {

View File

@ -4,9 +4,33 @@
#include "DoricSuperNode.h"
#include "DoricViewNode.h"
void DoricViewNode::blendLayoutConfig() {}
void DoricViewNode::blendLayoutConfig(QJSValue jsObject) {
QJSValue margin = jsObject.property("margin");
QJSValue widthSpec = jsObject.property("widthSpec");
QJSValue heightSpec = jsObject.property("heightSpec");
void DoricViewNode::setLayoutConfig(QJSValue layoutConfig) {}
if (widthSpec.isNumber()) {
switch (widthSpec.toInt()) {
case 1:
qCritical() << 1;
break;
case 2:
qCritical() << 1;
break;
default:
qCritical() << "default";
break;
}
}
}
void DoricViewNode::setLayoutConfig(QJSValue layoutConfig) {
if (mSuperNode != nullptr) {
mSuperNode->blendSubLayoutConfig(this, layoutConfig);
} else {
blendLayoutConfig(layoutConfig);
}
}
void DoricViewNode::init(DoricSuperNode *superNode) {
if (DoricUtils:: instanceof <DoricSuperNode *>(this)) {
@ -26,6 +50,10 @@ QString DoricViewNode::getType() { return mType; }
QQuickItem *DoricViewNode::getNodeView() { return mView; }
void DoricViewNode::blend(QJSValue jsValue) {
QJSValue value = jsValue.property("layoutConfig");
if (value.isObject()) {
setLayoutConfig(value);
}
QJSValueIterator it(jsValue);
while (it.hasNext()) {
it.next();

View File

@ -16,8 +16,6 @@ protected:
virtual QQuickItem *build() = 0;
virtual void blendLayoutConfig();
void setLayoutConfig(QJSValue layoutConfig);
private:
@ -55,5 +53,7 @@ public:
virtual void blend(QJSValue jsValue);
virtual void blend(QQuickItem *view, QString name, QJSValue prop);
virtual void blendLayoutConfig(QJSValue jsObject);
};
#endif // DORICVIEWNODE_H