summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsanchorlayout_p.h
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-06-09 11:49:06 (GMT)
committerEduardo M. Fleury <eduardo.fleury@openbossa.org>2009-07-22 18:04:26 (GMT)
commitf5dc6a07fb9eb99211eb1fa3056a51b933ac3430 (patch)
treeddfb7a70e83024095592c055774581413227cb99 /src/gui/graphicsview/qgraphicsanchorlayout_p.h
parent9d725b4bd16921e6e7967beb3c29681c0c25fc1c (diff)
downloadQt-f5dc6a07fb9eb99211eb1fa3056a51b933ac3430.zip
Qt-f5dc6a07fb9eb99211eb1fa3056a51b933ac3430.tar.gz
Qt-f5dc6a07fb9eb99211eb1fa3056a51b933ac3430.tar.bz2
Simplify the graph by replacing a sequence of anchors with one anchor.
We insert a special SequentialAnchorData. This anchor's min/pref/maxSize will be the sum of the sizes of all the anchors it is replacing. This should make the equation solver faster, and will enable us to do distribution properly just like a linear layout would do.
Diffstat (limited to 'src/gui/graphicsview/qgraphicsanchorlayout_p.h')
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index f2dd796..71c00a2 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -124,16 +124,21 @@ inline QString AnchorVertex::toString() const
Represents an edge (anchor) in the internal graph.
*/
struct AnchorData : public QSimplexVariable {
+ enum Type {
+ Normal = 0,
+ Sequential,
+ Parallel
+ };
AnchorData(qreal minimumSize, qreal preferredSize, qreal maximumSize)
: QSimplexVariable(), minSize(minimumSize), prefSize(preferredSize),
maxSize(maximumSize), sizeAtMinimum(preferredSize),
sizeAtPreferred(preferredSize), sizeAtMaximum(preferredSize),
- skipInPreferred(0) {}
+ skipInPreferred(0), type(Normal) {}
AnchorData(qreal size = 0)
: QSimplexVariable(), minSize(size), prefSize(size), maxSize(size),
sizeAtMinimum(size), sizeAtPreferred(size), sizeAtMaximum(size),
- skipInPreferred(0) {}
+ skipInPreferred(0), type(Normal) {}
inline QString toString() const;
QString name;
@@ -157,6 +162,13 @@ struct AnchorData : public QSimplexVariable {
qreal sizeAtMaximum;
uint skipInPreferred : 1;
+ uint type : 2; // either Normal, Sequential or Parallel
+protected:
+ AnchorData(Type type, qreal size = 0)
+ : QSimplexVariable(), minSize(size), prefSize(size),
+ maxSize(size), sizeAtMinimum(size),
+ sizeAtPreferred(size), sizeAtMaximum(size),
+ skipInPreferred(0), type(type) {}
};
inline QString AnchorData::toString() const
@@ -167,6 +179,18 @@ inline QString AnchorData::toString() const
}
+struct SequentialAnchorData : public AnchorData
+{
+ SequentialAnchorData() : AnchorData(AnchorData::Sequential) {}
+ QVector<AnchorVertex*> m_children; // list of vertices in the sequence
+};
+
+struct ParallelAnchorData : public AnchorData
+{
+ ParallelAnchorData() : AnchorData(AnchorData::Parallel) {}
+ QVector<AnchorData*> children; // list of parallel edges
+};
+
/*!
\internal
@@ -229,6 +253,16 @@ public:
static Orientation edgeOrientation(QGraphicsAnchorLayout::Edge edge);
+ static QGraphicsAnchorLayout::Edge pickEdge(QGraphicsAnchorLayout::Edge edge, Orientation orientation)
+ {
+ if (orientation == Vertical && int(edge) <= 2)
+ return (QGraphicsAnchorLayout::Edge)(edge + 3);
+ else if (orientation == Horizontal && int(edge) >= 3) {
+ return (QGraphicsAnchorLayout::Edge)(edge - 3);
+ }
+ return edge;
+ }
+
// Init methods
void createLayoutEdges();
void deleteLayoutEdges();
@@ -259,6 +293,7 @@ public:
void addChildItem(QGraphicsLayoutItem *child);
// Activation methods
+ void simplifyGraph(Orientation orientation);
void calculateGraphs();
void calculateGraphs(Orientation orientation);
void setAnchorSizeHintsFromItems(Orientation orientation);