diff options
author | Liang Qi <liang.qi@qt.io> | 2016-11-23 10:49:37 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-11-23 10:49:37 +0100 |
commit | 5d4cbf4094c9b290626aab89e4bd92edd29ce49f (patch) | |
tree | eac893652c724f057fba493688b16e212fd844dd /src/quick/items/qquickanchors.cpp | |
parent | 13cf5f02ce788f19a73e5d5c3da76e57291761a5 (diff) | |
parent | 07cde200e55ee03bf9e2f9af89c20f91072deccc (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
src/qml/jsruntime/qv4object_p.h
Change-Id: Iff4d3aba7710a999b8befdc493cbe959e1ce02f9
Diffstat (limited to 'src/quick/items/qquickanchors.cpp')
-rw-r--r-- | src/quick/items/qquickanchors.cpp | 127 |
1 files changed, 64 insertions, 63 deletions
diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp index a7a4a2b882..4162314cd3 100644 --- a/src/quick/items/qquickanchors.cpp +++ b/src/quick/items/qquickanchors.cpp @@ -617,74 +617,75 @@ void QQuickAnchorsPrivate::updateVerticalAnchors() if (fill || centerIn || !isItemComplete()) return; - if (updatingVerticalAnchor < 2) { - ++updatingVerticalAnchor; - if (usedAnchors & QQuickAnchors::TopAnchor) { - //Handle stretching - bool invalid = true; + if (Q_UNLIKELY(updatingVerticalAnchor > 1)) { + // ### Make this certain :) + qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on vertical anchor."); + return; + } + + ++updatingVerticalAnchor; + if (usedAnchors & QQuickAnchors::TopAnchor) { + //Handle stretching + bool invalid = true; + qreal height = 0.0; + if (usedAnchors & QQuickAnchors::BottomAnchor) { + invalid = calcStretch(topAnchorItem, topAnchorLine, + bottomAnchorItem, bottomAnchorLine, + topMargin, -bottomMargin, QQuickAnchors::TopAnchor, height); + } else if (usedAnchors & QQuickAnchors::VCenterAnchor) { + invalid = calcStretch(topAnchorItem, topAnchorLine, + vCenterAnchorItem, vCenterAnchorLine, + topMargin, vCenterOffset, QQuickAnchors::TopAnchor, height); + height *= 2; + } + if (!invalid) + setItemHeight(height); + + //Handle top + if (topAnchorItem == readParentItem(item)) { + setItemY(adjustedPosition(topAnchorItem, topAnchorLine) + topMargin); + } else if (readParentItem(topAnchorItem) == readParentItem(item)) { + setItemY(position(topAnchorItem, topAnchorLine) + topMargin); + } + } else if (usedAnchors & QQuickAnchors::BottomAnchor) { + //Handle stretching (top + bottom case is handled above) + if (usedAnchors & QQuickAnchors::VCenterAnchor) { qreal height = 0.0; - if (usedAnchors & QQuickAnchors::BottomAnchor) { - invalid = calcStretch(topAnchorItem, topAnchorLine, - bottomAnchorItem, bottomAnchorLine, - topMargin, -bottomMargin, QQuickAnchors::TopAnchor, height); - } else if (usedAnchors & QQuickAnchors::VCenterAnchor) { - invalid = calcStretch(topAnchorItem, topAnchorLine, - vCenterAnchorItem, vCenterAnchorLine, - topMargin, vCenterOffset, QQuickAnchors::TopAnchor, height); - height *= 2; - } + bool invalid = calcStretch(vCenterAnchorItem, vCenterAnchorLine, + bottomAnchorItem, bottomAnchorLine, + vCenterOffset, -bottomMargin, QQuickAnchors::TopAnchor, + height); if (!invalid) - setItemHeight(height); - - //Handle top - if (topAnchorItem == readParentItem(item)) { - setItemY(adjustedPosition(topAnchorItem, topAnchorLine) + topMargin); - } else if (readParentItem(topAnchorItem) == readParentItem(item)) { - setItemY(position(topAnchorItem, topAnchorLine) + topMargin); - } - } else if (usedAnchors & QQuickAnchors::BottomAnchor) { - //Handle stretching (top + bottom case is handled above) - if (usedAnchors & QQuickAnchors::VCenterAnchor) { - qreal height = 0.0; - bool invalid = calcStretch(vCenterAnchorItem, vCenterAnchorLine, - bottomAnchorItem, bottomAnchorLine, - vCenterOffset, -bottomMargin, QQuickAnchors::TopAnchor, - height); - if (!invalid) - setItemHeight(height*2); - } + setItemHeight(height*2); + } - //Handle bottom - if (bottomAnchorItem == readParentItem(item)) { - setItemY(adjustedPosition(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin); - } else if (readParentItem(bottomAnchorItem) == readParentItem(item)) { - setItemY(position(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin); - } - } else if (usedAnchors & QQuickAnchors::VCenterAnchor) { - //(stetching handled above) - - //Handle vCenter - if (vCenterAnchorItem == readParentItem(item)) { - setItemY(adjustedPosition(vCenterAnchorItem, vCenterAnchorLine) - - vcenter(item) + vCenterOffset); - } else if (readParentItem(vCenterAnchorItem) == readParentItem(item)) { - setItemY(position(vCenterAnchorItem, vCenterAnchorLine) - vcenter(item) + vCenterOffset); - } - } else if (usedAnchors & QQuickAnchors::BaselineAnchor) { - //Handle baseline - if (baselineAnchorItem == readParentItem(item)) { - setItemY(adjustedPosition(baselineAnchorItem, baselineAnchorLine) - - readBaselineOffset(item) + baselineOffset); - } else if (readParentItem(baselineAnchorItem) == readParentItem(item)) { - setItemY(position(baselineAnchorItem, baselineAnchorLine) - - readBaselineOffset(item) + baselineOffset); - } + //Handle bottom + if (bottomAnchorItem == readParentItem(item)) { + setItemY(adjustedPosition(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin); + } else if (readParentItem(bottomAnchorItem) == readParentItem(item)) { + setItemY(position(bottomAnchorItem, bottomAnchorLine) - readHeight(item) - bottomMargin); + } + } else if (usedAnchors & QQuickAnchors::VCenterAnchor) { + //(stetching handled above) + + //Handle vCenter + if (vCenterAnchorItem == readParentItem(item)) { + setItemY(adjustedPosition(vCenterAnchorItem, vCenterAnchorLine) + - vcenter(item) + vCenterOffset); + } else if (readParentItem(vCenterAnchorItem) == readParentItem(item)) { + setItemY(position(vCenterAnchorItem, vCenterAnchorLine) - vcenter(item) + vCenterOffset); + } + } else if (usedAnchors & QQuickAnchors::BaselineAnchor) { + //Handle baseline + if (baselineAnchorItem == readParentItem(item)) { + setItemY(adjustedPosition(baselineAnchorItem, baselineAnchorLine) + - readBaselineOffset(item) + baselineOffset); + } else if (readParentItem(baselineAnchorItem) == readParentItem(item)) { + setItemY(position(baselineAnchorItem, baselineAnchorLine) + - readBaselineOffset(item) + baselineOffset); } - --updatingVerticalAnchor; - } else { - // ### Make this certain :) - qmlInfo(item) << QQuickAnchors::tr("Possible anchor loop detected on vertical anchor."); } + --updatingVerticalAnchor; } static inline QQuickAnchors::Anchor reverseAnchorLine(QQuickAnchors::Anchor anchorLine) |