@@ -17,17 +17,19 @@
1717import QtQuick 2.4
1818import Ubuntu.Components 1.3
1919import Ubuntu.Gestures 0.1
20+import "../Components/PanelState"
2021
2122Item {
23+ id: root
2224 // to be set from outside
2325 property Item target // appDelegate
2426 property int borderThickness
2527
2628 TabletSideStageTouchGesture {
2729 id: gestureArea
30+ anchors.fill: parent
2831 minimumTouchPoints: 2
2932 maximumTouchPoints: 2
30− anchors.fill: parent
3133
3234 onRecognisedPressChanged: {
3335 print("Press recognized:", recognisedPress)
@@ -38,9 +40,8 @@ Item {
3840 onRecognisedDragChanged: {
3941 print("Drag recognized:", recognisedDrag)
4042 }
41− onDragStarted: print("Drag started")
43+ onPressed: print("Pressed:", x, y)
4244 onDropped: print("Dropped")
43− onCancelled: print("Cancelled")
4445 }
4546
4647 Timer { // dismiss timer
@@ -53,6 +54,38 @@ Item {
5354 onClicked: overlayTimer.stop()
5455 }
5556
57+ QtObject {
58+ id: priv
59+ property real distanceX
60+ property real distanceY
61+ property bool dragging
62+ }
63+
64+ MouseArea {
65+ anchors.fill: parent
66+ visible: overlay.visible
67+ enabled: visible
68+
69+ onPressedChanged: {
70+ if (pressed) {
71+ var pos = mapToItem(root.target, mouseX, mouseY);
72+ priv.distanceX = pos.x;
73+ priv.distanceY = pos.y;
74+ priv.dragging = true;
75+ } else {
76+ priv.dragging = false;
77+ }
78+ }
79+
80+ onPositionChanged: {
81+ if (priv.dragging) {
82+ var pos = mapToItem(root.target.parent, mouseX, mouseY);
83+ root.target.x = pos.x - priv.distanceX;
84+ root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
85+ }
86+ }
87+ }
88+
5689 Item {
5790 id: overlay
5891 anchors.fill: parent