forked from qt-creator/qt-creator
If you move a new item on the formeditor the item is always in the base
state The position is now setted int the base state if you drop a item on the formeditor and move it around. Task-Number: BAUHAUS-644 Reviewed-by: kkoehne
This commit is contained in:
@@ -314,7 +314,7 @@ void DragTool::move(QPointF scenePos)
|
|||||||
/* if (event->modifiers().testFlag(Qt::ControlModifier) != view()->isSnapButtonChecked())
|
/* if (event->modifiers().testFlag(Qt::ControlModifier) != view()->isSnapButtonChecked())
|
||||||
useSnapping = MoveManipulator::UseSnapping;*/
|
useSnapping = MoveManipulator::UseSnapping;*/
|
||||||
|
|
||||||
m_moveManipulator.update(scenePos, useSnapping);
|
m_moveManipulator.update(scenePos, useSnapping, MoveManipulator::UseBaseState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ QList<QRectF> MoveManipulator::tanslatedBoundingRects(const QList<QRectF> &bound
|
|||||||
/*
|
/*
|
||||||
/brief updates the position of the items.
|
/brief updates the position of the items.
|
||||||
*/
|
*/
|
||||||
void MoveManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
|
void MoveManipulator::update(const QPointF& updatePoint, Snapping useSnapping, State stateToBeManipulated)
|
||||||
{
|
{
|
||||||
deleteSnapLines(); //Since they position is changed and the item is moved the snapping lines are
|
deleteSnapLines(); //Since they position is changed and the item is moved the snapping lines are
|
||||||
//are obsolete. The new updated snapping lines (color and visibility) will be
|
//are obsolete. The new updated snapping lines (color and visibility) will be
|
||||||
@@ -226,36 +226,41 @@ void MoveManipulator::update(const QPointF& updatePoint, Snapping useSnapping)
|
|||||||
|
|
||||||
foreach (FormEditorItem* item, m_itemList) {
|
foreach (FormEditorItem* item, m_itemList) {
|
||||||
QPointF positionInContainerSpace(m_beginPositionHash.value(item) + offsetVector);
|
QPointF positionInContainerSpace(m_beginPositionHash.value(item) + offsetVector);
|
||||||
QmlAnchors anchors(item->qmlItemNode().anchors());
|
|
||||||
|
|
||||||
if (anchors.instanceHasAnchor(AnchorLine::Top)) {
|
// don't support anchors for base state because it is not needed by the droptool
|
||||||
anchors.setMargin(AnchorLine::Top, m_beginTopMarginHash.value(item) + offsetVector.y());
|
if (stateToBeManipulated == UseActualState) {
|
||||||
|
QmlAnchors anchors(item->qmlItemNode().anchors());
|
||||||
|
|
||||||
|
if (anchors.instanceHasAnchor(AnchorLine::Top)) {
|
||||||
|
anchors.setMargin(AnchorLine::Top, m_beginTopMarginHash.value(item) + offsetVector.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anchors.instanceHasAnchor(AnchorLine::Left)) {
|
||||||
|
anchors.setMargin(AnchorLine::Left, m_beginLeftMarginHash.value(item) + offsetVector.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
|
||||||
|
anchors.setMargin(AnchorLine::Bottom, m_beginBottomMarginHash.value(item) - offsetVector.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anchors.instanceHasAnchor(AnchorLine::Right)) {
|
||||||
|
anchors.setMargin(AnchorLine::Right, m_beginRightMarginHash.value(item) - offsetVector.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) {
|
||||||
|
anchors.setMargin(AnchorLine::HorizontalCenter, m_beginHorizontalCenterHash.value(item) + offsetVector.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) {
|
||||||
|
anchors.setMargin(AnchorLine::VerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
item->qmlItemNode().setPosition(positionInContainerSpace);
|
||||||
|
} else {
|
||||||
|
item->qmlItemNode().modelNode().variantProperty("x").setValue(qRound(positionInContainerSpace.x()));
|
||||||
|
item->qmlItemNode().modelNode().variantProperty("y").setValue(qRound(positionInContainerSpace.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anchors.instanceHasAnchor(AnchorLine::Left)) {
|
|
||||||
anchors.setMargin(AnchorLine::Left, m_beginLeftMarginHash.value(item) + offsetVector.x());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anchors.instanceHasAnchor(AnchorLine::Bottom)) {
|
|
||||||
anchors.setMargin(AnchorLine::Bottom, m_beginBottomMarginHash.value(item) - offsetVector.y());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anchors.instanceHasAnchor(AnchorLine::Right)) {
|
|
||||||
anchors.setMargin(AnchorLine::Right, m_beginRightMarginHash.value(item) - offsetVector.x());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anchors.instanceHasAnchor(AnchorLine::HorizontalCenter)) {
|
|
||||||
anchors.setMargin(AnchorLine::HorizontalCenter, m_beginHorizontalCenterHash.value(item) + offsetVector.x());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anchors.instanceHasAnchor(AnchorLine::VerticalCenter)) {
|
|
||||||
anchors.setMargin(AnchorLine::VerticalCenter, m_beginVerticalCenterHash.value(item) + offsetVector.y());
|
|
||||||
}
|
|
||||||
|
|
||||||
item->qmlItemNode().setPosition(positionInContainerSpace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,13 +57,18 @@ public:
|
|||||||
NoSnapping
|
NoSnapping
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum State {
|
||||||
|
UseActualState,
|
||||||
|
UseBaseState
|
||||||
|
};
|
||||||
|
|
||||||
MoveManipulator(LayerItem *layerItem, FormEditorView *view);
|
MoveManipulator(LayerItem *layerItem, FormEditorView *view);
|
||||||
~MoveManipulator();
|
~MoveManipulator();
|
||||||
void setItems(const QList<FormEditorItem*> &itemList);
|
void setItems(const QList<FormEditorItem*> &itemList);
|
||||||
void setItem(FormEditorItem* item);
|
void setItem(FormEditorItem* item);
|
||||||
|
|
||||||
void begin(const QPointF& beginPoint);
|
void begin(const QPointF& beginPoint);
|
||||||
void update(const QPointF& updatePoint, Snapping useSnapping);
|
void update(const QPointF& updatePoint, Snapping useSnapping, State stateToBeManipulated = UseActualState);
|
||||||
void reparentTo(FormEditorItem *newParent);
|
void reparentTo(FormEditorItem *newParent);
|
||||||
void end(const QPointF& endPoint);
|
void end(const QPointF& endPoint);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user