Commit e9c4965c authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Move setPostion and setSize to QmlItemNode



Change-Id: I7a6e3705807651a81b1408ce4dfaea2cdda731df
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent d27950b8
......@@ -298,10 +298,9 @@ void MoveManipulator::update(const QPointF& updatePoint, Snapper::Snapping useSn
if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
anchors.setMargin(AnchorLine::VerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y());
setPosition(item->qmlItemNode(), positionInContainerSpace);
item->qmlItemNode().setPosition(positionInContainerSpace);
} else {
item->qmlItemNode().modelNode().variantProperty("x").setValue(qRound(positionInContainerSpace.x()));
item->qmlItemNode().modelNode().variantProperty("y").setValue(qRound(positionInContainerSpace.y()));
item->qmlItemNode().setPostionInBaseState(positionInContainerSpace);
}
}
}
......@@ -415,7 +414,7 @@ void MoveManipulator::moveBy(double deltaX, double deltaY)
if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter))
anchors.setMargin(AnchorLine::VerticalCenter, anchors.instanceMargin(AnchorLine::VerticalCenter) + deltaY);
setPosition(item->qmlItemNode(), QPointF(item->qmlItemNode().instanceValue("x").toDouble() + deltaX,
item->qmlItemNode().setPosition(QPointF(item->qmlItemNode().instanceValue("x").toDouble() + deltaX,
item->qmlItemNode().instanceValue("y").toDouble() + deltaY));
}
}
......@@ -453,13 +452,4 @@ bool MoveManipulator::isActive() const
return m_isActive;
}
void MoveManipulator::setPosition(QmlItemNode itemNode, const QPointF &position)
{
if (!itemNode.hasBindingProperty("x"))
itemNode.setVariantProperty("x", qRound(position.x()));
if (!itemNode.hasBindingProperty("y"))
itemNode.setVariantProperty("y", qRound(position.y()));
}
}
......@@ -95,8 +95,6 @@ protected:
bool itemsCanReparented() const;
void setPosition(QmlItemNode itemNode, const QPointF &position);
void adjustAnchoringOfItem(FormEditorItem *item);
private:
......
......@@ -146,8 +146,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.height() < minimumHeight)
boundingRect.setHeight(minimumHeight);
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setSize(boundingRect.size());
if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
anchors.setMargin(AnchorLine::Bottom,
......@@ -184,8 +183,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.height() < minimumHeight)
boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height());
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Top)) {
......@@ -223,8 +222,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.width() < minimumWidth)
boundingRect.setWidth(minimumWidth);
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition( m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Top)) {
anchors.setMargin(AnchorLine::Top,
......@@ -261,8 +260,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.width() < minimumWidth)
boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width());
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Left)) {
anchors.setMargin(AnchorLine::Left,
......@@ -290,7 +289,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.height() < minimumHeight)
boundingRect.setHeight(minimumHeight);
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setSize(boundingRect.size());
if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
anchors.setMargin(AnchorLine::Bottom,
......@@ -313,8 +312,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.height() < minimumHeight)
boundingRect.setTop(boundingRect.top() - minimumHeight + boundingRect.height());
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Top)) {
anchors.setMargin(AnchorLine::Top,
......@@ -337,7 +336,7 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.width() < minimumWidth)
boundingRect.setWidth(minimumWidth);
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
formEditorItem->qmlItemNode().setSize(boundingRect.size());
if (anchors.instanceHasAnchor(AnchorLine::Right)) {
......@@ -361,8 +360,8 @@ void ResizeManipulator::update(const QPointF& updatePoint, Snapper::Snapping use
if (boundingRect.width() < minimumWidth)
boundingRect.setLeft(boundingRect.left() - minimumWidth + boundingRect.width());
setSize(formEditorItem->qmlItemNode(), boundingRect.size());
setPosition(formEditorItem->qmlItemNode(), m_beginToParentTransform.map(boundingRect.topLeft()));
formEditorItem->qmlItemNode().setSize(boundingRect.size());
formEditorItem->qmlItemNode().setPosition(m_beginToParentTransform.map(boundingRect.topLeft()));
if (anchors.instanceHasAnchor(AnchorLine::Left)) {
anchors.setMargin(AnchorLine::Left,
......@@ -501,21 +500,4 @@ bool ResizeManipulator::isActive() const
return m_isActive;
}
void ResizeManipulator::setSize(QmlItemNode itemNode, const QSizeF &size)
{
if (!itemNode.hasBindingProperty("width"))
itemNode.setVariantProperty("width", qRound(size.width()));
if (!itemNode.hasBindingProperty("height"))
itemNode.setVariantProperty("height", qRound(size.height()));
}
void ResizeManipulator::setPosition(QmlItemNode itemNode, const QPointF &position)
{
if (!itemNode.hasBindingProperty("x"))
itemNode.setVariantProperty("x", qRound(position.x()));
if (!itemNode.hasBindingProperty("y"))
itemNode.setVariantProperty("y", qRound(position.y()));
}
}
......@@ -64,8 +64,6 @@ protected:
bool isInvalidSize(const QSizeF & size);
void deleteSnapLines();
ResizeHandleItem *resizeHandle();
void setSize(QmlItemNode itemNode, const QSizeF &size);
void setPosition(QmlItemNode itemNode, const QPointF &position);
private:
Snapper m_snapper;
......
......@@ -97,6 +97,11 @@ public:
const QList<QmlItemNode> allDirectSubModelNodes() const;
const QList<QmlItemNode> allSubModelNodes() const;
bool hasAnySubModelNodes() const;
void setPosition(const QPointF &position);
void setPostionInBaseState(const QPointF &position);
void setSize(const QSizeF &size);
};
QMLDESIGNERCORE_EXPORT uint qHash(const QmlItemNode &node);
......
......@@ -31,6 +31,7 @@
#include <metainfo.h>
#include "qmlchangeset.h"
#include "nodelistproperty.h"
#include "variantproperty.h"
#include "qmlanchors.h"
#include "invalidmodelnodeexception.h"
#include "qmlmodelview.h"
......@@ -391,4 +392,28 @@ bool QmlItemNode::hasAnySubModelNodes() const
return modelNode().hasAnySubModelNodes();
}
void QmlItemNode::setPosition(const QPointF &position)
{
if (!hasBindingProperty("x"))
setVariantProperty("x", qRound(position.x()));
if (!hasBindingProperty("y"))
setVariantProperty("y", qRound(position.y()));
}
void QmlItemNode::setPostionInBaseState(const QPointF &position)
{
modelNode().variantProperty("x").setValue(qRound(position.x()));
modelNode().variantProperty("y").setValue(qRound(position.y()));
}
void QmlItemNode::setSize(const QSizeF &size)
{
if (!hasBindingProperty("width"))
setVariantProperty("width", qRound(size.width()));
if (!hasBindingProperty("height"))
setVariantProperty("height", qRound(size.height()));
}
} //QmlDesigner
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment