From 50f80a3fe4bb12c1a62e886a36d73829e348d543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 15 Jun 2021 17:36:01 +0800 Subject: [PATCH] fix layout bug --- doric-Qt/example/doric/shader/DoricScrollerNode.cpp | 5 ++--- doric-Qt/example/doric/shader/DoricSuperNode.cpp | 2 ++ doric-Qt/example/doric/shader/DoricTextNode.cpp | 6 ++++++ doric-Qt/example/doric/shader/DoricTextNode.h | 2 ++ doric-Qt/example/doric/utils/DoricLayouts.cpp | 2 ++ doric-Qt/example/doric/utils/DoricLayouts.h | 1 + 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doric-Qt/example/doric/shader/DoricScrollerNode.cpp b/doric-Qt/example/doric/shader/DoricScrollerNode.cpp index aad67ab3..375908b5 100644 --- a/doric-Qt/example/doric/shader/DoricScrollerNode.cpp +++ b/doric-Qt/example/doric/shader/DoricScrollerNode.cpp @@ -113,12 +113,11 @@ QSizeF DoricScrollerNode::sizeThatFits(QSizeF size) { ->property("doricLayout") .toULongLong(); - if (layout->getResolved()) { + if (!layout->getResolved()) { layout->apply(size); } - return QSizeF(qMax(size.width(), layout->getMeasuredWidth()), - qMax(size.height(), layout->getMeasuredHeight())); + return QSizeF(layout->getMeasuredWidth(), layout->getMeasuredHeight()); } DoricViewNode *DoricScrollerNode::getSubNodeById(QString id) { diff --git a/doric-Qt/example/doric/shader/DoricSuperNode.cpp b/doric-Qt/example/doric/shader/DoricSuperNode.cpp index 9f99db8b..6a047c42 100644 --- a/doric-Qt/example/doric/shader/DoricSuperNode.cpp +++ b/doric-Qt/example/doric/shader/DoricSuperNode.cpp @@ -12,6 +12,8 @@ void DoricSuperNode::blend(QQuickItem *view, QString name, QJsonValue prop) { mixinSubNode(subNode); blendSubNode(subNode); } + + getLayouts()->setResolved(false); } } else { DoricViewNode::blend(view, name, prop); diff --git a/doric-Qt/example/doric/shader/DoricTextNode.cpp b/doric-Qt/example/doric/shader/DoricTextNode.cpp index 92d3359b..92e323b4 100644 --- a/doric-Qt/example/doric/shader/DoricTextNode.cpp +++ b/doric-Qt/example/doric/shader/DoricTextNode.cpp @@ -98,3 +98,9 @@ void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) { DoricViewNode::blend(view, name, prop); } } + +void DoricTextNode::blend(QJsonValue jsValue) { + DoricViewNode::blend(jsValue); + + getLayouts()->setResolved(false); +} diff --git a/doric-Qt/example/doric/shader/DoricTextNode.h b/doric-Qt/example/doric/shader/DoricTextNode.h index d3cabe33..8c64c875 100644 --- a/doric-Qt/example/doric/shader/DoricTextNode.h +++ b/doric-Qt/example/doric/shader/DoricTextNode.h @@ -13,6 +13,8 @@ public: virtual void blendLayoutConfig(QJsonValue jsObject) override; + virtual void blend(QJsonValue jsValue) override; + virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override; }; diff --git a/doric-Qt/example/doric/utils/DoricLayouts.cpp b/doric-Qt/example/doric/utils/DoricLayouts.cpp index 8bd00e84..53327a3b 100644 --- a/doric-Qt/example/doric/utils/DoricLayouts.cpp +++ b/doric-Qt/example/doric/utils/DoricLayouts.cpp @@ -753,3 +753,5 @@ void DoricLayouts::setMeasuredY(qreal measuredY) { } bool DoricLayouts::getResolved() { return resolved; } + +void DoricLayouts::setResolved(bool resolved) { this->resolved = resolved; } diff --git a/doric-Qt/example/doric/utils/DoricLayouts.h b/doric-Qt/example/doric/utils/DoricLayouts.h index c7d66e0c..e9926b94 100644 --- a/doric-Qt/example/doric/utils/DoricLayouts.h +++ b/doric-Qt/example/doric/utils/DoricLayouts.h @@ -94,6 +94,7 @@ public: qreal getMeasuredHeight(); bool getResolved(); + void setResolved(bool resolved); private: QString tag;