diff options
author | Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> | 2009-08-13 18:07:34 (GMT) |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> | 2009-08-13 18:07:34 (GMT) |
commit | 548583f449432363fad8fe547ce073bb754d46be (patch) | |
tree | 815ff67f743f7901488c0c4dbd30eead7bfa09d3 | |
parent | 114e4b6ca9a1871f75dc5b9d443ab1e344eb99af (diff) | |
download | Qt-548583f449432363fad8fe547ce073bb754d46be.zip Qt-548583f449432363fad8fe547ce073bb754d46be.tar.gz Qt-548583f449432363fad8fe547ce073bb754d46be.tar.bz2 |
QGraphicsAnchorLayout: fix merging of preferredSizeHint
In simplification, the preferred size of a parallel group should get the
maximum preferred size (and bound it to the maximum size). This follows
the principle that for an layout item: 'growing is better than
shrinking', and is consistent with what our linear program also do.
This patch also make sure that the sizeAt* are properly initialized to
the preferred size, the idea is if there's no restriction upon an
anchor, it'll keep it's preferred size no matter what.
Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 7e0541e..d878722 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -57,11 +57,22 @@ void ParallelAnchorData::updateChildrenSizes() void ParallelAnchorData::refreshSizeHints() { + // ### should we warn if the parallel connection is invalid? + // e.g. 1-2-3 with 10-20-30, the minimum of the latter is + // bigger than the maximum of the former. + firstEdge->refreshSizeHints(); secondEdge->refreshSizeHints(); + minSize = qMax(firstEdge->minSize, secondEdge->minSize); - prefSize = qMin(firstEdge->prefSize, secondEdge->prefSize); maxSize = qMin(firstEdge->maxSize, secondEdge->maxSize); + + prefSize = qMax(firstEdge->prefSize, secondEdge->prefSize); + prefSize = qMin(prefSize, maxSize); + + sizeAtMinimum = prefSize; + sizeAtPreferred = prefSize; + sizeAtMaximum = prefSize; } void SequentialAnchorData::updateChildrenSizes() @@ -90,6 +101,10 @@ void SequentialAnchorData::refreshSizeHints() prefSize += edge->prefSize; maxSize += edge->maxSize; } + + sizeAtMinimum = prefSize; + sizeAtPreferred = prefSize; + sizeAtMaximum = prefSize; } void AnchorData::dump(int indent) { @@ -251,8 +266,11 @@ static void simplifySequentialChunk(Graph<AnchorVertex, AnchorData> *graph, if (AnchorData *oldAnchor = graph->takeEdge(before, after)) { newAnchor = new ParallelAnchorData(oldAnchor, sequence); min = qMax(oldAnchor->minSize, sequence->minSize); - pref = qMax(oldAnchor->prefSize, sequence->prefSize); max = qMin(oldAnchor->maxSize, sequence->maxSize); + + pref = qMax(oldAnchor->prefSize, sequence->prefSize); + pref = qMin(pref, max); + newAnchor->minSize = min; newAnchor->prefSize = pref; newAnchor->maxSize = max; |