From af1ef2a1039a33fbe21134073d1654ca5efd7ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Fri, 28 May 2021 13:27:11 +0800 Subject: [PATCH] layout bug fix --- doric-Qt/example/doric/shader/DoricScrollerNode.cpp | 9 ++++++--- doric-Qt/example/doric/utils/DoricLayouts.cpp | 2 ++ doric-Qt/example/doric/utils/DoricLayouts.h | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doric-Qt/example/doric/shader/DoricScrollerNode.cpp b/doric-Qt/example/doric/shader/DoricScrollerNode.cpp index c31c425b..aad67ab3 100644 --- a/doric-Qt/example/doric/shader/DoricScrollerNode.cpp +++ b/doric-Qt/example/doric/shader/DoricScrollerNode.cpp @@ -112,10 +112,13 @@ QSizeF DoricScrollerNode::sizeThatFits(QSizeF size) { DoricLayouts *layout = (DoricLayouts *)mChildNode->getNodeView() ->property("doricLayout") .toULongLong(); - layout->apply(size); - return QSizeF(qMin(size.width(), layout->getMeasuredWidth()), - qMin(size.height(), layout->getMeasuredHeight())); + if (layout->getResolved()) { + layout->apply(size); + } + + return QSizeF(qMax(size.width(), layout->getMeasuredWidth()), + qMax(size.height(), layout->getMeasuredHeight())); } DoricViewNode *DoricScrollerNode::getSubNodeById(QString id) { diff --git a/doric-Qt/example/doric/utils/DoricLayouts.cpp b/doric-Qt/example/doric/utils/DoricLayouts.cpp index 19bb5697..8bd00e84 100644 --- a/doric-Qt/example/doric/utils/DoricLayouts.cpp +++ b/doric-Qt/example/doric/utils/DoricLayouts.cpp @@ -751,3 +751,5 @@ void DoricLayouts::setMeasuredY(qreal measuredY) { qCritical() << "DoricLayouts: " << tag << this->view->property("uuid") << " measuredY: " << this->measuredY; } + +bool DoricLayouts::getResolved() { return resolved; } diff --git a/doric-Qt/example/doric/utils/DoricLayouts.h b/doric-Qt/example/doric/utils/DoricLayouts.h index 6df1ab7f..c7d66e0c 100644 --- a/doric-Qt/example/doric/utils/DoricLayouts.h +++ b/doric-Qt/example/doric/utils/DoricLayouts.h @@ -93,6 +93,8 @@ public: qreal getMeasuredWidth(); qreal getMeasuredHeight(); + bool getResolved(); + private: QString tag;