summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp48
-rw-r--r--src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp52
-rw-r--r--src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.h8
-rw-r--r--src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp60
-rw-r--r--src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp104
-rw-r--r--src/plugins/qmldesigner/components/formeditor/snapper.cpp64
-rw-r--r--src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp108
-rw-r--r--src/plugins/qmldesigner/designercore/designercore-lib.pri2
-rw-r--r--src/plugins/qmldesigner/designercore/include/anchorline.h60
-rw-r--r--src/plugins/qmldesigner/designercore/include/qmlanchors.h95
-rw-r--r--src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h18
-rw-r--r--src/plugins/qmldesigner/designercore/include/qmlitemnode.h1
-rw-r--r--src/plugins/qmldesigner/designercore/model/anchorline.cpp69
-rw-r--r--src/plugins/qmldesigner/designercore/model/qmlanchors.cpp223
-rw-r--r--src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp12
15 files changed, 497 insertions, 427 deletions
diff --git a/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp b/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp
index ac5c69af4b..54aa062f3f 100644
--- a/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/anchorindicator.cpp
@@ -98,28 +98,28 @@ void AnchorIndicator::setItems(const QList<FormEditorItem *> &itemList)
if (!sourceQmlItemNode.modelNode().isRootNode()) {
QmlAnchors qmlAnchors = sourceQmlItemNode.anchors();
- if (qmlAnchors.modelHasAnchor(AnchorLine::Top)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineTop)) {
m_indicatorTopShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Top),
- qmlAnchors.modelAnchor(AnchorLine::Top));
+ m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineTop),
+ qmlAnchors.modelAnchor(AnchorLineTop));
}
- if (qmlAnchors.modelHasAnchor(AnchorLine::Bottom)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineBottom)) {
m_indicatorBottomShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Bottom),
- qmlAnchors.modelAnchor(AnchorLine::Bottom));
+ m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineBottom),
+ qmlAnchors.modelAnchor(AnchorLineBottom));
}
- if (qmlAnchors.modelHasAnchor(AnchorLine::Left)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineLeft)) {
m_indicatorLeftShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Left),
- qmlAnchors.modelAnchor(AnchorLine::Left));
+ m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineLeft),
+ qmlAnchors.modelAnchor(AnchorLineLeft));
}
- if (qmlAnchors.modelHasAnchor(AnchorLine::Right)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineRight)) {
m_indicatorRightShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Right),
- qmlAnchors.modelAnchor(AnchorLine::Right));
+ m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineRight),
+ qmlAnchors.modelAnchor(AnchorLineRight));
}
}
}
@@ -133,38 +133,38 @@ void AnchorIndicator::updateItems(const QList<FormEditorItem *> &itemList)
if (!sourceQmlItemNode.modelNode().isRootNode()) {
QmlAnchors qmlAnchors = formEditorItem->qmlItemNode().anchors();
- if (qmlAnchors.modelHasAnchor(AnchorLine::Top)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineTop)) {
if (m_indicatorTopShape.isNull())
m_indicatorTopShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Top),
- qmlAnchors.modelAnchor(AnchorLine::Top));
+ m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineTop),
+ qmlAnchors.modelAnchor(AnchorLineTop));
} else {
delete m_indicatorTopShape;
}
- if (qmlAnchors.modelHasAnchor(AnchorLine::Bottom)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineBottom)) {
if (m_indicatorBottomShape.isNull())
m_indicatorBottomShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Bottom),
- qmlAnchors.modelAnchor(AnchorLine::Bottom));
+ m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineBottom),
+ qmlAnchors.modelAnchor(AnchorLineBottom));
} else {
delete m_indicatorBottomShape;
}
- if (qmlAnchors.modelHasAnchor(AnchorLine::Left)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineLeft)) {
if (m_indicatorLeftShape.isNull())
m_indicatorLeftShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Left),
- qmlAnchors.modelAnchor(AnchorLine::Left));
+ m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineLeft),
+ qmlAnchors.modelAnchor(AnchorLineLeft));
} else {
delete m_indicatorLeftShape;
}
- if (qmlAnchors.modelHasAnchor(AnchorLine::Right)) {
+ if (qmlAnchors.modelHasAnchor(AnchorLineRight)) {
if (m_indicatorRightShape.isNull())
m_indicatorRightShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
- m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Right),
- qmlAnchors.modelAnchor(AnchorLine::Right));
+ m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLineRight),
+ qmlAnchors.modelAnchor(AnchorLineRight));
} else {
delete m_indicatorRightShape;
}
diff --git a/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp b/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp
index 635c896a05..7bbf8d6192 100644
--- a/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.cpp
@@ -40,16 +40,16 @@ AnchorIndicatorGraphicsItem::AnchorIndicatorGraphicsItem(QGraphicsItem *parent)
setZValue(-3);
}
-int startAngleForAnchorLine(const AnchorLine::Type &anchorLineType)
+int startAngleForAnchorLine(const AnchorLineType &anchorLineType)
{
switch (anchorLineType) {
- case AnchorLine::Top:
+ case AnchorLineTop:
return 0;
- case AnchorLine::Bottom:
+ case AnchorLineBottom:
return 180 * 16;
- case AnchorLine::Left:
+ case AnchorLineLeft:
return 90 * 16;
- case AnchorLine::Right:
+ case AnchorLineRight:
return 270 * 16;
default:
return 0;
@@ -107,7 +107,7 @@ QRectF AnchorIndicatorGraphicsItem::boundingRect() const
return m_boundingRect;
}
-static QPointF createParentAnchorPoint(const QmlItemNode &parentQmlItemNode, AnchorLine::Type anchorLineType, const QmlItemNode &childQmlItemNode)
+static QPointF createParentAnchorPoint(const QmlItemNode &parentQmlItemNode, AnchorLineType anchorLineType, const QmlItemNode &childQmlItemNode)
{
QRectF parentBoundingRect = parentQmlItemNode.instanceSceneTransform().mapRect(parentQmlItemNode.instanceBoundingRect().adjusted(0., 0., 1., 1.));
QRectF childBoundingRect = childQmlItemNode.instanceSceneTransform().mapRect(childQmlItemNode.instanceBoundingRect().adjusted(0., 0., 1., 1.));
@@ -115,16 +115,16 @@ static QPointF createParentAnchorPoint(const QmlItemNode &parentQmlItemNode, Anc
QPointF anchorPoint;
switch (anchorLineType) {
- case AnchorLine::Top:
+ case AnchorLineTop:
anchorPoint = QPointF(childBoundingRect.center().x(), parentBoundingRect.top());
break;
- case AnchorLine::Bottom:
+ case AnchorLineBottom:
anchorPoint = QPointF(childBoundingRect.center().x(), parentBoundingRect.bottom());
break;
- case AnchorLine::Left:
+ case AnchorLineLeft:
anchorPoint = QPointF(parentBoundingRect.left(), childBoundingRect.center().y());
break;
- case AnchorLine::Right:
+ case AnchorLineRight:
anchorPoint = QPointF(parentBoundingRect.right(), childBoundingRect.center().y());
break;
default:
@@ -134,23 +134,23 @@ static QPointF createParentAnchorPoint(const QmlItemNode &parentQmlItemNode, Anc
return anchorPoint;
}
-static QPointF createAnchorPoint(const QmlItemNode &qmlItemNode, AnchorLine::Type anchorLineType)
+static QPointF createAnchorPoint(const QmlItemNode &qmlItemNode, AnchorLineType anchorLineType)
{
QRectF boundingRect = qmlItemNode.instanceBoundingRect().adjusted(0., 0., 1., 1.);
QPointF anchorPoint;
switch (anchorLineType) {
- case AnchorLine::Top:
+ case AnchorLineTop:
anchorPoint = QPointF(boundingRect.center().x(), boundingRect.top());
break;
- case AnchorLine::Bottom:
+ case AnchorLineBottom:
anchorPoint = QPointF(boundingRect.center().x(), boundingRect.bottom());
break;
- case AnchorLine::Left:
+ case AnchorLineLeft:
anchorPoint = QPointF(boundingRect.left(), boundingRect.center().y());
break;
- case AnchorLine::Right:
+ case AnchorLineRight:
anchorPoint = QPointF(boundingRect.right(), boundingRect.center().y());
break;
default:
@@ -160,17 +160,17 @@ static QPointF createAnchorPoint(const QmlItemNode &qmlItemNode, AnchorLine::Typ
return qmlItemNode.instanceSceneTransform().map(anchorPoint);
}
-static QPointF createControlPoint(const QPointF &firstEditPoint, AnchorLine::Type anchorLineType, const QPointF &secondEditPoint)
+static QPointF createControlPoint(const QPointF &firstEditPoint, AnchorLineType anchorLineType, const QPointF &secondEditPoint)
{
QPointF controlPoint = firstEditPoint;
switch (anchorLineType) {
- case AnchorLine::Top:
- case AnchorLine::Bottom:
+ case AnchorLineTop:
+ case AnchorLineBottom:
controlPoint.ry() += (secondEditPoint.y() - firstEditPoint.y()) / 2.0;
break;
- case AnchorLine::Left:
- case AnchorLine::Right:
+ case AnchorLineLeft:
+ case AnchorLineRight:
controlPoint.rx() += (secondEditPoint.x() - firstEditPoint.x()) / 2.0;
break;
default:
@@ -185,19 +185,19 @@ static void updateAnchorLinePoints(QPointF *firstPoint, QPointF *secondPoint, co
QRectF boundingRectangle = anchorLine.qmlItemNode().instanceBoundingRect().adjusted(0., 0., 1., 1.);
switch (anchorLine.type()) {
- case AnchorLine::Top:
+ case AnchorLineTop:
*firstPoint = boundingRectangle.topLeft();
*secondPoint = boundingRectangle.topRight();
break;
- case AnchorLine::Bottom:
+ case AnchorLineBottom:
*firstPoint = boundingRectangle.bottomLeft();
*secondPoint = boundingRectangle.bottomRight();
break;
- case AnchorLine::Left:
+ case AnchorLineLeft:
*firstPoint = boundingRectangle.topLeft();
*secondPoint = boundingRectangle.bottomLeft();
break;
- case AnchorLine::Right:
+ case AnchorLineRight:
*firstPoint = boundingRectangle.topRight();
*secondPoint = boundingRectangle.bottomRight();
break;
@@ -248,12 +248,12 @@ void AnchorIndicatorGraphicsItem::updateBoundingRect()
m_boundingRect = controlPolygon.boundingRect().adjusted(-10., -10., 10., 10.);
}
-AnchorLine::Type AnchorIndicatorGraphicsItem::sourceAnchorLineType() const
+AnchorLineType AnchorIndicatorGraphicsItem::sourceAnchorLineType() const
{
return m_sourceAnchorLineType;
}
-void AnchorIndicatorGraphicsItem::setSourceAnchorLineType(const AnchorLine::Type &sourceAnchorLineType)
+void AnchorIndicatorGraphicsItem::setSourceAnchorLineType(const AnchorLineType &sourceAnchorLineType)
{
m_sourceAnchorLineType = sourceAnchorLineType;
}
diff --git a/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.h b/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.h
index b861c25d9b..b0b118ee04 100644
--- a/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.h
+++ b/src/plugins/qmldesigner/components/formeditor/anchorindicatorgraphicsitem.h
@@ -48,8 +48,8 @@ public:
void updateAnchorIndicator(const AnchorLine &sourceAnchorLine, const AnchorLine targetAnchorLine);
- AnchorLine::Type sourceAnchorLineType() const;
- void setSourceAnchorLineType(const AnchorLine::Type &sourceAnchorLineType);
+ AnchorLineType sourceAnchorLineType() const;
+ void setSourceAnchorLineType(const AnchorLineType &sourceAnchorLineType);
protected:
void updateBoundingRect();
@@ -63,8 +63,8 @@ private:
QPointF m_sourceAnchorLineSecondPoint;
QPointF m_targetAnchorLineFirstPoint;
QPointF m_targetAnchorLineSecondPoint;
- AnchorLine::Type m_sourceAnchorLineType;
- AnchorLine::Type m_targetAnchorLineType;
+ AnchorLineType m_sourceAnchorLineType;
+ AnchorLineType m_targetAnchorLineType;
QRectF m_boundingRect;
};
diff --git a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
index 3cecfc4763..32f6cfc533 100644
--- a/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/movemanipulator.cpp
@@ -146,12 +146,12 @@ void MoveManipulator::begin(const QPointF &beginPoint)
foreach (FormEditorItem* item, m_itemList) {
if (item && item->qmlItemNode().isValid()) {
QmlAnchors anchors(item->qmlItemNode().anchors());
- m_beginTopMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Top));
- m_beginLeftMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Left));
- m_beginRightMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Right));
- m_beginBottomMarginHash.insert(item, anchors.instanceMargin(AnchorLine::Bottom));
- m_beginHorizontalCenterHash.insert(item, anchors.instanceMargin(AnchorLine::HorizontalCenter));
- m_beginVerticalCenterHash.insert(item, anchors.instanceMargin(AnchorLine::VerticalCenter));
+ m_beginTopMarginHash.insert(item, anchors.instanceMargin(AnchorLineTop));
+ m_beginLeftMarginHash.insert(item, anchors.instanceMargin(AnchorLineLeft));
+ m_beginRightMarginHash.insert(item, anchors.instanceMargin(AnchorLineRight));
+ m_beginBottomMarginHash.insert(item, anchors.instanceMargin(AnchorLineBottom));
+ m_beginHorizontalCenterHash.insert(item, anchors.instanceMargin(AnchorLineHorizontalCenter));
+ m_beginVerticalCenterHash.insert(item, anchors.instanceMargin(AnchorLineVerticalCenter));
}
}
@@ -280,23 +280,23 @@ void MoveManipulator::update(const QPointF& updatePoint, Snapper::Snapping useSn
if (stateToBeManipulated == UseCurrentState) {
QmlAnchors anchors(item->qmlItemNode().anchors());
- if (anchors.instanceHasAnchor(AnchorLine::Top))
- anchors.setMargin(AnchorLine::Top, m_beginTopMarginHash.value(item) + offsetVector.y());
+ if (anchors.instanceHasAnchor(AnchorLineTop))
+ anchors.setMargin(AnchorLineTop, m_beginTopMarginHash.value(item) + offsetVector.y());
- if (anchors.instanceHasAnchor(AnchorLine::Left))
- anchors.setMargin(AnchorLine::Left, m_beginLeftMarginHash.value(item) + offsetVector.x());
+ if (anchors.instanceHasAnchor(AnchorLineLeft))
+ anchors.setMargin(AnchorLineLeft, m_beginLeftMarginHash.value(item) + offsetVector.x());
- if (anchors.instanceHasAnchor(AnchorLine::Bottom))
- anchors.setMargin(AnchorLine::Bottom, m_beginBottomMarginHash.value(item) - offsetVector.y());
+ if (anchors.instanceHasAnchor(AnchorLineBottom))
+ anchors.setMargin(AnchorLineBottom, m_beginBottomMarginHash.value(item) - offsetVector.y());
- if (anchors.instanceHasAnchor(AnchorLine::Right))
- anchors.setMargin(AnchorLine::Right, m_beginRightMarginHash.value(item) - offsetVector.x());
+ if (anchors.instanceHasAnchor(AnchorLineRight))
+ anchors.setMargin(AnchorLineRight, m_beginRightMarginHash.value(item) - offsetVector.x());
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
- anchors.setMargin(AnchorLine::HorizontalCenter, m_beginHorizontalCenterHash.value(item) + offsetVector.x());
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
+ anchors.setMargin(AnchorLineHorizontalCenter, m_beginHorizontalCenterHash.value(item) + offsetVector.x());
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
- anchors.setMargin(AnchorLine::VerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y());
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
+ anchors.setMargin(AnchorLineVerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y());
item->qmlItemNode().setPosition(positionInContainerSpace);
} else {
@@ -396,23 +396,23 @@ void MoveManipulator::moveBy(double deltaX, double deltaY)
QmlAnchors anchors(item->qmlItemNode().anchors());
- if (anchors.instanceHasAnchor(AnchorLine::Top))
- anchors.setMargin(AnchorLine::Top, anchors.instanceMargin(AnchorLine::Top) + deltaY);
+ if (anchors.instanceHasAnchor(AnchorLineTop))
+ anchors.setMargin(AnchorLineTop, anchors.instanceMargin(AnchorLineTop) + deltaY);
- if (anchors.instanceHasAnchor(AnchorLine::Left))
- anchors.setMargin(AnchorLine::Left, anchors.instanceMargin(AnchorLine::Left) + deltaX);
+ if (anchors.instanceHasAnchor(AnchorLineLeft))
+ anchors.setMargin(AnchorLineLeft, anchors.instanceMargin(AnchorLineLeft) + deltaX);
- if (anchors.instanceHasAnchor(AnchorLine::Bottom))
- anchors.setMargin(AnchorLine::Bottom, anchors.instanceMargin(AnchorLine::Bottom) - deltaY);
+ if (anchors.instanceHasAnchor(AnchorLineBottom))
+ anchors.setMargin(AnchorLineBottom, anchors.instanceMargin(AnchorLineBottom) - deltaY);
- if (anchors.instanceHasAnchor(AnchorLine::Right))
- anchors.setMargin(AnchorLine::Right, anchors.instanceMargin(AnchorLine::Right) - deltaX);
+ if (anchors.instanceHasAnchor(AnchorLineRight))
+ anchors.setMargin(AnchorLineRight, anchors.instanceMargin(AnchorLineRight) - deltaX);
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
- anchors.setMargin(AnchorLine::HorizontalCenter, anchors.instanceMargin(AnchorLine::HorizontalCenter) + deltaX);
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
+ anchors.setMargin(AnchorLineHorizontalCenter, anchors.instanceMargin(AnchorLineHorizontalCenter) + deltaX);
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
- anchors.setMargin(AnchorLine::VerticalCenter, anchors.instanceMargin(AnchorLine::VerticalCenter) + deltaY);
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
+ anchors.setMargin(AnchorLineVerticalCenter, anchors.instanceMargin(AnchorLineVerticalCenter) + deltaY);
item->qmlItemNode().setPosition(QPointF(item->qmlItemNode().instanceValue("x").toDouble() + deltaX,
item->qmlItemNode().instanceValue("y").toDouble() + deltaY));
diff --git a/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp b/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp
index 82e54505ef..c567e1bc55 100644
--- a/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/resizemanipulator.cpp
@@ -86,10 +86,10 @@ void ResizeManipulator::begin(const QPointF &/*beginPoint*/)
m_beginBottomRightPoint = m_beginToParentTransform.map(m_resizeController.formEditorItem()->qmlItemNode().instanceBoundingRect().bottomRight());
QmlAnchors anchors(m_resizeController.formEditorItem()->qmlItemNode().anchors());
- m_beginTopMargin = anchors.instanceMargin(AnchorLine::Top);
- m_beginLeftMargin = anchors.instanceMargin(AnchorLine::Left);
- m_beginRightMargin = anchors.instanceMargin(AnchorLine::Right);
- m_beginBottomMargin = anchors.instanceMargin(AnchorLine::Bottom);
+ m_beginTopMargin = anchors.instanceMargin(AnchorLineTop);
+ m_beginLeftMargin = anchors.instanceMargin(AnchorLineLeft);
+ m_beginRightMargin = anchors.instanceMargin(AnchorLineRight);
+ m_beginBottomMargin = anchors.instanceMargin(AnchorLineBottom);
}
}
@@ -135,10 +135,10 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
}
boundingRect.setBottomRight(updatePointInLocalSpace);
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
boundingRect.setLeft(boundingRect.left() - (updatePointInLocalSpace.x() - m_beginBoundingRect.right()));
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
boundingRect.setTop(boundingRect.top() - (updatePointInLocalSpace.y() - m_beginBoundingRect.bottom()));
if (boundingRect.width() < minimumWidth)
@@ -148,13 +148,13 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setSize(boundingRect.size());
- if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
- anchors.setMargin(AnchorLine::Bottom,
+ if (anchors.instanceHasAnchor(AnchorLineBottom)) {
+ anchors.setMargin(AnchorLineBottom,
m_beginBottomMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).y());
}
- if (anchors.instanceHasAnchor(AnchorLine::Right)) {
- anchors.setMargin(AnchorLine::Right,
+ if (anchors.instanceHasAnchor(AnchorLineRight)) {
+ anchors.setMargin(AnchorLineRight,
m_beginRightMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).x());
}
} else if (m_resizeHandle->isTopLeftHandle()) {
@@ -171,10 +171,10 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
}
boundingRect.setTopLeft(updatePointInLocalSpace);
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
boundingRect.setRight(boundingRect.right() - (updatePointInLocalSpace.x() - m_beginBoundingRect.left()));
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
boundingRect.setBottom(boundingRect.bottom() - (updatePointInLocalSpace.y() - m_beginBoundingRect.top()));
@@ -187,13 +187,13 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
- if (anchors.instanceHasAnchor(AnchorLine::Top)) {
- anchors.setMargin(AnchorLine::Top,
+ if (anchors.instanceHasAnchor(AnchorLineTop)) {
+ anchors.setMargin(AnchorLineTop,
m_beginTopMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).y() + m_beginToParentTransform.map(boundingRect.topLeft()).y()));
}
- if (anchors.instanceHasAnchor(AnchorLine::Left)) {
- anchors.setMargin(AnchorLine::Left,
+ if (anchors.instanceHasAnchor(AnchorLineLeft)) {
+ anchors.setMargin(AnchorLineLeft,
m_beginLeftMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).x() + m_beginToParentTransform.map(boundingRect.topLeft()).x()));
}
@@ -211,10 +211,10 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
}
boundingRect.setTopRight(updatePointInLocalSpace);
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
boundingRect.setLeft(boundingRect.left() - (updatePointInLocalSpace.x() - m_beginBoundingRect.right()));
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
boundingRect.setBottom(boundingRect.bottom() - (updatePointInLocalSpace.y() - m_beginBoundingRect.top()));
if (boundingRect.height() < minimumHeight)
@@ -225,13 +225,13 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition( m_beginToParentTransform.map(boundingRect.topLeft()));
- if (anchors.instanceHasAnchor(AnchorLine::Top)) {
- anchors.setMargin(AnchorLine::Top,
+ if (anchors.instanceHasAnchor(AnchorLineTop)) {
+ anchors.setMargin(AnchorLineTop,
m_beginTopMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).y() + m_beginToParentTransform.map(boundingRect.topLeft()).y()));
}
- if (anchors.instanceHasAnchor(AnchorLine::Right)) {
- anchors.setMargin(AnchorLine::Right,
+ if (anchors.instanceHasAnchor(AnchorLineRight)) {
+ anchors.setMargin(AnchorLineRight,
m_beginRightMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).x());
}
} else if (m_resizeHandle->isBottomLeftHandle()) {
@@ -249,10 +249,10 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
boundingRect.setBottomLeft(updatePointInLocalSpace);
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
boundingRect.setRight(boundingRect.right() - (updatePointInLocalSpace.x() - m_beginBoundingRect.left()));
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
boundingRect.setTop(boundingRect.top() - (updatePointInLocalSpace.y() - m_beginBoundingRect.bottom()));
if (boundingRect.height() < minimumHeight)
@@ -263,13 +263,13 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
- if (anchors.instanceHasAnchor(AnchorLine::Left)) {
- anchors.setMargin(AnchorLine::Left,
+ if (anchors.instanceHasAnchor(AnchorLineLeft)) {
+ anchors.setMargin(AnchorLineLeft,
m_beginLeftMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).x() + m_beginToParentTransform.map(boundingRect.topLeft()).x()));
}
- if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
- anchors.setMargin(AnchorLine::Bottom,
+ if (anchors.instanceHasAnchor(AnchorLineBottom)) {
+ anchors.setMargin(AnchorLineBottom,
m_beginBottomMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).y());
}
} else if (m_resizeHandle->isBottomHandle()) {
@@ -283,7 +283,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
boundingRect.setBottom(updatePointInLocalSpace.y());
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
boundingRect.setTop(boundingRect.top() - (updatePointInLocalSpace.y() - m_beginBoundingRect.bottom()));
if (boundingRect.height() < minimumHeight)
@@ -291,8 +291,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setSize(boundingRect.size());
- if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
- anchors.setMargin(AnchorLine::Bottom,
+ if (anchors.instanceHasAnchor(AnchorLineBottom)) {
+ anchors.setMargin(AnchorLineBottom,
m_beginBottomMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).y());
}
} else if (m_resizeHandle->isTopHandle()) {
@@ -306,7 +306,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
boundingRect.setTop(updatePointInLocalSpace.y());
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
boundingRect.setBottom(boundingRect.bottom() - (updatePointInLocalSpace.y() - m_beginBoundingRect.top()));
if (boundingRect.height() < minimumHeight)
@@ -315,8 +315,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
- if (anchors.instanceHasAnchor(AnchorLine::Top)) {
- anchors.setMargin(AnchorLine::Top,
+ if (anchors.instanceHasAnchor(AnchorLineTop)) {
+ anchors.setMargin(AnchorLineTop,
m_beginTopMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).y() + m_beginToParentTransform.map(boundingRect.topLeft()).y()));
}
} else if (m_resizeHandle->isRightHandle()) {
@@ -330,7 +330,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
boundingRect.setRight(updatePointInLocalSpace.x());
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
boundingRect.setLeft(boundingRect.left() - (updatePointInLocalSpace.x() - m_beginBoundingRect.right()));
if (boundingRect.width() < minimumWidth)
@@ -339,8 +339,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setSize(boundingRect.size());
- if (anchors.instanceHasAnchor(AnchorLine::Right)) {
- anchors.setMargin(AnchorLine::Right,
+ if (anchors.instanceHasAnchor(AnchorLineRight)) {
+ anchors.setMargin(AnchorLineRight,
m_beginRightMargin - (m_beginToParentTransform.map(boundingRect.bottomRight()) - m_beginBottomRightPoint).x());
}
} else if (m_resizeHandle->isLeftHandle()) {
@@ -354,7 +354,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
boundingRect.setLeft(updatePointInLocalSpace.x());
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
boundingRect.setRight(boundingRect.right() - (updatePointInLocalSpace.x() - m_beginBoundingRect.left()));
if (boundingRect.width() < minimumWidth)
@@ -363,8 +363,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
- if (anchors.instanceHasAnchor(AnchorLine::Left)) {
- anchors.setMargin(AnchorLine::Left,
+ if (anchors.instanceHasAnchor(AnchorLineLeft)) {
+ anchors.setMargin(AnchorLineLeft,
m_beginLeftMargin + (-m_beginToParentTransform.map(m_beginBoundingRect.topLeft()).x() + m_beginToParentTransform.map(boundingRect.topLeft()).x()));
}
}
@@ -404,10 +404,10 @@ void ResizeManipulator::moveBy(double deltaX, double deltaY)
qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() - deltaX, 4));
- if (anchors.instanceHasAnchor(AnchorLine::Left))
- anchors.setMargin(AnchorLine::Left, anchors.instanceMargin(AnchorLine::Left) + deltaX);
+ if (anchors.instanceHasAnchor(AnchorLineLeft))
+ anchors.setMargin(AnchorLineLeft, anchors.instanceMargin(AnchorLineLeft) + deltaX);
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() - (deltaX * 2), 4));
}
@@ -416,10 +416,10 @@ void ResizeManipulator::moveBy(double deltaX, double deltaY)
|| m_resizeController.isBottomRightHandle(resizeHandle())) {
qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() + deltaX, 4));
- if (anchors.instanceHasAnchor(AnchorLine::Right))
- anchors.setMargin(AnchorLine::Right, round(anchors.instanceMargin(AnchorLine::Right) - deltaX, 4));
+ if (anchors.instanceHasAnchor(AnchorLineRight))
+ anchors.setMargin(AnchorLineRight, round(anchors.instanceMargin(AnchorLineRight) - deltaX, 4));
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter))
qmlItemNode.setVariantProperty("width", round(qmlItemNode.instanceValue("width").toDouble() + (deltaX * 2), 4));
}
@@ -430,10 +430,10 @@ void ResizeManipulator::moveBy(double deltaX, double deltaY)
qmlItemNode.setVariantProperty("y", round(qmlItemNode.instanceValue("y").toDouble() + deltaY, 4));
qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() - deltaY, 4));
- if (anchors.instanceHasAnchor(AnchorLine::Top))
- anchors.setMargin(AnchorLine::Top, anchors.instanceMargin(AnchorLine::Top) + deltaY);
+ if (anchors.instanceHasAnchor(AnchorLineTop))
+ anchors.setMargin(AnchorLineTop, anchors.instanceMargin(AnchorLineTop) + deltaY);
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() - (deltaY * 2), 4));
}
@@ -442,10 +442,10 @@ void ResizeManipulator::moveBy(double deltaX, double deltaY)
|| m_resizeController.isBottomRightHandle(resizeHandle())) {
qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() + deltaY, 4));
- if (anchors.instanceHasAnchor(AnchorLine::Bottom))
- anchors.setMargin(AnchorLine::Bottom, anchors.instanceMargin(AnchorLine::Bottom) - deltaY);
+ if (anchors.instanceHasAnchor(AnchorLineBottom))
+ anchors.setMargin(AnchorLineBottom, anchors.instanceMargin(AnchorLineBottom) - deltaY);
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter))
qmlItemNode.setVariantProperty("height", round(qmlItemNode.instanceValue("height").toDouble() + (deltaY * 2), 4));
}
diff --git a/src/plugins/qmldesigner/components/formeditor/snapper.cpp b/src/plugins/qmldesigner/components/formeditor/snapper.cpp
index a562dba8ea..13d560c315 100644
--- a/src/plugins/qmldesigner/components/formeditor/snapper.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/snapper.cpp
@@ -563,20 +563,20 @@ QList<QGraphicsItem*> Snapper::generateSnappingLines(const QRectF &boundingRect,
return generateSnappingLines(boundingRectList, layerItem, transform);
}
-static QmlItemNode findItemOnSnappingLine(const QmlItemNode &sourceQmlItemNode, const SnapLineMap &snappingLines, double anchorLine, AnchorLine::Type anchorLineType)
+static QmlItemNode findItemOnSnappingLine(const QmlItemNode &sourceQmlItemNode, const SnapLineMap &snappingLines, double anchorLine, AnchorLineType anchorLineType)
{
QmlItemNode targetQmlItemNode;
double targetAnchorLine = 0.0;
targetAnchorLine = std::numeric_limits<double>::max();
- AnchorLine::Type compareAnchorLineType;
+ AnchorLineType compareAnchorLineType;
- if (anchorLineType == AnchorLine::Left
- || anchorLineType == AnchorLine::Right)
- compareAnchorLineType = AnchorLine::Top;
+ if (anchorLineType == AnchorLineLeft
+ || anchorLineType == AnchorLineRight)
+ compareAnchorLineType = AnchorLineTop;
else
- compareAnchorLineType = AnchorLine::Left;
+ compareAnchorLineType = AnchorLineLeft;
SnapLineMapIterator snapLineIterator(snappingLines);
while (snapLineIterator.hasNext()) {
@@ -608,8 +608,8 @@ static void adjustAnchorLine(const QmlItemNode &sourceQmlItemNode,
const QmlItemNode &containerQmlItemNode,
const SnapLineMap &snappingLines,
const SnapLineMap &snappingOffsets,
- AnchorLine::Type lineAnchorLineType,
- AnchorLine::Type offsetAnchorLineType)
+ AnchorLineType lineAnchorLineType,
+ AnchorLineType offsetAnchorLineType)
{
QmlAnchors qmlAnchors = sourceQmlItemNode.anchors();
@@ -624,13 +624,13 @@ static void adjustAnchorLine(const QmlItemNode &sourceQmlItemNode,
boundingRect = targetQmlItemNode.instanceBoundingRect();
if (targetQmlItemNode == containerQmlItemNode) {
- if (lineAnchorLineType == AnchorLine::Left)
+ if (lineAnchorLineType == AnchorLineLeft)
margin = fromAnchorLine - boundingRect.left();
- else if (lineAnchorLineType == AnchorLine::Top)
+ else if (lineAnchorLineType == AnchorLineTop)
margin = fromAnchorLine - boundingRect.top();
- else if (lineAnchorLineType == AnchorLine::Right)
+ else if (lineAnchorLineType == AnchorLineRight)
margin = boundingRect.right() - fromAnchorLine;
- else if (lineAnchorLineType == AnchorLine::Bottom)
+ else if (lineAnchorLineType == AnchorLineBottom)
margin = boundingRect.bottom() - fromAnchorLine;
}
@@ -644,8 +644,8 @@ static void adjustAnchorLine(const QmlItemNode &sourceQmlItemNode,
if (targetQmlItemNode.isValid() && !targetQmlItemNode.anchors().checkForCycle(lineAnchorLineType, sourceQmlItemNode)) {
double margin = fromAnchorLine - targetQmlItemNode.anchors().instanceAnchorLine(offsetAnchorLineType);
- if (lineAnchorLineType == AnchorLine::Right
- || lineAnchorLineType == AnchorLine::Bottom)
+ if (lineAnchorLineType == AnchorLineRight
+ || lineAnchorLineType == AnchorLineBottom)
margin *= -1.;
@@ -662,58 +662,58 @@ void Snapper::adjustAnchoringOfItem(FormEditorItem *formEditorItem)
QmlItemNode qmlItemNode = formEditorItem->qmlItemNode();
QmlAnchors qmlAnchors = qmlItemNode.anchors();
- if (!qmlAnchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) {
+ if (!qmlAnchors.instanceHasAnchor(AnchorLineHorizontalCenter)) {
adjustAnchorLine(qmlItemNode,
containerFormEditorItem()->qmlItemNode(),
containerFormEditorItem()->leftSnappingLines(),
containerFormEditorItem()->rightSnappingOffsets(),
- AnchorLine::Left,
- AnchorLine::Right);
+ AnchorLineLeft,
+ AnchorLineRight);
}
- if (!qmlAnchors.instanceHasAnchor(AnchorLine::VerticalCenter)) {
+ if (!qmlAnchors.instanceHasAnchor(AnchorLineVerticalCenter)) {
adjustAnchorLine(qmlItemNode,
containerFormEditorItem()->qmlItemNode(),
containerFormEditorItem()->topSnappingLines(),
containerFormEditorItem()->bottomSnappingOffsets(),
- AnchorLine::Top,
- AnchorLine::Bottom);
+ AnchorLineTop,
+ AnchorLineBottom);
}
- if (!qmlAnchors.instanceHasAnchor(AnchorLine::VerticalCenter)) {
+ if (!qmlAnchors.instanceHasAnchor(AnchorLineVerticalCenter)) {
adjustAnchorLine(qmlItemNode,
containerFormEditorItem()->qmlItemNode(),
containerFormEditorItem()->bottomSnappingLines(),
containerFormEditorItem()->topSnappingOffsets(),
- AnchorLine::Bottom,
- AnchorLine::Top);
+ AnchorLineBottom,
+ AnchorLineTop);
}
- if (!qmlAnchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) {
+ if (!qmlAnchors.instanceHasAnchor(AnchorLineHorizontalCenter)) {
adjustAnchorLine(qmlItemNode,
containerFormEditorItem()->qmlItemNode(),
containerFormEditorItem()->rightSnappingLines(),
containerFormEditorItem()->leftSnappingOffsets(),
- AnchorLine::Right,
- AnchorLine::Left);
+ AnchorLineRight,
+ AnchorLineLeft);
}
- if (!qmlAnchors.instanceHasAnchor(AnchorLine::Left) && !qmlAnchors.instanceHasAnchor(AnchorLine::Right)) {
+ if (!qmlAnchors.instanceHasAnchor(AnchorLineLeft) && !qmlAnchors.instanceHasAnchor(AnchorLineRight)) {
adjustAnchorLine(qmlItemNode,
containerFormEditorItem()->qmlItemNode(),
containerFormEditorItem()->verticalCenterSnappingLines(),
SnapLineMap(),
- AnchorLine::HorizontalCenter,
- AnchorLine::HorizontalCenter);
+ AnchorLineHorizontalCenter,
+ AnchorLineHorizontalCenter);
}
- if (!qmlAnchors.instanceHasAnchor(AnchorLine::Top) && !qmlAnchors.instanceHasAnchor(AnchorLine::Bottom)) {
+ if (!qmlAnchors.instanceHasAnchor(AnchorLineTop) && !qmlAnchors.instanceHasAnchor(AnchorLineBottom)) {
adjustAnchorLine(qmlItemNode,
containerFormEditorItem()->qmlItemNode(),
containerFormEditorItem()->horizontalCenterSnappingLines(),
SnapLineMap(),
- AnchorLine::VerticalCenter,
- AnchorLine::VerticalCenter);
+ AnchorLineVerticalCenter,
+ AnchorLineVerticalCenter);
}
}
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
index e140692b57..76a5174385 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/qmlanchorbindingproxy.cpp
@@ -84,37 +84,37 @@ void QmlAnchorBindingProxy::setup(const QmlItemNode &fxItemNode)
setDefaultAnchorTarget(ModelNode());
if (topAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Top).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineTop).qmlItemNode();
if (targetNode.isValid())
m_topTarget = targetNode;
}
if (bottomAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Bottom).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineBottom).qmlItemNode();
if (targetNode.isValid())
m_bottomTarget = targetNode;
}
if (leftAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Left).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineLeft).qmlItemNode();
if (targetNode.isValid())
m_leftTarget = targetNode;
}
if (rightAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Right).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineRight).qmlItemNode();
if (targetNode.isValid())
m_rightTarget = targetNode;
}
if (verticalCentered()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineVerticalCenter).qmlItemNode();
if (targetNode.isValid())
m_verticalTarget = targetNode;
}
if (horizontalCentered()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineHorizontalCenter).qmlItemNode();
if (targetNode.isValid())
m_horizontalTarget = targetNode;
}
@@ -156,37 +156,37 @@ void QmlAnchorBindingProxy::invalidate(const QmlItemNode &fxItemNode)
m_verticalTarget = m_horizontalTarget = m_topTarget = m_bottomTarget = m_leftTarget = m_rightTarget = m_qmlItemNode.modelNode().parentProperty().parentModelNode();
if (topAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Top).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineTop).qmlItemNode();
if (targetNode.isValid())
m_topTarget = targetNode;
}
if (bottomAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Bottom).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineBottom).qmlItemNode();
if (targetNode.isValid())
m_bottomTarget = targetNode;
}
if (leftAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Left).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineLeft).qmlItemNode();
if (targetNode.isValid())
m_leftTarget = targetNode;
}
if (rightAnchored()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::Right).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineRight).qmlItemNode();
if (targetNode.isValid())
m_rightTarget = targetNode;
}
if (verticalCentered()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::VerticalCenter).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineVerticalCenter).qmlItemNode();
if (targetNode.isValid())
m_verticalTarget = targetNode;
}
if (horizontalCentered()) {
- ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLine::HorizontalCenter).qmlItemNode();
+ ModelNode targetNode = m_qmlItemNode.anchors().instanceAnchor(AnchorLineHorizontalCenter).qmlItemNode();
if (targetNode.isValid())
m_horizontalTarget = targetNode;
}
@@ -230,22 +230,22 @@ bool QmlAnchorBindingProxy::isFilled()
bool QmlAnchorBindingProxy::topAnchored()
{
- return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLine::Top);
+ return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLineTop);
}
bool QmlAnchorBindingProxy::bottomAnchored()
{
- return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLine::Bottom);
+ return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLineBottom);
}
bool QmlAnchorBindingProxy::leftAnchored()
{
- return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLine::Left);
+ return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLineLeft);
}
bool QmlAnchorBindingProxy::rightAnchored()
{
- return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLine::Right);
+ return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLineRight);
}
bool QmlAnchorBindingProxy::hasAnchors()
@@ -359,7 +359,7 @@ void QmlAnchorBindingProxy::setVerticalTarget(const QString &target)
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalTarget"));
m_verticalTarget = newTarget;
- m_qmlItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_verticalTarget, AnchorLine::VerticalCenter);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineVerticalCenter, m_verticalTarget, AnchorLineVerticalCenter);
emit verticalTargetChanged();
}
@@ -380,7 +380,7 @@ void QmlAnchorBindingProxy::setHorizontalTarget(const QString &target)
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalTarget"));
m_horizontalTarget = newTarget;
- m_qmlItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_horizontalTarget, AnchorLine::HorizontalCenter);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineHorizontalCenter, m_horizontalTarget, AnchorLineHorizontalCenter);
emit horizontalTargetChanged();
}
@@ -536,12 +536,12 @@ void QmlAnchorBindingProxy::calcTopMargin()
if (m_topTarget.modelNode() == m_qmlItemNode.modelNode().parentProperty().parentModelNode()) {
qreal topMargin = transformedBoundingBox().top() - parentBoundingBox().top();
- m_qmlItemNode.anchors().setMargin( AnchorLine::Top, topMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Top);
+ m_qmlItemNode.anchors().setMargin( AnchorLineTop, topMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineTop, m_topTarget, AnchorLineTop);
} else {
qreal topMargin = boundingBox(m_qmlItemNode).top() - boundingBox(m_topTarget).bottom();
- m_qmlItemNode.anchors().setMargin( AnchorLine::Top, topMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Top, m_topTarget, AnchorLine::Bottom);
+ m_qmlItemNode.anchors().setMargin( AnchorLineTop, topMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineTop, m_topTarget, AnchorLineBottom);
}
m_locked = false;
@@ -553,12 +553,12 @@ void QmlAnchorBindingProxy::calcBottomMargin()
if (m_bottomTarget.modelNode() == m_qmlItemNode.modelNode().parentProperty().parentModelNode()) {
qreal bottomMargin = parentBoundingBox().bottom() - transformedBoundingBox().bottom();
- m_qmlItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Bottom);
+ m_qmlItemNode.anchors().setMargin( AnchorLineBottom, bottomMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineBottom, m_bottomTarget, AnchorLineBottom);
} else {
qreal bottomMargin = boundingBox(m_bottomTarget).top()- boundingBox(m_qmlItemNode).bottom();
- m_qmlItemNode.anchors().setMargin( AnchorLine::Bottom, bottomMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Bottom, m_bottomTarget, AnchorLine::Top);
+ m_qmlItemNode.anchors().setMargin( AnchorLineBottom, bottomMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineBottom, m_bottomTarget, AnchorLineTop);
}
m_locked = false;
@@ -570,12 +570,12 @@ void QmlAnchorBindingProxy::calcLeftMargin()
if (m_leftTarget.modelNode() == m_qmlItemNode.modelNode().parentProperty().parentModelNode()) {
qreal leftMargin = transformedBoundingBox().left() - parentBoundingBox().left();
- m_qmlItemNode.anchors().setMargin(AnchorLine::Left, leftMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Left, m_leftTarget, AnchorLine::Left);
+ m_qmlItemNode.anchors().setMargin(AnchorLineLeft, leftMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineLeft, m_leftTarget, AnchorLineLeft);
} else {
qreal leftMargin = boundingBox(m_qmlItemNode).left() - boundingBox(m_leftTarget).right();
- m_qmlItemNode.anchors().setMargin( AnchorLine::Left, leftMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Left, m_leftTarget, AnchorLine::Right);
+ m_qmlItemNode.anchors().setMargin( AnchorLineLeft, leftMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineLeft, m_leftTarget, AnchorLineRight);
}
m_locked = false;
@@ -587,12 +587,12 @@ void QmlAnchorBindingProxy::calcRightMargin()
if (m_rightTarget.modelNode() == m_qmlItemNode.modelNode().parentProperty().parentModelNode()) {
qreal rightMargin = parentBoundingBox().right() - transformedBoundingBox().right();
- m_qmlItemNode.anchors().setMargin( AnchorLine::Right, rightMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Right);
+ m_qmlItemNode.anchors().setMargin( AnchorLineRight, rightMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineRight, m_rightTarget, AnchorLineRight);
} else {
qreal rightMargin = boundingBox(m_rightTarget).left() - boundingBox(m_qmlItemNode).right();
- m_qmlItemNode.anchors().setMargin( AnchorLine::Right, rightMargin);
- m_qmlItemNode.anchors().setAnchor(AnchorLine::Right, m_rightTarget, AnchorLine::Left);
+ m_qmlItemNode.anchors().setMargin( AnchorLineRight, rightMargin);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineRight, m_rightTarget, AnchorLineLeft);
}
m_locked = false;
@@ -652,8 +652,8 @@ void QmlAnchorBindingProxy::setTopAnchor(bool anchor)
void QmlAnchorBindingProxy::removeTopAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeTopAnchor"));
- m_qmlItemNode.anchors().removeAnchor(AnchorLine::Top);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Top);
+ m_qmlItemNode.anchors().removeAnchor(AnchorLineTop);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
restoreProperty(modelNode(), "y");
restoreProperty(modelNode(), "height");
@@ -663,8 +663,8 @@ void QmlAnchorBindingProxy::removeTopAnchor() {
void QmlAnchorBindingProxy::removeBottomAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeBottomAnchor"));
- m_qmlItemNode.anchors().removeAnchor(AnchorLine::Bottom);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Bottom);
+ m_qmlItemNode.anchors().removeAnchor(AnchorLineBottom);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
restoreProperty(modelNode(), "height");
@@ -673,8 +673,8 @@ void QmlAnchorBindingProxy::removeBottomAnchor() {
void QmlAnchorBindingProxy::removeLeftAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeLeftAnchor"));
- m_qmlItemNode.anchors().removeAnchor(AnchorLine::Left);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Left);
+ m_qmlItemNode.anchors().removeAnchor(AnchorLineLeft);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineLeft);
restoreProperty(modelNode(), "x");
restoreProperty(modelNode(), "width");
@@ -683,8 +683,8 @@ void QmlAnchorBindingProxy::removeLeftAnchor() {
void QmlAnchorBindingProxy::removeRightAnchor() {
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::removeRightAnchor"));
- m_qmlItemNode.anchors().removeAnchor(AnchorLine::Right);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Right);
+ m_qmlItemNode.anchors().removeAnchor(AnchorLineRight);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineRight);
restoreProperty(modelNode(), "width");
}
@@ -702,10 +702,10 @@ void QmlAnchorBindingProxy::setVerticalCentered(bool centered)
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setVerticalCentered"));
if (!centered) {
- m_qmlItemNode.anchors().removeAnchor(AnchorLine::VerticalCenter);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::VerticalCenter);
+ m_qmlItemNode.anchors().removeAnchor(AnchorLineVerticalCenter);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineVerticalCenter);
} else {
- m_qmlItemNode.anchors().setAnchor(AnchorLine::VerticalCenter, m_qmlItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::VerticalCenter);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineVerticalCenter, m_qmlItemNode.modelNode().parentProperty().parentModelNode(), AnchorLineVerticalCenter);
}
m_locked = false;
@@ -726,10 +726,10 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
RewriterTransaction transaction = m_qmlItemNode.modelNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchorBindingProxy::setHorizontalCentered"));
if (!centered) {
- m_qmlItemNode.anchors().removeAnchor(AnchorLine::HorizontalCenter);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::HorizontalCenter);
+ m_qmlItemNode.anchors().removeAnchor(AnchorLineHorizontalCenter);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineHorizontalCenter);
} else {
- m_qmlItemNode.anchors().setAnchor(AnchorLine::HorizontalCenter, m_qmlItemNode.modelNode().parentProperty().parentModelNode(), AnchorLine::HorizontalCenter);
+ m_qmlItemNode.anchors().setAnchor(AnchorLineHorizontalCenter, m_qmlItemNode.modelNode().parentProperty().parentModelNode(), AnchorLineHorizontalCenter);
}
m_locked = false;
@@ -739,7 +739,7 @@ void QmlAnchorBindingProxy::setHorizontalCentered(bool centered)
bool QmlAnchorBindingProxy::verticalCentered()
{
- return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLine::VerticalCenter);
+ return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLineVerticalCenter);
}
QString QmlAnchorBindingProxy::topTarget() const
@@ -774,7 +774,7 @@ QString QmlAnchorBindingProxy::horizontalTarget() const
bool QmlAnchorBindingProxy::horizontalCentered()
{
- return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLine::HorizontalCenter);
+ return m_qmlItemNode.isValid() && m_qmlItemNode.anchors().instanceHasAnchor(AnchorLineHorizontalCenter);
}
void QmlAnchorBindingProxy::fill()
@@ -793,10 +793,10 @@ void QmlAnchorBindingProxy::fill()
setHorizontalCentered(false);
setVerticalCentered(false);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Right);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Left);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Top);
- m_qmlItemNode.anchors().removeMargin(AnchorLine::Bottom);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineRight);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineLeft);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineTop);
+ m_qmlItemNode.anchors().removeMargin(AnchorLineBottom);
emit topAnchorChanged();
emit bottomAnchorChanged();
diff --git a/src/plugins/qmldesigner/designercore/designercore-lib.pri b/src/plugins/qmldesigner/designercore/designercore-lib.pri
index 2662a33b91..7229dd6eda 100644
--- a/src/plugins/qmldesigner/designercore/designercore-lib.pri
+++ b/src/plugins/qmldesigner/designercore/designercore-lib.pri
@@ -78,6 +78,7 @@ SOURCES += $$PWD/model/abstractview.cpp \
$$PWD/model/viewmanager.cpp \
$$PWD/model/signalhandlerproperty.cpp \
$$PWD/model/internalsignalhandlerproperty.cpp \
+ $$PWD/model/anchorline.cpp \
$$PWD/instances/puppetdialog.cpp
HEADERS += $$PWD/include/qmldesignercorelib_global.h \
@@ -150,6 +151,7 @@ HEADERS += $$PWD/include/qmldesignercorelib_global.h \
$$PWD/include/viewmanager.h \
$$PWD/include/signalhandlerproperty.h \
$$PWD/model/internalsignalhandlerproperty.h \
+ $$PWD/include/anchorline.h \
$$PWD/instances/puppetdialog.h
FORMS += \
diff --git a/src/plugins/qmldesigner/designercore/include/anchorline.h b/src/plugins/qmldesigner/designercore/include/anchorline.h
new file mode 100644
index 0000000000..c797b0923f
--- /dev/null
+++ b/src/plugins/qmldesigner/designercore/include/anchorline.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+
+#ifndef QMLDESIGNER_ANCHORLINE_H
+#define QMLDESIGNER_ANCHORLINE_H
+
+#include <qmldesignercorelib_global.h>
+
+#include "qmlitemnode.h"
+
+namespace QmlDesigner {
+
+class QMLDESIGNERCORE_EXPORT AnchorLine
+{
+public:
+ AnchorLine();
+ AnchorLine(const QmlItemNode &qmlItemNode, AnchorLineType type);
+ AnchorLineType type() const;
+ bool isValid() const;
+
+ static bool isHorizontalAnchorLine(AnchorLineType anchorline);
+ static bool isVerticalAnchorLine(AnchorLineType anchorline);
+
+ QmlItemNode qmlItemNode() const;
+
+private:
+ QmlItemNode m_qmlItemNode;
+ AnchorLineType m_type;
+};
+
+} // namespace QmlDesigner
+
+#endif // QMLDESIGNER_ANCHORLINE_H
diff --git a/src/plugins/qmldesigner/designercore/include/qmlanchors.h b/src/plugins/qmldesigner/designercore/include/qmlanchors.h
index bc5bc7c240..8b0574bc72 100644
--- a/src/plugins/qmldesigner/designercore/include/qmlanchors.h
+++ b/src/plugins/qmldesigner/designercore/include/qmlanchors.h
@@ -1,78 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-****************************************************************************/
#ifndef QmlAnchors_H
#define QmlAnchors_H
#include <qmldesignercorelib_global.h>
#include <qmlitemnode.h>
-
+#include "anchorline.h"
namespace QmlDesigner {
-class QMLDESIGNERCORE_EXPORT AnchorLine
-{
-public:
- enum Type {
- Invalid = 0x0,
- NoAnchor = Invalid,
- Left = 0x01,
- Right = 0x02,
- Top = 0x04,
- Bottom = 0x08,
- HorizontalCenter = 0x10,
- VerticalCenter = 0x20,
- Baseline = 0x40,
-
- Fill = Left | Right | Top | Bottom,
- Center = VerticalCenter | HorizontalCenter,
- HorizontalMask = Left | Right | HorizontalCenter,
- VerticalMask = Top | Bottom | VerticalCenter | Baseline,
- AllMask = VerticalMask | HorizontalMask
- };
-
- AnchorLine() : m_qmlItemNode(QmlItemNode()), m_type(Invalid) {}
- AnchorLine(const QmlItemNode &fxItemNode, Type type) : m_qmlItemNode(fxItemNode), m_type(type) {}
- Type type() const { return m_type; }
- bool isValid() const { return m_type != Invalid && m_qmlItemNode.isValid(); }
-
- static bool isHorizontalAnchorLine(Type anchorline);
- static bool isVerticalAnchorLine(Type anchorline);
-
- QmlItemNode qmlItemNode() const;
-
-private:
- QmlItemNode m_qmlItemNode;
- Type m_type;
-};
-
-
class QMLDESIGNERCORE_EXPORT QmlAnchors
{
public:
@@ -80,17 +15,17 @@ public:
bool isValid() const;
- void setAnchor(AnchorLine::Type sourceAnchorLineType,
+ void setAnchor(AnchorLineType sourceAnchorLineType,
const QmlItemNode &targetModelNode,
- AnchorLine::Type targetAnchorLineType);
+ AnchorLineType targetAnchorLineType);
bool canAnchor(const QmlItemNode &targetModelNode) const;
- AnchorLine::Type possibleAnchorLines(AnchorLine::Type sourceAnchorLineType,
+ AnchorLineType possibleAnchorLines(AnchorLineType sourceAnchorLineType,
const QmlItemNode &targetModelNode) const;
- AnchorLine instanceAnchor(AnchorLine::Type sourceAnchorLineType) const;
+ AnchorLine instanceAnchor(AnchorLineType sourceAnchorLineType) const;
- void removeAnchor(AnchorLine::Type sourceAnchorLineType);
+ void removeAnchor(AnchorLineType sourceAnchorLineType);
void removeAnchors();
- bool instanceHasAnchor(AnchorLine::Type sourceAnchorLineType) const;
+ bool instanceHasAnchor(AnchorLineType sourceAnchorLineType) const;
bool instanceHasAnchors() const;
double instanceLeftAnchorLine() const;
double instanceTopAnchorLine() const;
@@ -98,26 +33,26 @@ public:
double instanceBottomAnchorLine() const;
double instanceHorizontalCenterAnchorLine() const;
double instanceVerticalCenterAnchorLine() const;
- double instanceAnchorLine(AnchorLine::Type anchorLine) const;
+ double instanceAnchorLine(AnchorLineType anchorLine) const;
- void setMargin(AnchorLine::Type sourceAnchorLineType, double margin) const;
- bool instanceHasMargin(AnchorLine::Type sourceAnchorLineType) const;
- double instanceMargin(AnchorLine::Type sourceAnchorLineType) const;
- void removeMargin(AnchorLine::Type sourceAnchorLineType);
+ void setMargin(AnchorLineType sourceAnchorLineType, double margin) const;
+ bool instanceHasMargin(AnchorLineType sourceAnchorLineType) const;
+ double instanceMargin(AnchorLineType sourceAnchorLineType) const;
+ void removeMargin(AnchorLineType sourceAnchorLineType);
void removeMargins();
void fill();
void centerIn();
- bool checkForCycle(AnchorLine::Type anchorLineTyp, const QmlItemNode &sourceItem) const;
+ bool checkForCycle(AnchorLineType anchorLineTyp, const QmlItemNode &sourceItem) const;
bool checkForHorizontalCycle(const QmlItemNode &sourceItem) const;
bool checkForVerticalCycle(const QmlItemNode &sourceItem) const;
QmlItemNode qmlItemNode() const;
bool modelHasAnchors() const;
- bool modelHasAnchor(AnchorLine::Type sourceAnchorLineType) const;
- AnchorLine modelAnchor(AnchorLine::Type sourceAnchorLineType) const;
+ bool modelHasAnchor(AnchorLineType sourceAnchorLineType) const;
+ AnchorLine modelAnchor(AnchorLineType sourceAnchorLineType) const;
private:
diff --git a/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h b/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h
index 724f7e5391..a1ad1acad9 100644
--- a/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h
+++ b/src/plugins/qmldesigner/designercore/include/qmldesignercorelib_global.h
@@ -49,6 +49,24 @@ typedef QByteArray PropertyName;
typedef QList<PropertyName> PropertyNameList;
typedef QByteArray TypeName;
typedef QByteArray IdName;
+
+enum AnchorLineType {
+ AnchorLineInvalid = 0x0,
+ AnchorLineNoAnchor = AnchorLineInvalid,
+ AnchorLineLeft = 0x01,
+ AnchorLineRight = 0x02,
+ AnchorLineTop = 0x04,
+ AnchorLineBottom = 0x08,
+ AnchorLineHorizontalCenter = 0x10,
+ AnchorLineVerticalCenter = 0x20,
+ AnchorLineBaseline = 0x40,
+
+ AnchorLineFill = AnchorLineLeft | AnchorLineRight | AnchorLineTop | AnchorLineBottom,
+ AnchorLineCenter = AnchorLineVerticalCenter | AnchorLineHorizontalCenter,
+ AnchorLineHorizontalMask = AnchorLineLeft | AnchorLineRight | AnchorLineHorizontalCenter,
+ AnchorLineVerticalMask = AnchorLineTop | AnchorLineBottom | AnchorLineVerticalCenter | AnchorLineBaseline,
+ AnchorLineAllMask = AnchorLineVerticalMask | AnchorLineHorizontalMask
+};
}
//#if defined(TEST_EXPORTS)
//#if defined(CORE_LIBRARY)
diff --git a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h
index e6486bdce1..006df1ce64 100644
--- a/src/plugins/qmldesigner/designercore/include/qmlitemnode.h
+++ b/src/plugins/qmldesigner/designercore/include/qmlitemnode.h
@@ -74,6 +74,7 @@ public:
bool hasChildren() const;
bool hasResources() const;
+ bool instanceHasAnchor(AnchorLineType sourceAnchorLineType) const;
bool instanceHasAnchors() const;
bool instanceHasShowContent() const;
diff --git a/src/plugins/qmldesigner/designercore/model/anchorline.cpp b/src/plugins/qmldesigner/designercore/model/anchorline.cpp
new file mode 100644
index 0000000000..f2b5a56d73
--- /dev/null
+++ b/src/plugins/qmldesigner/designercore/model/anchorline.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "anchorline.h"
+
+namespace QmlDesigner {
+
+AnchorLine::AnchorLine()
+ : m_qmlItemNode(QmlItemNode())
+ , m_type(AnchorLineInvalid)
+{}
+
+AnchorLine::AnchorLine(const QmlItemNode &qmlItemNode, AnchorLineType type)
+ : m_qmlItemNode(qmlItemNode),
+ m_type(type)
+{}
+
+AnchorLineType AnchorLine::type() const
+{
+ return m_type;
+}
+
+bool AnchorLine::isValid() const
+{
+ return m_type != AnchorLineInvalid && m_qmlItemNode.isValid();
+}
+
+bool AnchorLine::isHorizontalAnchorLine(AnchorLineType anchorline)
+{
+ return anchorline & AnchorLineHorizontalMask;
+}
+
+bool AnchorLine::isVerticalAnchorLine(AnchorLineType anchorline)
+{
+ return anchorline & AnchorLineVerticalMask;
+}
+
+QmlItemNode AnchorLine::qmlItemNode() const
+{
+ return m_qmlItemNode;
+}
+
+} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
index 23ee802bf2..606239fcf8 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlanchors.cpp
@@ -36,70 +36,60 @@
namespace QmlDesigner {
-static PropertyName lineTypeToString(AnchorLine::Type lineType)
+static PropertyName lineTypeToString(AnchorLineType lineType)
{
switch (lineType) {
- case AnchorLine::Left: return PropertyName("left");
- case AnchorLine::Top: return PropertyName("top");
- case AnchorLine::Right: return PropertyName("right");
- case AnchorLine::Bottom: return PropertyName("bottom");
- case AnchorLine::HorizontalCenter: return PropertyName("horizontalCenter");
- case AnchorLine::VerticalCenter: return PropertyName("verticalCenter");
- case AnchorLine::Baseline: return PropertyName("baseline");
- case AnchorLine::Fill: return PropertyName("fill");
- case AnchorLine::Center: return PropertyName("centerIn");
+ case AnchorLineLeft: return PropertyName("left");
+ case AnchorLineTop: return PropertyName("top");
+ case AnchorLineRight: return PropertyName("right");
+ case AnchorLineBottom: return PropertyName("bottom");
+ case AnchorLineHorizontalCenter: return PropertyName("horizontalCenter");
+ case AnchorLineVerticalCenter: return PropertyName("verticalCenter");
+ case AnchorLineBaseline: return PropertyName("baseline");
+ case AnchorLineFill: return PropertyName("fill");
+ case AnchorLineCenter: return PropertyName("centerIn");
default: return PropertyName();
}
}
-bool AnchorLine::isHorizontalAnchorLine(Type anchorline)
-{
- return anchorline & HorizontalMask;
-}
-
-bool AnchorLine::isVerticalAnchorLine(Type anchorline)
-{
- return anchorline & VerticalMask;
-}
-
-static AnchorLine::Type propertyNameToLineType(const QString & string)
+static AnchorLineType propertyNameToLineType(const QString & string)
{
if (string == QLatin1String("left"))
- return AnchorLine::Left;
+ return AnchorLineLeft;
else if (string == QLatin1String("top"))
- return AnchorLine::Top;
+ return AnchorLineTop;
else if (string == QLatin1String("right"))
- return AnchorLine::Right;
+ return AnchorLineRight;
else if (string == QLatin1String("bottom"))
- return AnchorLine::Bottom;
+ return AnchorLineBottom;
else if (string == QLatin1String("horizontalCenter"))
- return AnchorLine::HorizontalCenter;
+ return AnchorLineHorizontalCenter;
else if (string == QLatin1String("verticalCenter"))
- return AnchorLine::VerticalCenter;
+ return AnchorLineVerticalCenter;
else if (string == QLatin1String("baseline"))
- return AnchorLine::VerticalCenter;
+ return AnchorLineVerticalCenter;
else if (string == QLatin1String("centerIn"))
- return AnchorLine::Center;
+ return AnchorLineCenter;
else if (string == QLatin1String("fill"))
- return AnchorLine::Fill;
+ return AnchorLineFill;
- return AnchorLine::Invalid;
+ return AnchorLineInvalid;
}
-static PropertyName marginPropertyName(AnchorLine::Type lineType)
+static PropertyName marginPropertyName(AnchorLineType lineType)
{
switch (lineType) {
- case AnchorLine::Left: return PropertyName("anchors.leftMargin");
- case AnchorLine::Top: return PropertyName("anchors.topMargin");
- case AnchorLine::Right: return PropertyName("anchors.rightMargin");
- case AnchorLine::Bottom: return PropertyName("anchors.bottomMargin");
- case AnchorLine::HorizontalCenter: return PropertyName("anchors.horizontalCenterOffset");
- case AnchorLine::VerticalCenter: return PropertyName("anchors.verticalCenterOffset");
+ case AnchorLineLeft: return PropertyName("anchors.leftMargin");
+ case AnchorLineTop: return PropertyName("anchors.topMargin");
+ case AnchorLineRight: return PropertyName("anchors.rightMargin");
+ case AnchorLineBottom: return PropertyName("anchors.bottomMargin");
+ case AnchorLineHorizontalCenter: return PropertyName("anchors.horizontalCenterOffset");
+ case AnchorLineVerticalCenter: return PropertyName("anchors.verticalCenterOffset");
default: return PropertyName();
}
}
-static PropertyName anchorPropertyName(AnchorLine::Type lineType)
+static PropertyName anchorPropertyName(AnchorLineType lineType)
{
const PropertyName typeString = lineTypeToString(lineType);
@@ -121,35 +111,35 @@ QmlItemNode QmlAnchors::qmlItemNode() const
bool QmlAnchors::modelHasAnchors() const
{
- return modelHasAnchor(AnchorLine::Left)
- || modelHasAnchor(AnchorLine::Right)
- || modelHasAnchor(AnchorLine::Top)
- || modelHasAnchor(AnchorLine::Bottom)
- || modelHasAnchor(AnchorLine::HorizontalCenter)
- || modelHasAnchor(AnchorLine::VerticalCenter)
- || modelHasAnchor(AnchorLine::Baseline);
+ return modelHasAnchor(AnchorLineLeft)
+ || modelHasAnchor(AnchorLineRight)
+ || modelHasAnchor(AnchorLineTop)
+ || modelHasAnchor(AnchorLineBottom)
+ || modelHasAnchor(AnchorLineHorizontalCenter)
+ || modelHasAnchor(AnchorLineVerticalCenter)
+ || modelHasAnchor(AnchorLineBaseline);
}
-bool QmlAnchors::modelHasAnchor(AnchorLine::Type sourceAnchorLineType) const
+bool QmlAnchors::modelHasAnchor(AnchorLineType sourceAnchorLineType) const
{
const PropertyName propertyName = anchorPropertyName(sourceAnchorLineType);
- if (sourceAnchorLineType & AnchorLine::Fill)
+ if (sourceAnchorLineType & AnchorLineFill)
return qmlItemNode().modelNode().hasBindingProperty(propertyName) || qmlItemNode().modelNode().hasBindingProperty("anchors.fill");
- if (sourceAnchorLineType & AnchorLine::Center)
+ if (sourceAnchorLineType & AnchorLineCenter)
return qmlItemNode().modelNode().hasBindingProperty(propertyName) || qmlItemNode().modelNode().hasBindingProperty("anchors.centerIn");
return qmlItemNode().modelNode().hasBindingProperty(anchorPropertyName(sourceAnchorLineType));
}
-AnchorLine QmlAnchors::modelAnchor(AnchorLine::Type sourceAnchorLineType) const
+AnchorLine QmlAnchors::modelAnchor(AnchorLineType sourceAnchorLineType) const
{
QPair<PropertyName, ModelNode> targetAnchorLinePair;
- if (sourceAnchorLineType & AnchorLine::Fill && qmlItemNode().modelNode().hasBindingProperty("anchors.fill")) {
+ if (sourceAnchorLineType & AnchorLineFill && qmlItemNode().modelNode().hasBindingProperty("anchors.fill")) {
targetAnchorLinePair.second = qmlItemNode().modelNode().bindingProperty("anchors.fill").resolveToModelNode();
targetAnchorLinePair.first = lineTypeToString(sourceAnchorLineType);
- } else if (sourceAnchorLineType & AnchorLine::Center && qmlItemNode().modelNode().hasBindingProperty("anchors.centerIn")) {
+ } else if (sourceAnchorLineType & AnchorLineCenter && qmlItemNode().modelNode().hasBindingProperty("anchors.centerIn")) {
targetAnchorLinePair.second = qmlItemNode().modelNode().bindingProperty("anchors.centerIn").resolveToModelNode();
targetAnchorLinePair.first = lineTypeToString(sourceAnchorLineType);
} else {
@@ -158,9 +148,9 @@ AnchorLine QmlAnchors::modelAnchor(AnchorLine::Type sourceAnchorLineType) const
targetAnchorLinePair.second = binding.parentModelNode();
}
- AnchorLine::Type targetAnchorLine = propertyNameToLineType(targetAnchorLinePair.first);
+ AnchorLineType targetAnchorLine = propertyNameToLineType(targetAnchorLinePair.first);
- if (targetAnchorLine == AnchorLine::Invalid )
+ if (targetAnchorLine == AnchorLineInvalid )
return AnchorLine();
@@ -172,14 +162,14 @@ bool QmlAnchors::isValid() const
return m_qmlItemNode.isValid();
}
-void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine,
+void QmlAnchors::setAnchor(AnchorLineType sourceAnchorLine,
const QmlItemNode &targetQmlItemNode,
- AnchorLine::Type targetAnchorLine)
+ AnchorLineType targetAnchorLine)
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::setAnchor"));
if (qmlItemNode().isInBaseState()) {
- if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill))
- || ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLine::Center)))) {
+ if ((qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill))
+ || ((qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)))) {
removeAnchor(sourceAnchorLine);
}
@@ -188,7 +178,7 @@ void QmlAnchors::setAnchor(AnchorLine::Type sourceAnchorLine,
QString targetExpression = targetModelNode.validId();
if (targetQmlItemNode.modelNode() == qmlItemNode().modelNode().parentProperty().parentModelNode())
targetExpression = "parent";
- if (sourceAnchorLine != AnchorLine::Center && sourceAnchorLine != AnchorLine::Fill)
+ if (sourceAnchorLine != AnchorLineCenter && sourceAnchorLine != AnchorLineFill)
targetExpression = targetExpression + QLatin1Char('.') + lineTypeToString(targetAnchorLine);
qmlItemNode().modelNode().bindingProperty(propertyName).setExpression(targetExpression);
}
@@ -285,41 +275,41 @@ bool QmlAnchors::canAnchor(const QmlItemNode &targetModelNode) const
return false;
}
-AnchorLine::Type QmlAnchors::possibleAnchorLines(AnchorLine::Type sourceAnchorLineType,
- const QmlItemNode &targetQmlItemNode) const
+AnchorLineType QmlAnchors::possibleAnchorLines(AnchorLineType sourceAnchorLineType,
+ const QmlItemNode &targetQmlItemNode) const
{
if (!canAnchor(targetQmlItemNode))
- return AnchorLine::Invalid;
+ return AnchorLineInvalid;
if (AnchorLine::isHorizontalAnchorLine(sourceAnchorLineType)) {
if (!detectHorizontalCycle(targetQmlItemNode, QList<ModelNode>() << qmlItemNode().modelNode()))
- return AnchorLine::HorizontalMask;
+ return AnchorLineHorizontalMask;
}
if (AnchorLine::isVerticalAnchorLine(sourceAnchorLineType)) {
if (!detectVerticalCycle(targetQmlItemNode, QList<ModelNode>() << qmlItemNode().modelNode()))
- return AnchorLine::VerticalMask;
+ return AnchorLineVerticalMask;
}
- return AnchorLine::Invalid;
+ return AnchorLineInvalid;
}
-AnchorLine QmlAnchors::instanceAnchor(AnchorLine::Type sourceAnchorLine) const
+AnchorLine QmlAnchors::instanceAnchor(AnchorLineType sourceAnchorLine) const
{
QPair<PropertyName, qint32> targetAnchorLinePair;
- if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill)) {
+ if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) {
targetAnchorLinePair = qmlItemNode().nodeInstance().anchor("anchors.fill");
targetAnchorLinePair.first = lineTypeToString(sourceAnchorLine); // TODO: looks wrong
- } else if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLine::Center)) {
+ } else if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)) {
targetAnchorLinePair = qmlItemNode().nodeInstance().anchor("anchors.centerIn");
targetAnchorLinePair.first = lineTypeToString(sourceAnchorLine);
} else {
targetAnchorLinePair = qmlItemNode().nodeInstance().anchor(anchorPropertyName(sourceAnchorLine));
}
- AnchorLine::Type targetAnchorLine = propertyNameToLineType(targetAnchorLinePair.first);
+ AnchorLineType targetAnchorLine = propertyNameToLineType(targetAnchorLinePair.first);
- if (targetAnchorLine == AnchorLine::Invalid )
+ if (targetAnchorLine == AnchorLineInvalid )
return AnchorLine();
if (targetAnchorLinePair.second < 0) //there might be no node instance for the parent
@@ -328,19 +318,19 @@ AnchorLine QmlAnchors::instanceAnchor(AnchorLine::Type sourceAnchorLine) const
return AnchorLine(QmlItemNode(qmlItemNode().nodeForInstance(qmlItemNode().nodeInstanceView()->instanceForId(targetAnchorLinePair.second))), targetAnchorLine);
}
-void QmlAnchors::removeAnchor(AnchorLine::Type sourceAnchorLine)
+void QmlAnchors::removeAnchor(AnchorLineType sourceAnchorLine)
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeAnchor"));
if (qmlItemNode().isInBaseState()) {
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
- if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLine::Fill)) {
+ if (qmlItemNode().nodeInstance().hasAnchor("anchors.fill") && (sourceAnchorLine & AnchorLineFill)) {
qmlItemNode().modelNode().removeProperty("anchors.fill");
qmlItemNode().modelNode().bindingProperty("anchors.top").setExpression("parent.top");
qmlItemNode().modelNode().bindingProperty("anchors.left").setExpression("parent.left");
qmlItemNode().modelNode().bindingProperty("anchors.bottom").setExpression("parent.bottom");
qmlItemNode().modelNode().bindingProperty("anchors.right").setExpression("parent.right");
- } else if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLine::Center)) {
+ } else if (qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn") && (sourceAnchorLine & AnchorLineCenter)) {
qmlItemNode().modelNode().removeProperty("anchors.centerIn");
qmlItemNode().modelNode().bindingProperty("anchors.horizontalCenter").setExpression("parent.horizontalCenter");
qmlItemNode().modelNode().bindingProperty("anchors.verticalCenter").setExpression("parent.verticalCenter");
@@ -373,14 +363,14 @@ void QmlAnchors::removeAnchors()
qmlItemNode().modelNode().removeProperty("anchors.baseline");
}
-bool QmlAnchors::instanceHasAnchor(AnchorLine::Type sourceAnchorLine) const
+bool QmlAnchors::instanceHasAnchor(AnchorLineType sourceAnchorLine) const
{
const PropertyName propertyName = anchorPropertyName(sourceAnchorLine);
- if (sourceAnchorLine & AnchorLine::Fill)
+ if (sourceAnchorLine & AnchorLineFill)
return qmlItemNode().nodeInstance().hasAnchor(propertyName) || qmlItemNode().nodeInstance().hasAnchor("anchors.fill");
- if (sourceAnchorLine & AnchorLine::Center)
+ if (sourceAnchorLine & AnchorLineCenter)
return qmlItemNode().nodeInstance().hasAnchor(propertyName) || qmlItemNode().nodeInstance().hasAnchor("anchors.centerIn");
@@ -389,13 +379,13 @@ bool QmlAnchors::instanceHasAnchor(AnchorLine::Type sourceAnchorLine) const
bool QmlAnchors::instanceHasAnchors() const
{
- return instanceHasAnchor(AnchorLine::Left) ||
- instanceHasAnchor(AnchorLine::Right) ||
- instanceHasAnchor(AnchorLine::Top) ||
- instanceHasAnchor(AnchorLine::Bottom) ||
- instanceHasAnchor(AnchorLine::HorizontalCenter) ||
- instanceHasAnchor(AnchorLine::VerticalCenter) ||
- instanceHasAnchor(AnchorLine::Baseline);
+ return instanceHasAnchor(AnchorLineLeft) ||
+ instanceHasAnchor(AnchorLineRight) ||
+ instanceHasAnchor(AnchorLineTop) ||
+ instanceHasAnchor(AnchorLineBottom) ||
+ instanceHasAnchor(AnchorLineHorizontalCenter) ||
+ instanceHasAnchor(AnchorLineVerticalCenter) ||
+ instanceHasAnchor(AnchorLineBaseline);
}
QRectF contentRect(const NodeInstance &nodeInstance)
@@ -434,28 +424,28 @@ double QmlAnchors::instanceVerticalCenterAnchorLine() const
return (instanceBottomAnchorLine() + instanceTopAnchorLine()) / 2.0;
}
-double QmlAnchors::instanceAnchorLine(AnchorLine::Type anchorLine) const
+double QmlAnchors::instanceAnchorLine(AnchorLineType anchorLine) const
{
switch (anchorLine) {
- case AnchorLine::Left: return instanceLeftAnchorLine();
- case AnchorLine::Top: return instanceTopAnchorLine();
- case AnchorLine::Bottom: return instanceBottomAnchorLine();
- case AnchorLine::Right: return instanceRightAnchorLine();
- case AnchorLine::HorizontalCenter: return instanceHorizontalCenterAnchorLine();
- case AnchorLine::VerticalCenter: return instanceVerticalCenterAnchorLine();
+ case AnchorLineLeft: return instanceLeftAnchorLine();
+ case AnchorLineTop: return instanceTopAnchorLine();
+ case AnchorLineBottom: return instanceBottomAnchorLine();
+ case AnchorLineRight: return instanceRightAnchorLine();
+ case AnchorLineHorizontalCenter: return instanceHorizontalCenterAnchorLine();
+ case AnchorLineVerticalCenter: return instanceVerticalCenterAnchorLine();
default: return 0;
}
return 0.0;
}
-void QmlAnchors::setMargin(AnchorLine::Type sourceAnchorLineType, double margin) const
+void QmlAnchors::setMargin(AnchorLineType sourceAnchorLineType, double margin) const
{
PropertyName propertyName = marginPropertyName(sourceAnchorLineType);
qmlItemNode().setVariantProperty(propertyName, qRound(margin));
}
-bool QmlAnchors::instanceHasMargin(AnchorLine::Type sourceAnchorLineType) const
+bool QmlAnchors::instanceHasMargin(AnchorLineType sourceAnchorLineType) const
{
return !qIsNull(instanceMargin(sourceAnchorLineType));
}
@@ -463,20 +453,20 @@ bool QmlAnchors::instanceHasMargin(AnchorLine::Type sourceAnchorLineType) const
static bool checkForHorizontalCycleRecusive(const QmlAnchors &anchors, QList<QmlItemNode> &visitedItems)
{
visitedItems.append(anchors.qmlItemNode());
- if (anchors.instanceHasAnchor(AnchorLine::Left)) {
- AnchorLine leftAnchorLine = anchors.instanceAnchor(AnchorLine::Left);
+ if (anchors.instanceHasAnchor(AnchorLineLeft)) {
+ AnchorLine leftAnchorLine = anchors.instanceAnchor(AnchorLineLeft);
if (visitedItems.contains(leftAnchorLine.qmlItemNode()) || checkForHorizontalCycleRecusive(leftAnchorLine.qmlItemNode().anchors(), visitedItems))
return true;
}
- if (anchors.instanceHasAnchor(AnchorLine::Right)) {
- AnchorLine rightAnchorLine = anchors.instanceAnchor(AnchorLine::Right);
+ if (anchors.instanceHasAnchor(AnchorLineRight)) {
+ AnchorLine rightAnchorLine = anchors.instanceAnchor(AnchorLineRight);
if (visitedItems.contains(rightAnchorLine.qmlItemNode()) || checkForHorizontalCycleRecusive(rightAnchorLine.qmlItemNode().anchors(), visitedItems))
return true;
}
- if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) {
- AnchorLine horizontalCenterAnchorLine = anchors.instanceAnchor(AnchorLine::HorizontalCenter);
+ if (anchors.instanceHasAnchor(AnchorLineHorizontalCenter)) {
+ AnchorLine horizontalCenterAnchorLine = anchors.instanceAnchor(AnchorLineHorizontalCenter);
if (visitedItems.contains(horizontalCenterAnchorLine.qmlItemNode()) || checkForHorizontalCycleRecusive(horizontalCenterAnchorLine.qmlItemNode().anchors(), visitedItems))
return true;
}
@@ -488,20 +478,20 @@ static bool checkForVerticalCycleRecusive(const QmlAnchors &anchors, QList<QmlIt
{
visitedItems.append(anchors.qmlItemNode());
- if (anchors.instanceHasAnchor(AnchorLine::Top)) {
- AnchorLine topAnchorLine = anchors.instanceAnchor(AnchorLine::Top);
+ if (anchors.instanceHasAnchor(AnchorLineTop)) {
+ AnchorLine topAnchorLine = anchors.instanceAnchor(AnchorLineTop);
if (visitedItems.contains(topAnchorLine.qmlItemNode()) || checkForVerticalCycleRecusive(topAnchorLine.qmlItemNode().anchors(), visitedItems))
return true;
}
- if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
- AnchorLine bottomAnchorLine = anchors.instanceAnchor(AnchorLine::Bottom);
+ if (anchors.instanceHasAnchor(AnchorLineBottom)) {
+ AnchorLine bottomAnchorLine = anchors.instanceAnchor(AnchorLineBottom);
if (visitedItems.contains(bottomAnchorLine.qmlItemNode()) || checkForVerticalCycleRecusive(bottomAnchorLine.qmlItemNode().anchors(), visitedItems))
return true;
}
- if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) {
- AnchorLine verticalCenterAnchorLine = anchors.instanceAnchor(AnchorLine::VerticalCenter);
+ if (anchors.instanceHasAnchor(AnchorLineVerticalCenter)) {
+ AnchorLine verticalCenterAnchorLine = anchors.instanceAnchor(AnchorLineVerticalCenter);
if (visitedItems.contains(verticalCenterAnchorLine.qmlItemNode()) || checkForVerticalCycleRecusive(verticalCenterAnchorLine.qmlItemNode().anchors(), visitedItems))
return true;
}
@@ -525,12 +515,12 @@ bool QmlAnchors::checkForVerticalCycle(const QmlItemNode &sourceItem) const
return checkForVerticalCycleRecusive(*this, visitedItems);
}
-double QmlAnchors::instanceMargin(AnchorLine::Type sourceAnchorLineType) const
+double QmlAnchors::instanceMargin(AnchorLineType sourceAnchorLineType) const
{
return qmlItemNode().nodeInstance().property(marginPropertyName(sourceAnchorLineType)).toDouble();
}
-void QmlAnchors::removeMargin(AnchorLine::Type sourceAnchorLineType)
+void QmlAnchors::removeMargin(AnchorLineType sourceAnchorLineType)
{
if (qmlItemNode().isInBaseState()) {
PropertyName propertyName = marginPropertyName(sourceAnchorLineType);
@@ -541,17 +531,12 @@ void QmlAnchors::removeMargin(AnchorLine::Type sourceAnchorLineType)
void QmlAnchors::removeMargins()
{
RewriterTransaction transaction = qmlItemNode().view()->beginRewriterTransaction(QByteArrayLiteral("QmlAnchors::removeMargins"));
- removeMargin(AnchorLine::Left);
- removeMargin(AnchorLine::Right);
- removeMargin(AnchorLine::Top);
- removeMargin(AnchorLine::Bottom);
- removeMargin(AnchorLine::HorizontalCenter);
- removeMargin(AnchorLine::VerticalCenter);
-}
-
-QmlItemNode AnchorLine::qmlItemNode() const
-{
- return m_qmlItemNode;
+ removeMargin(AnchorLineLeft);
+ removeMargin(AnchorLineRight);
+ removeMargin(AnchorLineTop);
+ removeMargin(AnchorLineBottom);
+ removeMargin(AnchorLineHorizontalCenter);
+ removeMargin(AnchorLineVerticalCenter);
}
void QmlAnchors::fill()
@@ -570,9 +555,9 @@ void QmlAnchors::centerIn()
qmlItemNode().modelNode().bindingProperty("anchors.centerIn").setExpression("parent");
}
-bool QmlAnchors::checkForCycle(AnchorLine::Type anchorLineTyp, const QmlItemNode &sourceItem) const
+bool QmlAnchors::checkForCycle(AnchorLineType anchorLineTyp, const QmlItemNode &sourceItem) const
{
- if (anchorLineTyp & AnchorLine::HorizontalMask)
+ if (anchorLineTyp & AnchorLineHorizontalMask)
return checkForHorizontalCycle(sourceItem);
else
return checkForVerticalCycle(sourceItem);
diff --git a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
index 18217bb569..d6b87bcd2f 100644
--- a/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
+++ b/src/plugins/qmldesigner/designercore/model/qmlitemnode.cpp
@@ -606,13 +606,13 @@ bool QmlItemNode::hasAnySubModelNodes() const
void QmlItemNode::setPosition(const QPointF &position)
{
if (!hasBindingProperty("x")
- && !anchors().instanceHasAnchor(AnchorLine::Left)
- && !anchors().instanceHasAnchor(AnchorLine::HorizontalCenter))
+ && !anchors().instanceHasAnchor(AnchorLineLeft)
+ && !anchors().instanceHasAnchor(AnchorLineHorizontalCenter))
setVariantProperty("x", qRound(position.x()));
if (!hasBindingProperty("y")
- && !anchors().instanceHasAnchor(AnchorLine::Top)
- && !anchors().instanceHasAnchor(AnchorLine::VerticalCenter))
+ && !anchors().instanceHasAnchor(AnchorLineTop)
+ && !anchors().instanceHasAnchor(AnchorLineVerticalCenter))
setVariantProperty("y", qRound(position.y()));
}
@@ -624,10 +624,10 @@ void QmlItemNode::setPostionInBaseState(const QPointF &position)
void QmlItemNode::setSize(const QSizeF &size)
{
- if (!hasBindingProperty("width") && !anchors().instanceHasAnchor(AnchorLine::Right))
+ if (!hasBindingProperty("width") && !anchors().instanceHasAnchor(AnchorLineRight))
setVariantProperty("width", qRound(size.width()));
- if (!hasBindingProperty("height") && !anchors().instanceHasAnchor(AnchorLine::Bottom))
+ if (!hasBindingProperty("height") && !anchors().instanceHasAnchor(AnchorLineBottom))
setVariantProperty("height", qRound(size.height()));
}