add blend layout config
This commit is contained in:
parent
78629497aa
commit
692397be2e
@ -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>
|
||||
|
@ -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 = []
|
||||
|
@ -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 {
|
||||
|
@ -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()) {
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
|
||||
QQuickItem *build() override;
|
||||
|
||||
void blendLayoutConfig() override;
|
||||
void blendLayoutConfig(QJSValue jsValue) override;
|
||||
};
|
||||
|
||||
#endif // DORICSTACKNODE_H
|
||||
|
@ -49,3 +49,8 @@ QJSValue DoricSuperNode::getSubModel(QString id) {
|
||||
return QJSValue::UndefinedValue;
|
||||
}
|
||||
}
|
||||
|
||||
void DoricSuperNode::blendSubLayoutConfig(DoricViewNode *viewNode,
|
||||
QJSValue jsValue) {
|
||||
viewNode->blendLayoutConfig(jsValue);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user