diff options
author | Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> | 2009-11-12 01:09:11 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-11-12 21:35:40 (GMT) |
commit | 41cc464ec332033127b88433ffa0a2a990fec83d (patch) | |
tree | a131ebd4395fe9ff64738bc79299968807e1c979 | |
parent | 604b6d9d00e36de7ed516e4fa5c277946216f1e9 (diff) | |
download | Qt-41cc464ec332033127b88433ffa0a2a990fec83d.zip Qt-41cc464ec332033127b88433ffa0a2a990fec83d.tar.gz Qt-41cc464ec332033127b88433ffa0a2a990fec83d.tar.bz2 |
QGAL: fix update size hints logic in parallel anchors
When filling sizeAt* values for parallel anchors, we have to identify
the case when the second anchor in the parallel doesn't have the same
direction as the parallel itself. However, relying on the parallel group
vertices to identify this case is not safe, because after a parallel
group a new vertex simplification can happen.
So, the comparing the 'from' with the first edge is the correct way to
verify whether the second is backwards. Code was fixed to follow that.
Note that, without negative spacing the case "out-of-order" for parallels
is only the trivial case (size == 0).
Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Reviewed-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index a15e473..8520ebd 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -256,8 +256,13 @@ void ParallelAnchorData::updateChildrenSizes() firstEdge->sizeAtPreferred = sizeAtPreferred; firstEdge->sizeAtMaximum = sizeAtMaximum; - const bool secondFwd = (secondEdge->from == from); - if (secondFwd) { + // We have the convention that the first children will define the direction of the + // pararell group. So we can check whether the second edge is "forward" in relation + // to the group if it have the same direction as the first edge. Note that we don't + // use 'this->from' because it might be changed by vertex simplification. + const bool secondForward = (firstEdge->from == secondEdge->from); + + if (secondForward) { secondEdge->sizeAtMinimum = sizeAtMinimum; secondEdge->sizeAtPreferred = sizeAtPreferred; secondEdge->sizeAtMaximum = sizeAtMaximum; @@ -287,10 +292,12 @@ bool ParallelAnchorData::refreshSizeHints_helper(const QLayoutStyleInfo *styleIn // Account for parallel anchors where the second edge is backwards. // We rely on the fact that a forward anchor of sizes min, pref, max is equivalent // to a backwards anchor of size (-max, -pref, -min) - const bool secondFwd = (secondEdge->from == from); - const qreal secondMin = secondFwd ? secondEdge->minSize : -secondEdge->maxSize; - const qreal secondPref = secondFwd ? secondEdge->prefSize : -secondEdge->prefSize; - const qreal secondMax = secondFwd ? secondEdge->maxSize : -secondEdge->minSize; + + // Also see comments in updateChildrenSizes(). + const bool secondForward = (firstEdge->from == secondEdge->from); + const qreal secondMin = secondForward ? secondEdge->minSize : -secondEdge->maxSize; + const qreal secondPref = secondForward ? secondEdge->prefSize : -secondEdge->prefSize; + const qreal secondMax = secondForward ? secondEdge->maxSize : -secondEdge->minSize; minSize = qMax(firstEdge->minSize, secondMin); maxSize = qMin(firstEdge->maxSize, secondMax); |