add head & tail for h & v layout for fill
This commit is contained in:
parent
5229e04752
commit
ad1b1a979b
@ -33,7 +33,7 @@ Rectangle {
|
|||||||
|
|
||||||
if (this.widthSpec === 2) {
|
if (this.widthSpec === 2) {
|
||||||
this.width = parent.width
|
this.width = parent.width
|
||||||
// children[1].width = parent.width
|
children[1].width = parent.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,15 +77,35 @@ Rectangle {
|
|||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: head
|
||||||
|
objectName: "head"
|
||||||
|
}
|
||||||
|
|
||||||
onChildrenChanged: {
|
onChildrenChanged: {
|
||||||
console.log(tag, uuid + " gravity: " + gravity)
|
console.log(tag, uuid + " gravity: " + gravity)
|
||||||
for (var i = 0;i !== children.length;i++) {
|
for (var i = 0;i !== children.length;i++) {
|
||||||
|
if (children[i] !== head && children[i] !== tail) {
|
||||||
switch(this.gravity) {
|
switch(this.gravity) {
|
||||||
case Gravity.enumerate().CENTER_X:
|
case Gravity.enumerate().CENTER_X:
|
||||||
children[i].Layout.alignment = Qt.AlignHCenter
|
children[i].Layout.alignment = Qt.AlignHCenter
|
||||||
break
|
break
|
||||||
|
case Gravity.enumerate().CENTER:
|
||||||
|
children[i].Layout.alignment = Qt.AlignCenter
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gravity === Gravity.enumerate().CENTER || gravity === Gravity.enumerate().CENTER_X) {
|
||||||
|
head.Layout.fillWidth = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: tail
|
||||||
|
objectName: "tail"
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ Rectangle {
|
|||||||
|
|
||||||
if (this.heightSpec === 2) {
|
if (this.heightSpec === 2) {
|
||||||
this.height = parent.height
|
this.height = parent.height
|
||||||
// children[1].height = parent.height
|
children[1].height = parent.height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,16 +77,36 @@ Rectangle {
|
|||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: head
|
||||||
|
objectName: "head"
|
||||||
|
}
|
||||||
|
|
||||||
onChildrenChanged: {
|
onChildrenChanged: {
|
||||||
console.log(tag, uuid + " gravity: " + gravity)
|
console.log(tag, uuid + " gravity: " + gravity)
|
||||||
|
|
||||||
for (var i = 0;i !== children.length;i++) {
|
for (var i = 0;i !== children.length;i++) {
|
||||||
|
if (children[i] !== head && children[i] !== tail) {
|
||||||
switch(this.gravity) {
|
switch(this.gravity) {
|
||||||
case Gravity.enumerate().CENTER_X:
|
case Gravity.enumerate().CENTER_X:
|
||||||
children[i].Layout.alignment = Qt.AlignHCenter
|
children[i].Layout.alignment = Qt.AlignHCenter
|
||||||
break
|
break
|
||||||
|
case Gravity.enumerate().CENTER:
|
||||||
|
children[i].Layout.alignment = Qt.AlignCenter
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gravity === Gravity.enumerate().CENTER || gravity === Gravity.enumerate().CENTER_Y) {
|
||||||
|
head.Layout.fillHeight = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: tail
|
||||||
|
objectName: "tail"
|
||||||
|
Layout.fillHeight: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,10 @@ void DoricGroupNode::blend(QJsonValue jsValue) {
|
|||||||
|
|
||||||
void DoricGroupNode::configChildNode() {
|
void DoricGroupNode::configChildNode() {
|
||||||
QQuickItem *parent = nullptr;
|
QQuickItem *parent = nullptr;
|
||||||
if (mType.isEmpty() || mType == "Stack") {
|
if (mType == "HLayout" || mType == "VLayout") {
|
||||||
parent = mView;
|
|
||||||
} else {
|
|
||||||
parent = mView->childItems().at(1);
|
parent = mView->childItems().at(1);
|
||||||
|
} else {
|
||||||
|
parent = mView;
|
||||||
}
|
}
|
||||||
for (int idx = 0; idx < mChildViewIds.size(); idx++) {
|
for (int idx = 0; idx < mChildViewIds.size(); idx++) {
|
||||||
QString id = mChildViewIds.at(idx);
|
QString id = mChildViewIds.at(idx);
|
||||||
@ -140,6 +140,23 @@ void DoricGroupNode::configChildNode() {
|
|||||||
viewNode->getNodeView()->setParentItem(nullptr);
|
viewNode->getNodeView()->setParentItem(nullptr);
|
||||||
viewNode->getNodeView()->deleteLater();
|
viewNode->getNodeView()->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle tail
|
||||||
|
if (mType == "VLayout" || mType == "HLayout") {
|
||||||
|
int tailIndex = -1;
|
||||||
|
for (int idx = 0; idx < parent->childItems().size(); idx++) {
|
||||||
|
if (parent->childItems().at(idx)->objectName() == "tail") {
|
||||||
|
tailIndex = idx;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tailIndex != -1 && tailIndex != parent->childItems().size() - 1) {
|
||||||
|
QQuickItem *tail = parent->childItems().at(tailIndex);
|
||||||
|
tail->setParentItem(nullptr);
|
||||||
|
tail->setParentItem(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoricGroupNode::blendSubNode(QJsonValue subProperties) {
|
void DoricGroupNode::blendSubNode(QJsonValue subProperties) {
|
||||||
|
@ -16,10 +16,11 @@ QQuickItem *DoricHLayoutNode::build() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||||
|
QQuickItem *container = view->childItems().at(1);
|
||||||
if (name == "space") {
|
if (name == "space") {
|
||||||
view->childItems().at(1)->setProperty("spacing", prop.toInt());
|
container->setProperty("spacing", prop.toInt());
|
||||||
} else if (name == "gravity") {
|
} else if (name == "gravity") {
|
||||||
view->childItems().at(1)->setProperty("gravity", prop.toInt());
|
container->setProperty("gravity", prop.toInt());
|
||||||
} else {
|
} else {
|
||||||
DoricGroupNode::blend(view, name, prop);
|
DoricGroupNode::blend(view, name, prop);
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,11 @@ QQuickItem *DoricVLayoutNode::build() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||||
|
QQuickItem *container = view->childItems().at(1);
|
||||||
if (name == "space") {
|
if (name == "space") {
|
||||||
view->childItems().at(1)->setProperty("spacing", prop.toInt());
|
container->setProperty("spacing", prop.toInt());
|
||||||
} else if (name == "gravity") {
|
} else if (name == "gravity") {
|
||||||
view->childItems().at(1)->setProperty("gravity", prop.toInt());
|
container->setProperty("gravity", prop.toInt());
|
||||||
} else {
|
} else {
|
||||||
DoricGroupNode::blend(view, name, prop);
|
DoricGroupNode::blend(view, name, prop);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user