mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Handle Expanding policies in flow layouts
This commit is contained in:
+26
-1
@@ -194,6 +194,8 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
||||
}
|
||||
}
|
||||
|
||||
QList<QPair<QLayoutItem *, QRect>> 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<QPair<QLayoutItem *, QRect>> &line, int lineHeight) const
|
||||
{
|
||||
for (const QPair<QLayoutItem *, QRect> &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();
|
||||
|
||||
+2
@@ -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<QPair<QLayoutItem *, QRect>> &line, int lineHeight) const;
|
||||
int smartSpacing(QStyle::PixelMetric pm) const;
|
||||
|
||||
QList<QLayoutItem *> itemList;
|
||||
|
||||
Reference in New Issue
Block a user