diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2020-01-13 16:37:24 +0200 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2020-01-14 11:09:57 +0000 |
commit | e92bef2b62ece3505e3e090f0573af321b6db697 (patch) | |
tree | 04b6a84a3df47a8f51c6a7328f22d205854effde /share | |
parent | 58e2c3271e9d02fbeac54ffaa263581379e3f79c (diff) |
QmlDesigner: Hide non-dragged planes of rotate gizmo in 3D edit view
To make things clearer, non-dragged planes of rotate gizmo are hidden
for the duration of the drag. This also hides the wobbling of the
gizmo during a drag when ancestors have non-uniform scaling.
Also corrects the resulting rotation by using dragHelper mouseArea to
lock the drag plane down for the duration of the drag.
Change-Id: I2dda2a78c78d5df62626c6b6c3ed3b18bac37933
Fixes: QDS-1331
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml | 35 | ||||
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml | 9 |
2 files changed, 39 insertions, 5 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml index c46ca3cb40..a1f5a4b509 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml @@ -55,6 +55,21 @@ Node { signal rotateCommit() signal rotateChange() + function copyRingProperties(srcRing) { + draggingRing.rotation = srcRing.sceneRotation; + draggingRing.color = srcRing.color; + draggingRing.scale = srcRing.scale; + } + + onDraggingChanged: { + if (rotRingX.dragging) + copyRingProperties(rotRingX) + else if (rotRingY.dragging) + copyRingProperties(rotRingY) + else if (rotRingZ.dragging) + copyRingProperties(rotRingZ) + } + Rectangle { id: angleLabel color: "white" @@ -87,6 +102,7 @@ Node { : rotateGizmo.targetNode.sceneRotation rotationOrder: rotateGizmo.targetNode ? rotateGizmo.targetNode.rotationOrder : Node.YXZ orientation: rotateGizmo.orientation + visible: !rotateGizmo.dragging && !freeRotator.dragging RotateRing { id: rotRingX @@ -148,6 +164,20 @@ Node { } RotateRing { + // This ring is used as visual proxy during dragging to display the currently dragged + // plane in static position, as rotation planes can wobble when ancestors don't have + // uniform scaling. + // Camera ring doesn't need dragging proxy as it doesn't wobble. + id: draggingRing + objectName: "draggingRing" + targetNode: rotateGizmo.targetNode + view3D: rotateGizmo.view3D + active: false + visible: rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging + orientation: rotateGizmo.orientation + } + + RotateRing { id: cameraRing objectName: "cameraRing" rotation: rotateGizmo.view3D.camera.rotation @@ -159,6 +189,7 @@ Node { view3D: rotateGizmo.view3D active: rotateGizmo.visible dragHelper: rotateGizmo.dragHelper + visible: !rotRingX.dragging && !rotRingY.dragging && !rotRingZ.dragging && !freeRotator.dragging onRotateCommit: rotateGizmo.rotateCommit() onRotateChange: rotateGizmo.rotateChange() @@ -177,7 +208,9 @@ Node { lighting: DefaultMaterial.NoLighting } scale: Qt.vector3d(0.15, 0.15, 0.15) + visible: !rotateGizmo.dragging && !dragging + property bool dragging: false property vector3d _pointerPosPressed property vector3d _targetPosOnScreen property vector3d _startRotation @@ -200,6 +233,7 @@ Node { _startRotation = Qt.vector3d(rotateGizmo.targetNode.rotation.x, rotateGizmo.targetNode.rotation.y, rotateGizmo.targetNode.rotation.z); + dragging = true; } function handleDragged(screenPos) @@ -224,6 +258,7 @@ Node { Qt.vector3d(screenPos.x, screenPos.y, 0), _targetPosOnScreen); rotateGizmo.rotateCommit(); + dragging = false; } MouseArea3D { diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml index 1a119cd950..d5f9370a33 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml @@ -66,11 +66,10 @@ Model { function applyLocalRotation(screenPos) { - currentAngle = mouseAreaMain.getNewRotationAngle(targetNode, _pointerPosPressed, - Qt.vector3d(screenPos.x, screenPos.y, 0), - _targetPosOnScreen, currentAngle, - _trackBall); - mouseAreaMain.applyRotationAngleToNode(targetNode, _startRotation, currentAngle); + currentAngle = mouseAreaMain.dragHelper.getNewRotationAngle( + targetNode, _pointerPosPressed, Qt.vector3d(screenPos.x, screenPos.y, 0), + _targetPosOnScreen, currentAngle, _trackBall); + mouseAreaMain.dragHelper.applyRotationAngleToNode(targetNode, _startRotation, currentAngle); } function handlePressed(screenPos, angle) |