summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-09-22 17:20:10 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-10-06 09:28:21 (GMT)
commitbfc1a75616e1c96a018349084fae844d7efbc177 (patch)
treed956c9f8b489c0cae43829b2f04caa2b0e4e7f5d /src
parent933e74473a23c0090eaaae9c6122a0e0d192df15 (diff)
downloadQt-bfc1a75616e1c96a018349084fae844d7efbc177.zip
Qt-bfc1a75616e1c96a018349084fae844d7efbc177.tar.gz
Qt-bfc1a75616e1c96a018349084fae844d7efbc177.tar.bz2
QGraphicsAnchorLayout: Add data structures for Expanding size policy
Adding required members for the upcoming support of the QSizePolicy::Expand flag. In this state, running with simplification will probably not work. Signed-off-by: Eduardo M. Fleury <eduardo.fleury@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp44
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h20
2 files changed, 51 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index f75118b..fc3bc8a 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -94,7 +94,9 @@ qreal QGraphicsAnchorPrivate::spacing() const
void AnchorData::refreshSizeHints(qreal effectiveSpacing)
{
- if (!isLayoutAnchor && from->m_item == to->m_item) {
+ isExpanding = 0;
+
+ if (!isLayoutAnchor && (from->m_item == to->m_item)) {
QGraphicsLayoutItem *item = from->m_item;
const QGraphicsAnchorLayoutPrivate::Orientation orient = QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge);
@@ -138,6 +140,9 @@ void AnchorData::refreshSizeHints(qreal effectiveSpacing)
if (policy & QSizePolicy::IgnoreFlag)
prefSize = minSize;
+ if (policy & QSizePolicy::ExpandFlag)
+ isExpanding = 1;
+
bool hasCenter = (from->m_edge == centerEdge || to->m_edge == centerEdge);
if (hasCenter) {
@@ -155,6 +160,7 @@ void AnchorData::refreshSizeHints(qreal effectiveSpacing)
// recalculate and override the values we set here.
sizeAtMinimum = prefSize;
sizeAtPreferred = prefSize;
+ sizeAtExpanding = prefSize;
sizeAtMaximum = prefSize;
} else if (!hasSize) {
@@ -165,6 +171,7 @@ void AnchorData::refreshSizeHints(qreal effectiveSpacing)
sizeAtMinimum = prefSize;
sizeAtPreferred = prefSize;
+ sizeAtExpanding = prefSize;
sizeAtMaximum = prefSize;
}
}
@@ -357,6 +364,12 @@ QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()
: calculateGraphCacheDirty(1)
{
for (int i = 0; i < NOrientations; ++i) {
+ for (int j = 0; j < 3; ++j) {
+ sizeHints[i][j] = -1;
+ }
+ sizeAtExpanding[i] = -1;
+ interpolationProgress[i] = -1;
+
spacings[i] = -1;
graphSimplified[i] = false;
graphHasConflicts[i] = false;
@@ -1649,6 +1662,10 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(
sizeHints[orientation][Qt::PreferredSize] = pref;
sizeHints[orientation][Qt::MaximumSize] = max;
+ // XXX implement Expanding simplex
+ for (int i = 0; i < trunkVariables.count(); ++i)
+ trunkVariables.at(i)->sizeAtExpanding = trunkVariables.at(i)->sizeAtPreferred;
+ sizeAtExpanding[orientation] = pref;
}
} else {
#if 0
@@ -1664,6 +1681,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(
AnchorData *ad = trunkPath.positives.toList()[0];
ad->sizeAtMinimum = ad->minSize;
ad->sizeAtPreferred = ad->prefSize;
+ ad->sizeAtExpanding = ad->prefSize;
ad->sizeAtMaximum = ad->maxSize;
// Propagate
@@ -1672,6 +1690,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(
sizeHints[orientation][Qt::MinimumSize] = ad->sizeAtMinimum;
sizeHints[orientation][Qt::PreferredSize] = ad->sizeAtPreferred;
sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum;
+ sizeAtExpanding[orientation] = ad->sizeAtPreferred;
}
// Delete the constraints, we won't use them anymore.
@@ -1701,6 +1720,7 @@ void QGraphicsAnchorLayoutPrivate::calculateGraphs(
AnchorData *ad = partVariables[j];
Q_ASSERT(ad);
ad->sizeAtMinimum = ad->sizeAtPreferred;
+ ad->sizeAtExpanding = ad->sizeAtPreferred;
ad->sizeAtMaximum = ad->sizeAtPreferred;
ad->updateChildrenSizes();
}
@@ -2058,9 +2078,13 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
interpolationInterval[orientation] = MinToPreferred;
lower = sizeHints[orientation][Qt::MinimumSize];
upper = sizeHints[orientation][Qt::PreferredSize];
- } else {
- interpolationInterval[orientation] = PreferredToMax;
+ } else if (current < sizeAtExpanding[orientation]) {
+ interpolationInterval[orientation] = PreferredToExpanding;
lower = sizeHints[orientation][Qt::PreferredSize];
+ upper = sizeAtExpanding[orientation];
+ } else {
+ interpolationInterval[orientation] = ExpandingToMax;
+ lower = sizeAtExpanding[orientation];
upper = sizeHints[orientation][Qt::MaximumSize];
}
@@ -2075,11 +2099,12 @@ void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
\internal
Calculate the current Edge size based on the current Layout size and the
- size the edge is supposed to have when:
+ size the edge is supposed to have when the layout is at its:
- - the layout is at its minimum size.
- - the layout is at its preferred size.
- - the layout is at its maximum size.
+ - minimum size,
+ - preferred size,
+ - size when all expanding anchors are expanded,
+ - maximum size.
These three key values are calculated in advance using linear
programming (more expensive) or the simplification algorithm, then
@@ -2099,8 +2124,11 @@ void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base,
if (interpolationInterval[orientation] == MinToPreferred) {
lower = edge->sizeAtMinimum;
upper = edge->sizeAtPreferred;
- } else {
+ } else if (interpolationInterval[orientation] == PreferredToExpanding) {
lower = edge->sizeAtPreferred;
+ upper = edge->sizeAtExpanding;
+ } else {
+ lower = edge->sizeAtExpanding;
upper = edge->sizeAtMaximum;
}
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index c86bfa3..4c6c2aa 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -153,7 +153,8 @@ struct AnchorData : public QSimplexVariable {
: QSimplexVariable(), from(0), to(0),
minSize(minimumSize), prefSize(preferredSize),
maxSize(maximumSize), sizeAtMinimum(preferredSize),
- sizeAtPreferred(preferredSize), sizeAtMaximum(preferredSize),
+ sizeAtPreferred(preferredSize), sizeAtExpanding(preferredSize),
+ sizeAtMaximum(preferredSize),
graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(true),
isLayoutAnchor(false) {}
@@ -161,7 +162,8 @@ struct AnchorData : public QSimplexVariable {
AnchorData(qreal size)
: QSimplexVariable(), from(0), to(0),
minSize(size), prefSize(size), maxSize(size),
- sizeAtMinimum(size), sizeAtPreferred(size), sizeAtMaximum(size),
+ sizeAtMinimum(size), sizeAtPreferred(size), sizeAtExpanding(size),
+ sizeAtMaximum(size),
graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(true),
isLayoutAnchor(false) {}
@@ -169,7 +171,8 @@ struct AnchorData : public QSimplexVariable {
AnchorData()
: QSimplexVariable(), from(0), to(0),
minSize(0), prefSize(0), maxSize(0),
- sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0),
+ sizeAtMinimum(0), sizeAtPreferred(0), sizeAtExpanding(0),
+ sizeAtMaximum(0),
graphicsAnchor(0),
skipInPreferred(0), type(Normal), hasSize(false),
isLayoutAnchor(false) {}
@@ -192,6 +195,7 @@ struct AnchorData : public QSimplexVariable {
maxSize = size;
sizeAtMinimum = size;
sizeAtPreferred = size;
+ sizeAtExpanding = size;
sizeAtMaximum = size;
hasSize = true;
}
@@ -218,6 +222,7 @@ struct AnchorData : public QSimplexVariable {
// calculated by the Simplex solver based on the current layout setup.
qreal sizeAtMinimum;
qreal sizeAtPreferred;
+ qreal sizeAtExpanding;
qreal sizeAtMaximum;
QGraphicsAnchor *graphicsAnchor;
@@ -225,12 +230,15 @@ struct AnchorData : public QSimplexVariable {
uint type : 2; // either Normal, Sequential or Parallel
uint hasSize : 1; // if false, get size from style.
uint isLayoutAnchor : 1; // if this anchor is connected to a layout 'edge'
+ uint isExpanding : 1; // if true, expands before other anchors
+
protected:
AnchorData(Type type, qreal size = 0)
: QSimplexVariable(), from(0), to(0),
minSize(size), prefSize(size),
maxSize(size), sizeAtMinimum(size),
- sizeAtPreferred(size), sizeAtMaximum(size),
+ sizeAtPreferred(size), sizeAtExpanding(size),
+ sizeAtMaximum(size),
graphicsAnchor(0),
skipInPreferred(0), type(type), hasSize(true),
isLayoutAnchor(false) {}
@@ -355,7 +363,8 @@ public:
// Interval represents which interpolation interval are we operating in.
enum Interval {
MinToPreferred = 0,
- PreferredToMax
+ PreferredToExpanding,
+ ExpandingToMax
};
// Several structures internal to the layout are duplicated to handle
@@ -496,6 +505,7 @@ public:
qreal spacings[NOrientations];
// Size hints from simplex engine
qreal sizeHints[2][3];
+ qreal sizeAtExpanding[2];
// Items
QVector<QGraphicsLayoutItem *> items;