fix layout bug

This commit is contained in:
王劲鹏 2021-06-15 17:36:01 +08:00 committed by osborn
parent 738566e043
commit 50f80a3fe4
6 changed files with 15 additions and 3 deletions

View File

@ -113,12 +113,11 @@ QSizeF DoricScrollerNode::sizeThatFits(QSizeF size) {
->property("doricLayout") ->property("doricLayout")
.toULongLong(); .toULongLong();
if (layout->getResolved()) { if (!layout->getResolved()) {
layout->apply(size); layout->apply(size);
} }
return QSizeF(qMax(size.width(), layout->getMeasuredWidth()), return QSizeF(layout->getMeasuredWidth(), layout->getMeasuredHeight());
qMax(size.height(), layout->getMeasuredHeight()));
} }
DoricViewNode *DoricScrollerNode::getSubNodeById(QString id) { DoricViewNode *DoricScrollerNode::getSubNodeById(QString id) {

View File

@ -12,6 +12,8 @@ void DoricSuperNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
mixinSubNode(subNode); mixinSubNode(subNode);
blendSubNode(subNode); blendSubNode(subNode);
} }
getLayouts()->setResolved(false);
} }
} else { } else {
DoricViewNode::blend(view, name, prop); DoricViewNode::blend(view, name, prop);

View File

@ -98,3 +98,9 @@ void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
DoricViewNode::blend(view, name, prop); DoricViewNode::blend(view, name, prop);
} }
} }
void DoricTextNode::blend(QJsonValue jsValue) {
DoricViewNode::blend(jsValue);
getLayouts()->setResolved(false);
}

View File

@ -13,6 +13,8 @@ public:
virtual void blendLayoutConfig(QJsonValue jsObject) override; virtual void blendLayoutConfig(QJsonValue jsObject) override;
virtual void blend(QJsonValue jsValue) override;
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override; virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
}; };

View File

@ -753,3 +753,5 @@ void DoricLayouts::setMeasuredY(qreal measuredY) {
} }
bool DoricLayouts::getResolved() { return resolved; } bool DoricLayouts::getResolved() { return resolved; }
void DoricLayouts::setResolved(bool resolved) { this->resolved = resolved; }

View File

@ -94,6 +94,7 @@ public:
qreal getMeasuredHeight(); qreal getMeasuredHeight();
bool getResolved(); bool getResolved();
void setResolved(bool resolved);
private: private:
QString tag; QString tag;