summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout_p.h
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-08-14 21:02:21 (GMT)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-08-14 21:02:21 (GMT)
commit916a74ef9703da783894c4a49b4897ef57cc474c (patch)
tree8b3e2fa023376d9fb74425b1f91ef567fc9a5208 /src/gui/graphicsview/qgraphicsanchorlayout_p.h
parent6bd756353d1be7eadcf56f9c8415283d0d1c4cc3 (diff)
downloadQt-916a74ef9703da783894c4a49b4897ef57cc474c.zip
Qt-916a74ef9703da783894c4a49b4897ef57cc474c.tar.gz
Qt-916a74ef9703da783894c4a49b4897ef57cc474c.tar.bz2
QGraphicsAnchorLayout: use a recursive approach for size hints
Bring back the refreshSizeHints() now that we have locally the necessary information to get the size hints given an arbitrary anchor data. We also created a bit to set whether the AnchorData is an anchor of a layout (i.e. connects the layout with something else) or not. This costs one pointer more in the AnchorData, but simplifies a good deal of code and avoid traversing the graph to get this information back, so I think it's worthwhile. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout_p.h')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index eb1f8f6..ce4eaf7 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -134,21 +134,25 @@ struct AnchorData : public QSimplexVariable {
minSize(minimumSize), prefSize(preferredSize),
maxSize(maximumSize), sizeAtMinimum(preferredSize),
sizeAtPreferred(preferredSize), sizeAtMaximum(preferredSize),
- skipInPreferred(0), type(Normal), hasSize(true) {}
+ skipInPreferred(0), type(Normal), hasSize(true),
+ isLayoutAnchor(false) {}
AnchorData(qreal size)
: QSimplexVariable(), from(0), to(0),
minSize(size), prefSize(size), maxSize(size),
sizeAtMinimum(size), sizeAtPreferred(size), sizeAtMaximum(size),
- skipInPreferred(0), type(Normal), hasSize(true) {}
+ skipInPreferred(0), type(Normal), hasSize(true),
+ isLayoutAnchor(false) {}
AnchorData()
: QSimplexVariable(), from(0), to(0),
minSize(0), prefSize(0), maxSize(0),
sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0),
- skipInPreferred(0), type(Normal), hasSize(false) {}
+ skipInPreferred(0), type(Normal), hasSize(false),
+ isLayoutAnchor(false) {}
virtual void updateChildrenSizes() { };
+ virtual void refreshSizeHints(qreal effectiveSpacing);
void dump(int indent = 2);
@@ -175,15 +179,17 @@ struct AnchorData : public QSimplexVariable {
qreal sizeAtMaximum;
uint skipInPreferred : 1;
- uint type : 2; // either Normal, Sequential or Parallel
- uint hasSize : 1; // if false, get size from style.
+ 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'
protected:
AnchorData(Type type, qreal size = 0)
: QSimplexVariable(), from(0), to(0),
minSize(size), prefSize(size),
maxSize(size), sizeAtMinimum(size),
sizeAtPreferred(size), sizeAtMaximum(size),
- skipInPreferred(0), type(type), hasSize(true) {}
+ skipInPreferred(0), type(type), hasSize(true),
+ isLayoutAnchor(false) {}
};
inline QString AnchorData::toString() const
@@ -202,6 +208,7 @@ struct SequentialAnchorData : public AnchorData
}
virtual void updateChildrenSizes();
+ virtual void refreshSizeHints(qreal effectiveSpacing);
void setVertices(const QVector<AnchorVertex*> &vertices)
{
@@ -229,6 +236,7 @@ struct ParallelAnchorData : public AnchorData
}
virtual void updateChildrenSizes();
+ virtual void refreshSizeHints(qreal effectiveSpacing);
AnchorData* firstEdge;
AnchorData* secondEdge;