summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-11-12 01:09:11 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-11-18 03:13:19 (GMT)
commit05cd0e984c6fc604f379990f4ed8a137033628f0 (patch)
tree109feb04a9e9efc2de4762f2197ac71646e186b5 /src/gui
parentf22b7cfd35b9e2ef20ee19aebaad8915b474057e (diff)
downloadQt-05cd0e984c6fc604f379990f4ed8a137033628f0.zip
Qt-05cd0e984c6fc604f379990f4ed8a137033628f0.tar.gz
Qt-05cd0e984c6fc604f379990f4ed8a137033628f0.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> (cherry picked from commit 41cc464ec332033127b88433ffa0a2a990fec83d)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp19
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);