summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp24
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.h7
2 files changed, 31 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index afe60a1..4844748 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -45,6 +45,30 @@
#include "qgraphicsanchorlayout_p.h"
+void ParallelAnchorData::updateChildrenSizes()
+{
+ firstEdge->sizeAtMinimum = secondEdge->sizeAtMinimum = sizeAtMinimum;
+ firstEdge->sizeAtPreferred = secondEdge->sizeAtPreferred = sizeAtPreferred;
+ firstEdge->sizeAtMaximum = secondEdge->sizeAtMaximum = sizeAtMaximum;
+
+ firstEdge->updateChildrenSizes();
+ secondEdge->updateChildrenSizes();
+}
+
+void SequentialAnchorData::updateChildrenSizes()
+{
+ qreal minFactor = sizeAtMinimum / minSize;
+ qreal prefFactor = sizeAtPreferred / prefSize;
+ qreal maxFactor = sizeAtMaximum / maxSize;
+
+ for (int i = 0; i < m_edges.count(); ++i) {
+ m_edges[i]->sizeAtMinimum = m_edges[i]->minSize * minFactor;
+ m_edges[i]->sizeAtPreferred = m_edges[i]->prefSize * prefFactor;
+ m_edges[i]->sizeAtMaximum = m_edges[i]->maxSize * maxFactor;
+ m_edges[i]->updateChildrenSizes();
+ }
+}
+
QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const
{
// Calculate
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
index 2f1aa97..1c0f737 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.h
@@ -145,6 +145,8 @@ struct AnchorData : public QSimplexVariable {
sizeAtMinimum(0), sizeAtPreferred(0), sizeAtMaximum(0),
skipInPreferred(0), type(Normal), hasSize(false) {}
+ virtual void updateChildrenSizes() { };
+
inline QString toString() const;
QString name;
@@ -192,6 +194,8 @@ struct SequentialAnchorData : public AnchorData
name = QLatin1String("SequentialAnchorData");
}
+ virtual void updateChildrenSizes();
+
void setVertices(const QVector<AnchorVertex*> &vertices)
{
m_children = vertices;
@@ -212,6 +216,9 @@ struct ParallelAnchorData : public AnchorData
origin = first->origin;
name = QString::fromAscii("%1 | %2").arg(first->toString(), second->toString());
}
+
+ virtual void updateChildrenSizes();
+
AnchorData* firstEdge;
AnchorData* secondEdge;
};