on xenial help sign in
implement moving by dragging around
commit9035e45ee2e7458c13c2967affe1b3e4a5ed2ef9 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateWed 30 Mar 2016, 13:54 (11 years ago) parentc8fd873
3 files changed+39−4
qml/Stages/TabletSideStageTouchGesture.qml+3 qml/Stages/TabletStage.qml−1 qml/Stages/WindowControlsOverlay.qml+36−3
qml/Stages/TabletSideStageTouchGesture.qml+3
@@ -106,6 +106,9 @@ TouchGestureArea {
106106 }
107107
108108 onDragStarted: {
109+ if (!dragComponent)
110+ return;
111+
109112 if (dragComponentProperties) {
110113 priv.dragObject = dragComponent.createObject(root, dragComponentProperties);
111114 } else {
qml/Stages/TabletStage.qml−1
@@ -974,7 +974,6 @@ AbstractStage {
974974 id: triGestureArea
975975 anchors.fill: parent
976976 enabled: priv.sideStageEnabled && !spreadView.active
977− property var dragObject: null
978977 property string appId: ""
979978 dragComponent: dragComponent
980979 dragComponentProperties: { "appId": appId }
qml/Stages/WindowControlsOverlay.qml+36−3
@@ -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