mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-06 12:51:57 +02:00
Merge pull request #1732 from alicevision/fix/uiNodeConnections
[ui] Fix offset between the mouse's position and the tip of the edge when connecting two nodes
This commit is contained in:
commit
09fc117c65
1 changed files with 15 additions and 8 deletions
|
@ -59,7 +59,7 @@ RowLayout {
|
||||||
color: Colors.sysPalette.base
|
color: Colors.sysPalette.base
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: inputConnectMA.containsMouse || childrenRepeater.count > 0 || (attribute && attribute.isLink)
|
visible: inputConnectMA.containsMouse || childrenRepeater.count > 0 || (attribute && attribute.isLink) || inputConnectMA.drag.active || inputDropArea.containsDrag
|
||||||
radius: isList ? 0 : 2
|
radius: isList ? 0 : 2
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 2
|
anchors.margins: 2
|
||||||
|
@ -127,8 +127,8 @@ RowLayout {
|
||||||
property bool dragAccepted: false
|
property bool dragAccepted: false
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
width: 4
|
width: parent.width
|
||||||
height: 4
|
height: parent.height
|
||||||
Drag.keys: [inputDragTarget.objectName]
|
Drag.keys: [inputDragTarget.objectName]
|
||||||
Drag.active: inputConnectMA.drag.active
|
Drag.active: inputConnectMA.drag.active
|
||||||
Drag.hotSpot.x: width * 0.5
|
Drag.hotSpot.x: width * 0.5
|
||||||
|
@ -139,6 +139,8 @@ RowLayout {
|
||||||
id: inputConnectMA
|
id: inputConnectMA
|
||||||
drag.target: attribute.isReadOnly ? undefined : inputDragTarget
|
drag.target: attribute.isReadOnly ? undefined : inputDragTarget
|
||||||
drag.threshold: 0
|
drag.threshold: 0
|
||||||
|
// Move the edge's tip straight to the the current mouse position instead of waiting after the drag operation has started
|
||||||
|
drag.smoothed: false
|
||||||
enabled: !root.readOnly
|
enabled: !root.readOnly
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
// use the same negative margins as DropArea to ease pin selection
|
// use the same negative margins as DropArea to ease pin selection
|
||||||
|
@ -174,6 +176,8 @@ RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
implicitHeight: childrenRect.height
|
implicitHeight: childrenRect.height
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: nameLabel
|
id: nameLabel
|
||||||
|
|
||||||
|
@ -205,7 +209,7 @@ RowLayout {
|
||||||
color: Colors.sysPalette.base
|
color: Colors.sysPalette.base
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: attribute.hasOutputConnections
|
visible: attribute.hasOutputConnections || outputConnectMA.containsMouse || outputConnectMA.drag.active || outputDropArea.containsDrag
|
||||||
radius: isList ? 0 : 2
|
radius: isList ? 0 : 2
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 2
|
anchors.margins: 2
|
||||||
|
@ -269,8 +273,8 @@ RowLayout {
|
||||||
property bool dropAccepted: false
|
property bool dropAccepted: false
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
width: 4
|
width: parent.width
|
||||||
height: 4
|
height: parent.height
|
||||||
Drag.keys: [outputDragTarget.objectName]
|
Drag.keys: [outputDragTarget.objectName]
|
||||||
Drag.active: outputConnectMA.drag.active
|
Drag.active: outputConnectMA.drag.active
|
||||||
Drag.hotSpot.x: width*0.5
|
Drag.hotSpot.x: width*0.5
|
||||||
|
@ -281,6 +285,8 @@ RowLayout {
|
||||||
id: outputConnectMA
|
id: outputConnectMA
|
||||||
drag.target: outputDragTarget
|
drag.target: outputDragTarget
|
||||||
drag.threshold: 0
|
drag.threshold: 0
|
||||||
|
// Move the edge's tip straight to the the current mouse position instead of waiting after the drag operation has started
|
||||||
|
drag.smoothed: false
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
// use the same negative margins as DropArea to ease pin selection
|
// use the same negative margins as DropArea to ease pin selection
|
||||||
anchors.margins: outputDropArea.anchors.margins
|
anchors.margins: outputDropArea.anchors.margins
|
||||||
|
@ -346,6 +352,7 @@ RowLayout {
|
||||||
}
|
}
|
||||||
StateChangeScript {
|
StateChangeScript {
|
||||||
script: {
|
script: {
|
||||||
|
// Add the right offset if the initial click is not exactly at the center of the connection circle.
|
||||||
var pos = inputDragTarget.mapFromItem(inputConnectMA, inputConnectMA.mouseX, inputConnectMA.mouseY);
|
var pos = inputDragTarget.mapFromItem(inputConnectMA, inputConnectMA.mouseX, inputConnectMA.mouseY);
|
||||||
inputDragTarget.x = pos.x - inputDragTarget.width/2;
|
inputDragTarget.x = pos.x - inputDragTarget.width/2;
|
||||||
inputDragTarget.y = pos.y - inputDragTarget.height/2;
|
inputDragTarget.y = pos.y - inputDragTarget.height/2;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue