From 511c33c52acc4de8da7a1145ae24ab9c14cf2860 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 16 Sep 2025 16:29:25 +0100 Subject: [PATCH] Handle Expanding policies in flow layouts --- qrenderdoc/3rdparty/flowlayout/FlowLayout.cpp | 27 ++++++++++++++++++- qrenderdoc/3rdparty/flowlayout/FlowLayout.h | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/3rdparty/flowlayout/FlowLayout.cpp b/qrenderdoc/3rdparty/flowlayout/FlowLayout.cpp index 619dd0965..f91dc07d0 100644 --- a/qrenderdoc/3rdparty/flowlayout/FlowLayout.cpp +++ b/qrenderdoc/3rdparty/flowlayout/FlowLayout.cpp @@ -194,6 +194,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const } } + QList> line; + foreach (item, itemList) { QWidget *wid = item->widget(); @@ -209,6 +211,9 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); int nextX = x + size.width() + spaceX; if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { + setLineGeometry(line, lineHeight); + line.clear(); + x = effectiveRect.x(); y = y + lineHeight + spaceY; nextX = x + size.width() + spaceX; @@ -216,13 +221,33 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const } if (!testOnly) - item->setGeometry(QRect(QPoint(x, y), item->sizeHint())); + { + line.push_back({item, QRect(QPoint(x, y), item->sizeHint())}); + } x = nextX; lineHeight = qMax(lineHeight, size.height()); } + + setLineGeometry(line, lineHeight); + return y + lineHeight - rect.y() + bottom; } + +void FlowLayout::setLineGeometry(const QList> &line, int lineHeight) const +{ + for (const QPair &item : line) + { + QRect g = item.second; + + QWidget *wid = item.first->widget(); + if (wid && wid->sizePolicy().verticalPolicy() & QSizePolicy::ExpandFlag) + g.setHeight(qMax(g.height(), lineHeight)); + + item.first->setGeometry(g); + } +} + int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const { QObject *parent = this->parent(); diff --git a/qrenderdoc/3rdparty/flowlayout/FlowLayout.h b/qrenderdoc/3rdparty/flowlayout/FlowLayout.h index 3e822b35f..f3a8d6f03 100644 --- a/qrenderdoc/3rdparty/flowlayout/FlowLayout.h +++ b/qrenderdoc/3rdparty/flowlayout/FlowLayout.h @@ -1,3 +1,4 @@ +// clang-format off /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. @@ -69,6 +70,7 @@ public: private: int doLayout(const QRect &rect, bool testOnly) const; + void setLineGeometry(const QList> &line, int lineHeight) const; int smartSpacing(QStyle::PixelMetric pm) const; QList itemList;