-
Notifications
You must be signed in to change notification settings - Fork 0
/
InputConnector.qml
79 lines (64 loc) · 2.64 KB
/
InputConnector.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import QtQuick
import MotionGloveInterface
import QtQuick.Controls
Item {
id:root
property string parentID: "unknown" //important for identifying sender of connection
property int vIdx: -1 //identifies potential subvalues; -1 means the whole datatype
property int vType: TypeHelper.Undefined // type of connection that will be initiated
property string vName: "" // just the text while dragging
property color cColor: _typehelper.getColorForValueType(vType)
property bool nodeHovered: inConnectorMa.containsMouse
property bool dropAreaEnabled: true
implicitHeight: 10
implicitWidth: 10
Rectangle {
id: inputConnector
anchors.fill: parent
radius: height/2
color: cColor//connectorPair.nodeColor
border {
width: 1
color: inDrop.containsDrag ? "cyan" : "black"
}
MouseArea {
id: inConnectorMa
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.RightButton | Qt.LeftButton
onClicked: (mouse) => {
if(mouse.button === Qt.RightButton) {
contextMenu.popup()
}
}
}
DropArea {
id: inDrop
enabled: true//root.dropAreaEnabled
anchors.fill: parent
anchors.margins: -8
keys: ["valueType", "valueIndex", "sourceObjectId"]//, "text/nodeId", "text/valueType"]"nodeId",
// onEntered:(drag) => console.log(drag.keys)
onDropped: (drop) => {
// console.log(drop.source)
if(_mbackend.connectionRequest(//drop.getDataAsString("sourceObjectId"),
drop.getDataAsString("sourceObjectId"),
drop.getDataAsString("valueIndex"),
//inputConnector,
root.parentID,
root.vIdx,
//drop.source,
drop.getDataAsString("valueType"))) {
drop.acceptProposedAction()
}
}
}
}
Menu {
width: 80
id: contextMenu
MenuItem {text: "del connection"
onClicked: _mbackend.deleteReceiveConnectionForObjectAtIdx(root.parentID, vIdx)
}
}
}