@@ -21,10 +21,9 @@ import "../Components/PanelState"
2121
2222Item {
2323 id: root
24+
2425 // to be set from outside
2526 property Item target // appDelegate
26− property Item resizeTarget // WindowResizeArea
27− property int borderThickness
2827
2928 signal activated
3029
@@ -33,7 +32,7 @@ Item {
3332 anchors.fill: parent
3433
3534 // NB: for testing set to 2, not to clash with unity7 touch overlay controls
36− minimumTouchPoints: 3
35+ minimumTouchPoints: 2
3736 maximumTouchPoints: minimumTouchPoints
3837
3938 readonly property bool recognizedPress: status == TouchGestureArea.Recognized &&
@@ -53,49 +52,7 @@ Item {
5352 Timer {
5453 id: overlayTimer
5554 interval: 2000
56− repeat: priv.dragging || root.resizeTarget.dragging
57− }
58−
59−
60− // dismiss area
61− InverseMouseArea {
62− anchors.fill: overlay
63− visible: overlay.visible
64− enabled: visible
65− onPressed: {
66− overlayTimer.stop();
67− mouse.accepted = false;
68− }
69− propagateComposedEvents: true
70− }
71−
72−
73− // move handler
74− MouseArea {
75− anchors.fill: overlay
76− visible: overlay.visible
77− enabled: visible
78− hoverEnabled: true
79− cursorShape: priv.dragging ? Qt.ClosedHandCursor : (overlay.visible ? Qt.OpenHandCursor : Qt.ArrowCursor)
80−
81− onPressedChanged: {
82− if (pressed) {
83− var pos = mapToItem(root.target, mouseX, mouseY);
84− priv.distanceX = pos.x;
85− priv.distanceY = pos.y;
86− priv.dragging = true;
87− } else {
88− priv.dragging = false;
89− }
90− }
91−
92− onPositionChanged: {
93− if (priv.dragging) {
94− var pos = mapToItem(root.target.parent, mouseX, mouseY);
95− root.target.x = pos.x - priv.distanceX;
96− root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
97− }
98− }
55+ repeat: priv.dragging || (priv.resizeArea && priv.resizeArea.dragging)
9956 }
10057
10158 QtObject {
@@ -103,6 +60,9 @@ Item {
10360 property real distanceX
10461 property real distanceY
10562 property bool dragging
63+
64+ readonly property var resizeArea: root.target && root.target.resizeArea ? root.target.resizeArea : null
65+ readonly property int borderThickness: priv.resizeArea ? priv.resizeArea.borderThickness : 0
10666 }
10767
10868
@@ -129,80 +89,119 @@ Item {
12989 anchors.centerIn: parent
13090 opacity: 0.95
13191 visible: target && target.width > units.gu(12) && target.height > units.gu(12)
92+
93+ // move handler
94+ MouseArea {
95+ anchors.fill: parent
96+ visible: overlay.visible
97+ enabled: visible
98+ hoverEnabled: true
99+ cursorShape: priv.dragging ? Qt.ClosedHandCursor : (overlay.visible ? Qt.OpenHandCursor : Qt.ArrowCursor)
100+
101+ onPressedChanged: {
102+ if (pressed) {
103+ var pos = mapToItem(root.target, mouseX, mouseY);
104+ priv.distanceX = pos.x;
105+ priv.distanceY = pos.y;
106+ priv.dragging = true;
107+ } else {
108+ priv.dragging = false;
109+ }
110+ }
111+
112+ onPositionChanged: {
113+ if (priv.dragging) {
114+ var pos = mapToItem(root.target.parent, mouseX, mouseY);
115+ root.target.x = pos.x - priv.distanceX;
116+ root.target.y = Math.max(pos.y - priv.distanceY, PanelState.panelHeight);
117+ }
118+ }
119+ }
120+
121+ // dismiss area
122+ InverseMouseArea {
123+ anchors.fill: parent
124+ visible: overlay.visible
125+ enabled: visible
126+ onClicked: {
127+ overlayTimer.stop();
128+ mouse.accepted = false;
129+ }
130+ }
132131 }
133132
134133 ResizeGrip { // top left
135134 anchors.horizontalCenter: parent.left
136− anchors.horizontalCenterOffset: borderThickness
135+ //anchors.horizontalCenterOffset: priv.borderThickness
137136 anchors.verticalCenter: parent.top
138− anchors.verticalCenterOffset: borderThickness
137+ //anchors.verticalCenterOffset: priv.borderThickness
139138 visible: !overlay.anyMaximized
140− resizeTarget: root.resizeTarget
139+ resizeTarget: priv.resizeArea
141140 }
142141
143142 ResizeGrip { // top center
144143 anchors.horizontalCenter: parent.horizontalCenter
145144 anchors.verticalCenter: parent.top
146− anchors.verticalCenterOffset: borderThickness
145+ //anchors.verticalCenterOffset: priv.borderThickness
147146 rotation: 45
148147 visible: !overlay.anyMaximized
149− resizeTarget: root.resizeTarget
148+ resizeTarget: priv.resizeArea
150149 }
151150
152151 ResizeGrip { // top right
153152 anchors.horizontalCenter: parent.right
154− anchors.horizontalCenterOffset: -borderThickness
153+ //anchors.horizontalCenterOffset: -priv.borderThickness
155154 anchors.verticalCenter: parent.top
156− anchors.verticalCenterOffset: borderThickness
155+ //anchors.verticalCenterOffset: priv.borderThickness
157156 rotation: 90
158157 visible: !overlay.anyMaximized
159− resizeTarget: root.resizeTarget
158+ resizeTarget: priv.resizeArea
160159 }
161160
162161 ResizeGrip { // right
163162 anchors.horizontalCenter: parent.right
164− anchors.horizontalCenterOffset: -borderThickness
163+ //anchors.horizontalCenterOffset: -priv.borderThickness
165164 anchors.verticalCenter: parent.verticalCenter
166165 rotation: 135
167166 visible: target && !target.maximizedRight && !target.maximized
168− resizeTarget: root.resizeTarget
167+ resizeTarget: priv.resizeArea
169168 }
170169
171170 ResizeGrip { // bottom right
172171 anchors.horizontalCenter: parent.right
173− anchors.horizontalCenterOffset: -borderThickness
172+ //anchors.horizontalCenterOffset: -priv.borderThickness
174173 anchors.verticalCenter: parent.bottom
175− anchors.verticalCenterOffset: -borderThickness
174+ //anchors.verticalCenterOffset: -priv.borderThickness
176175 visible: !overlay.anyMaximized
177− resizeTarget: root.resizeTarget
176+ resizeTarget: priv.resizeArea
178177 }
179178
180179 ResizeGrip { // bottom center
181180 anchors.horizontalCenter: parent.horizontalCenter
182181 anchors.verticalCenter: parent.bottom
183− anchors.verticalCenterOffset: -borderThickness
182+ //anchors.verticalCenterOffset: -priv.borderThickness
184183 rotation: 45
185184 visible: !overlay.anyMaximized
186− resizeTarget: root.resizeTarget
185+ resizeTarget: priv.resizeArea
187186 }
188187
189188 ResizeGrip { // bottom left
190189 anchors.horizontalCenter: parent.left
191− anchors.horizontalCenterOffset: borderThickness
190+ //anchors.horizontalCenterOffset: priv.borderThickness
192191 anchors.verticalCenter: parent.bottom
193− anchors.verticalCenterOffset: -borderThickness
192+ //anchors.verticalCenterOffset: -priv.borderThickness
194193 rotation: 90
195194 visible: !overlay.anyMaximized
196− resizeTarget: root.resizeTarget
195+ resizeTarget: priv.resizeArea
197196 }
198197
199198 ResizeGrip { // left
200199 anchors.horizontalCenter: parent.left
201− anchors.horizontalCenterOffset: borderThickness
200+ //anchors.horizontalCenterOffset: priv.borderThickness
202201 anchors.verticalCenter: parent.verticalCenter
203202 rotation: 135
204203 visible: target && !target.maximizedLeft && !target.maximized
205− resizeTarget: root.resizeTarget
204+ resizeTarget: priv.resizeArea
206205 }
207206 }
208207}