forked from qt-creator/qt-creator
QmlDesigner: Direct update of the position
This is maybe harmful shortcut in 99.99% of the cases it should work better. Change-Id: Ia162666862498ac331c9f5381cb12753d34758c1 Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
This commit is contained in:
@@ -122,6 +122,14 @@ bool MoveManipulator::itemsCanReparented() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MoveManipulator::setDirectUpdateInNodeInstances(bool directUpdate)
|
||||||
|
{
|
||||||
|
foreach (FormEditorItem* item, m_itemList) {
|
||||||
|
if (item && item->qmlItemNode().isValid())
|
||||||
|
item->qmlItemNode().nodeInstance().setUpdateTransform(!directUpdate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MoveManipulator::begin(const QPointF &beginPoint)
|
void MoveManipulator::begin(const QPointF &beginPoint)
|
||||||
{
|
{
|
||||||
m_isActive = true;
|
m_isActive = true;
|
||||||
@@ -159,6 +167,8 @@ void MoveManipulator::begin(const QPointF &beginPoint)
|
|||||||
|
|
||||||
// setOpacityForAllElements(0.62);
|
// setOpacityForAllElements(0.62);
|
||||||
|
|
||||||
|
setDirectUpdateInNodeInstances(true);
|
||||||
|
|
||||||
m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("MoveManipulator::begin"));
|
m_rewriterTransaction = m_view->beginRewriterTransaction(QByteArrayLiteral("MoveManipulator::begin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,6 +381,7 @@ void MoveManipulator::reparentTo(FormEditorItem *newParent)
|
|||||||
|
|
||||||
void MoveManipulator::end()
|
void MoveManipulator::end()
|
||||||
{
|
{
|
||||||
|
setDirectUpdateInNodeInstances(false);
|
||||||
m_isActive = false;
|
m_isActive = false;
|
||||||
deleteSnapLines();
|
deleteSnapLines();
|
||||||
clear();
|
clear();
|
||||||
|
@@ -97,6 +97,8 @@ protected:
|
|||||||
|
|
||||||
void adjustAnchoringOfItem(FormEditorItem *item);
|
void adjustAnchoringOfItem(FormEditorItem *item);
|
||||||
|
|
||||||
|
void setDirectUpdateInNodeInstances(bool directUpdate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Snapper m_snapper;
|
Snapper m_snapper;
|
||||||
QPointer<LayerItem> m_layerItem;
|
QPointer<LayerItem> m_layerItem;
|
||||||
|
@@ -86,6 +86,10 @@ public:
|
|||||||
qint32 parentId() const;
|
qint32 parentId() const;
|
||||||
qint32 instanceId() const;
|
qint32 instanceId() const;
|
||||||
|
|
||||||
|
void setUpdateTransform(bool updateTransform);
|
||||||
|
bool updateTransform() const;
|
||||||
|
void setX(double x);
|
||||||
|
void setY(double y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setProperty(const PropertyName &name, const QVariant &value);
|
void setProperty(const PropertyName &name, const QVariant &value);
|
||||||
|
@@ -136,6 +136,7 @@ public:
|
|||||||
|
|
||||||
NodeInstance activeStateInstance() const;
|
NodeInstance activeStateInstance() const;
|
||||||
|
|
||||||
|
void updatePosition(const QList<VariantProperty>& propertyList);
|
||||||
|
|
||||||
void valuesChanged(const ValuesChangedCommand &command);
|
void valuesChanged(const ValuesChangedCommand &command);
|
||||||
void pixmapChanged(const PixmapChangedCommand &command);
|
void pixmapChanged(const PixmapChangedCommand &command);
|
||||||
|
@@ -41,9 +41,12 @@ namespace QmlDesigner {
|
|||||||
|
|
||||||
class QmlItemNode;
|
class QmlItemNode;
|
||||||
class QmlPropertyChanges;
|
class QmlPropertyChanges;
|
||||||
|
class MoveManipulator;
|
||||||
|
|
||||||
class QMLDESIGNERCORE_EXPORT QmlObjectNode : public QmlModelNodeFacade
|
class QMLDESIGNERCORE_EXPORT QmlObjectNode : public QmlModelNodeFacade
|
||||||
{
|
{
|
||||||
|
friend class QmlItemNode;
|
||||||
|
friend class MoveManipulator;
|
||||||
public:
|
public:
|
||||||
QmlObjectNode();
|
QmlObjectNode();
|
||||||
QmlObjectNode(const ModelNode &modelNode);
|
QmlObjectNode(const ModelNode &modelNode);
|
||||||
|
@@ -51,7 +51,8 @@ public:
|
|||||||
hasContent(false),
|
hasContent(false),
|
||||||
isMovable(false),
|
isMovable(false),
|
||||||
isResizable(false),
|
isResizable(false),
|
||||||
isInLayoutable(false)
|
isInLayoutable(false),
|
||||||
|
updateTransform(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
qint32 parentInstanceId;
|
qint32 parentInstanceId;
|
||||||
@@ -71,6 +72,7 @@ public:
|
|||||||
bool isMovable;
|
bool isMovable;
|
||||||
bool isResizable;
|
bool isResizable;
|
||||||
bool isInLayoutable;
|
bool isInLayoutable;
|
||||||
|
bool updateTransform;
|
||||||
|
|
||||||
|
|
||||||
QHash<PropertyName, QVariant> propertyValues;
|
QHash<PropertyName, QVariant> propertyValues;
|
||||||
@@ -133,6 +135,36 @@ qint32 NodeInstance::instanceId() const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeInstance::setUpdateTransform(bool updateTransform)
|
||||||
|
{
|
||||||
|
if (d)
|
||||||
|
d->updateTransform = updateTransform;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NodeInstance::updateTransform() const
|
||||||
|
{
|
||||||
|
if (d)
|
||||||
|
d->updateTransform || d->transform.isRotating() || d->transform.isScaling();
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeInstance::setX(double x)
|
||||||
|
{
|
||||||
|
if(d && !updateTransform()) {
|
||||||
|
double dx = x - d->transform.dx();
|
||||||
|
d->transform.translate(dx, 0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeInstance::setY(double y)
|
||||||
|
{
|
||||||
|
if(d && !updateTransform()) {
|
||||||
|
double dy = y - d->transform.dy();
|
||||||
|
d->transform.translate(0.0, dy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool NodeInstance::isValid() const
|
bool NodeInstance::isValid() const
|
||||||
{
|
{
|
||||||
return instanceId() >= 0 && modelNode().isValid();
|
return instanceId() >= 0 && modelNode().isValid();
|
||||||
@@ -375,7 +407,7 @@ InformationName NodeInstance::setInformationContentItemBoundingRect(const QRectF
|
|||||||
|
|
||||||
InformationName NodeInstance::setInformationTransform(const QTransform &transform)
|
InformationName NodeInstance::setInformationTransform(const QTransform &transform)
|
||||||
{
|
{
|
||||||
if (d->transform != transform) {
|
if (updateTransform() && d->transform != transform) {
|
||||||
d->transform = transform;
|
d->transform = transform;
|
||||||
return Transform;
|
return Transform;
|
||||||
}
|
}
|
||||||
|
@@ -370,6 +370,7 @@ void NodeInstanceView::signalHandlerPropertiesChanged(const QVector<SignalHandle
|
|||||||
|
|
||||||
void NodeInstanceView::variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags /*propertyChange*/)
|
void NodeInstanceView::variantPropertiesChanged(const QList<VariantProperty>& propertyList, PropertyChangeFlags /*propertyChange*/)
|
||||||
{
|
{
|
||||||
|
updatePosition(propertyList);
|
||||||
nodeInstanceServer()->changePropertyValues(createChangeValueCommand(propertyList));
|
nodeInstanceServer()->changePropertyValues(createChangeValueCommand(propertyList));
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
@@ -673,6 +674,26 @@ NodeInstance NodeInstanceView::activeStateInstance() const
|
|||||||
return m_activeStateInstance;
|
return m_activeStateInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeInstanceView::updatePosition(const QList<VariantProperty> &propertyList)
|
||||||
|
{
|
||||||
|
QMultiHash<ModelNode, InformationName> informationChangeHash;
|
||||||
|
|
||||||
|
foreach (const VariantProperty &variantProperty, propertyList) {
|
||||||
|
if (variantProperty.name() == "x") {
|
||||||
|
NodeInstance instance = instanceForModelNode(variantProperty.parentModelNode());
|
||||||
|
instance.setX(variantProperty.value().toDouble());
|
||||||
|
informationChangeHash.insert(variantProperty.parentModelNode(), Transform);
|
||||||
|
} else if (variantProperty.name() == "y") {
|
||||||
|
NodeInstance instance = instanceForModelNode(variantProperty.parentModelNode());
|
||||||
|
instance.setY(variantProperty.value().toDouble());
|
||||||
|
informationChangeHash.insert(variantProperty.parentModelNode(), Transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!informationChangeHash.isEmpty())
|
||||||
|
emitInstanceInformationsChange(informationChangeHash);
|
||||||
|
}
|
||||||
|
|
||||||
NodeInstanceServerInterface *NodeInstanceView::nodeInstanceServer() const
|
NodeInstanceServerInterface *NodeInstanceView::nodeInstanceServer() const
|
||||||
{
|
{
|
||||||
return m_nodeInstanceServer.data();
|
return m_nodeInstanceServer.data();
|
||||||
|
Reference in New Issue
Block a user