Debian Codegraph @

au4/src/projectscene/qml/Audacity/ProjectScene/clipsview/ClipsSelection.qml

raw
1 import QtQuick
2
3 Item {
4 id: root
5
6 property bool isDataSelected: false
7 property alias active: selRect.visible
8 property var context: null
9 property real minSelection: 12 // px 4left + 4 + 4right
10
11 signal selectionDraged(var x1, var x2, var completed)
12
13 Rectangle {
14 id: selRect
15
16 x: root.context.selectionStartPosition
17 width: root.context.selectionEndPosition - selRect.x
18
19 anchors.top: parent.top
20 anchors.bottom: parent.bottom
21
22 visible: isDataSelected
23 color: "transparent"
24 }
25
26 MouseArea {
27 id: leftMa
28
29 x: selRect.x
30
31 anchors.top: parent.top
32 anchors.bottom: parent.bottom
33
34 visible: isDataSelected
35 width: 8
36 cursorShape: Qt.SizeHorCursor
37
38 property real startX: 0
39 property real startW: 0
40
41 onPressed: function(mouse) {
42 leftMa.cursorShape = Qt.ArrowCursor
43 leftMa.startX = selRect.x
44 leftMa.startW = selRect.width
45 leftMa.x = selRect.x
46 }
47
48 onPositionChanged: function(mouse) {
49 var newWidth = leftMa.startW + (mouse.x * -1)
50 if (newWidth > root.minSelection) {
51 root.selectionDraged(leftMa.startX + mouse.x, leftMa.startX + mouse.x + newWidth, false)
52 }
53 }
54
55 onReleased: {
56 root.selectionDraged(selRect.x, selRect.x + selRect.width, true)
57 leftMa.x = Qt.binding(function() { return selRect.x })
58 leftMa.cursorShape = Qt.SizeHorCursor
59 }
60 }
61
62 MouseArea {
63 id: rightMa
64
65 x: selRect.x + selRect.width - rightMa.width
66
67 anchors.top: parent.top
68 anchors.bottom: parent.bottom
69
70 visible: isDataSelected
71 width: 8
72 cursorShape: Qt.SizeHorCursor
73
74 property real startX: 0
75 property real startW: 0
76
77 onPressed: function(mouse) {
78 rightMa.cursorShape = Qt.ArrowCursor
79 rightMa.startW = selRect.width
80 rightMa.x = selRect.x + selRect.width - rightMa.width
81 }
82
83 onPositionChanged: function(mouse) {
84 var newWidth = rightMa.startW + mouse.x
85 if (newWidth > root.minSelection) {
86 root.selectionDraged(selRect.x, selRect.x + newWidth, false)
87 }
88 }
89
90 onReleased: {
91 root.selectionDraged(selRect.x, selRect.x + selRect.width, true)
92 rightMa.x = Qt.binding(function() {return selRect.x + selRect.width - rightMa.width })
93 rightMa.cursorShape = Qt.SizeHorCursor
94 }
95 }
96 }