diff options
author | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-11-05 14:54:33 (GMT) |
---|---|---|
committer | Eduardo M. Fleury <eduardo.fleury@openbossa.org> | 2009-11-27 19:19:08 (GMT) |
commit | 666576b39da04f4185036d9eee1b8edeae10ccf7 (patch) | |
tree | d38e6d95f6ff8610da9b9bfc7ffd565f7f82f8fe /src/gui/graphicsview | |
parent | 33116cf737b6ded48ccbb14af401ecb18adeec96 (diff) | |
download | Qt-666576b39da04f4185036d9eee1b8edeae10ccf7.zip Qt-666576b39da04f4185036d9eee1b8edeae10ccf7.tar.gz Qt-666576b39da04f4185036d9eee1b8edeae10ccf7.tar.bz2 |
QGAL: Support for out-of-order sequential anchors
Now sequential anchors account for the fact they may be composed of
anchors with different directions.
Both refreshSizeHints and updateChildrenSizes have been updated
to support this situation.
Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index 3154630..1f1769f 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -416,12 +416,27 @@ void SequentialAnchorData::updateChildrenSizes() const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> maxFactor = getFactor(sizeAtMaximum, minSize, prefSize, maxSize); + // XXX This is not safe if Vertex simplification takes place after the sequential + // anchor is created. In that case, "prev" will be a group-vertex, different from + // "from" or "to", that _contains_ one of them. + AnchorVertex *prev = from; + for (int i = 0; i < m_edges.count(); ++i) { AnchorData *e = m_edges.at(i); - e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->prefSize, e->maxSize); - e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->prefSize, e->maxSize); - e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->prefSize, e->maxSize); + const bool edgeIsForward = (e->from == prev); + if (edgeIsForward) { + e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->prefSize, e->maxSize); + e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->prefSize, e->maxSize); + e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->prefSize, e->maxSize); + prev = e->to; + } else { + Q_ASSERT(prev == e->to); + e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->prefSize, e->minSize); + e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->prefSize, e->minSize); + e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->prefSize, e->minSize); + prev = e->from; + } e->updateChildrenSizes(); } @@ -433,11 +448,24 @@ void SequentialAnchorData::calculateSizeHints() prefSize = 0; maxSize = 0; + AnchorVertex *prev = from; + for (int i = 0; i < m_edges.count(); ++i) { AnchorData *edge = m_edges.at(i); - minSize += edge->minSize; - prefSize += edge->prefSize; - maxSize += edge->maxSize; + + const bool edgeIsForward = (edge->from == prev); + if (edgeIsForward) { + minSize += edge->minSize; + prefSize += edge->prefSize; + maxSize += edge->maxSize; + prev = edge->to; + } else { + Q_ASSERT(prev == edge->to); + minSize -= edge->maxSize; + prefSize -= edge->prefSize; + maxSize -= edge->minSize; + prev = edge->from; + } } // See comment in AnchorData::refreshSizeHints() about sizeAt* values |