Skip to content

Commit e040b81

Browse files
committed
[GraphEditor] AttributePin: Do not start dragging edge on pressed
Prior to this commit, the edge that was being dragged to be connected appeared as soon as the `pressed` signal was emitted by the mouse. Now that the user can actually click (press & release) without dragging the mouse to expand or collapse groups, we want to be able to distinguish cases where the user presses the mouse to click (to expand/collapse groups) from those where the user presses the mouse to drag it (to connect edges). Instead of triggering the drag as soon as the `pressed` signal is emitted, we wait to see if the mouse moves significantly enough to indicate the will to drag; an arbitrary limit of 10 pixels along the X- or Y-axis is used to determine that the user means to drag the mouse.
1 parent f193ed6 commit e040b81

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

meshroom/ui/qml/GraphEditor/AttributePin.qml

+43-4
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,31 @@ RowLayout {
180180
anchors.margins: inputDropArea.anchors.margins
181181
anchors.leftMargin: inputDropArea.anchors.leftMargin
182182
anchors.rightMargin: inputDropArea.anchors.rightMargin
183+
184+
property bool dragTriggered: false // An edge is being dragged from the output connector
185+
property bool isPressed: false // The mouse has been pressed but not yet released
186+
property double initialX: 0.0
187+
property double initialY: 0.0
188+
183189
onPressed: function(mouse) {
184190
root.pressed(mouse)
191+
isPressed = true
192+
initialX = mouse.x
193+
initialY = mouse.y
185194
}
186-
onReleased: {
195+
onReleased: function(mouse) {
187196
inputDragTarget.Drag.drop()
197+
isPressed = false
198+
dragTriggered = false
188199
}
189200
onClicked: root.clicked()
201+
onPositionChanged: function(mouse) {
202+
// If there's been a significant (10px along the X- or Y- axis) while the mouse is being pressed,
203+
// then we can consider being in the dragging state
204+
if (isPressed && (Math.abs(mouse.x - initialX) >= 10.0 || Math.abs(mouse.y - initialY) >= 10.0)) {
205+
dragTriggered = true
206+
}
207+
}
190208
hoverEnabled: root.visible
191209
}
192210

@@ -371,9 +389,30 @@ RowLayout {
371389
anchors.leftMargin: outputDropArea.anchors.leftMargin
372390
anchors.rightMargin: outputDropArea.anchors.rightMargin
373391

374-
onPressed: function(mouse) { root.pressed(mouse) }
375-
onReleased: outputDragTarget.Drag.drop()
392+
property bool dragTriggered: false // An edge is being dragged from the output connector
393+
property bool isPressed: false // The mouse has been pressed but not yet released
394+
property double initialX: 0.0
395+
property double initialY: 0.0
396+
397+
onPressed: function(mouse) {
398+
root.pressed(mouse)
399+
isPressed = true
400+
initialX = mouse.x
401+
initialY = mouse.y
402+
}
403+
onReleased: function(mouse) {
404+
outputDragTarget.Drag.drop()
405+
isPressed = false
406+
dragTriggered = false
407+
}
376408
onClicked: root.clicked()
409+
onPositionChanged: function(mouse) {
410+
// If there's been a significant (10px along the X- or Y- axis) while the mouse is being pressed,
411+
// then we can consider being in the dragging state
412+
if (isPressed && (Math.abs(mouse.x - initialX) >= 10.0 || Math.abs(mouse.y - initialY) >= 10.0)) {
413+
dragTriggered = true
414+
}
415+
}
377416

378417
hoverEnabled: root.visible
379418
}
@@ -390,7 +429,7 @@ RowLayout {
390429
}
391430
}
392431

393-
state: (inputConnectMA.pressed) ? "DraggingInput" : outputConnectMA.pressed ? "DraggingOutput" : ""
432+
state: inputConnectMA.dragTriggered ? "DraggingInput" : outputConnectMA.dragTriggered ? "DraggingOutput" : ""
394433

395434
states: [
396435
State {

0 commit comments

Comments
 (0)