Merge lp:~dandrader/unity8/dragHandleStretchAndHint into lp:unity8

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 64
Merged at revision: 66
Proposed branch: lp:~dandrader/unity8/dragHandleStretchAndHint
Merge into: lp:unity8
Prerequisite: lp:~dandrader/unity8/ddaDraggingFix
Diff against target: 588 lines (+361/-75)
6 files modified
Components/DragHandle.qml (+130/-63)
tests/qmltests/Components/tst_DragHandle.cpp (+100/-0)
tests/qmltests/Components/tst_DragHandle.qml (+32/-0)
tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml (+29/-6)
tests/qmltests/Components/tst_DragHandle/TestButton.qml (+41/-0)
tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml (+29/-6)
To merge this branch: bzr merge lp:~dandrader/unity8/dragHandleStretchAndHint
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Nick Dedekind (community) Approve
Albert Astals Cid (community) Approve
Review via email: mp+171908@code.launchpad.net

Commit message

DragHandle: add stretch and hintDisplacement properties

Description of the change

DragHandle: add stretch and hintDisplacement properties

Depends on https://code.launchpad.net/~dandrader/unity8/ddaDraggingFix/+merge/171904

Needed by the upcoming change that makes Panel use DragHandles instead of a Revealer.

Try it out by typing
$ make tryDragHandle

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Rerunning -ci as the armhf builder went-offline mid-run.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

Looks good :-)

review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

70 + property var __previousStatus: undefined
71 + property real __startValue
72 + property real __minValue:
74 + property real __maxValue:
78 + property string __targetProp: {

Can you create a private QtObject to encapsulate these as per guidelines
https://docs.google.com/a/canonical.com/document/d/1gd87Wo_CSB0DpFWLpTKIIXQfdmFncrq0PHSr9H2PTnk/edit

72 + property real __minValue:
73 + Direction.isPositive(direction) ? __startValue : __startValue - maxTotalDragDistance
74 + property real __maxValue:
75 + Direction.isPositive(direction) ? __startValue + maxTotalDragDistance : __startValue

Expression on a new line?

368 + x = 0
369 + width = 0
370 + } else {
371 + x = -parent.width
372 + width = parent.width

456 + rect.clicked()

482 + y = 0
483 + height = 0
484 + } else {
485 + y = -parent.height
486 + height = parent.height

Semi-colons.

Top marks for the tests. All seems to work well.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> 70 + property var __previousStatus: undefined
> 71 + property real __startValue
> 72 + property real __minValue:
> 74 + property real __maxValue:
> 78 + property string __targetProp: {
>
> Can you create a private QtObject to encapsulate these as per guidelines
> https://docs.google.com/a/canonical.com/document/d/1gd87Wo_CSB0DpFWLpTKIIXQfdm
> Fncrq0PHSr9H2PTnk/edit

Done.

>
> 72 + property real __minValue:
> 73 + Direction.isPositive(direction) ? __startValue : __startValue
> - maxTotalDragDistance
> 74 + property real __maxValue:
> 75 + Direction.isPositive(direction) ? __startValue +
> maxTotalDragDistance : __startValue
>
> Expression on a new line?

Otherwise the line would be quite long. Done it differently now.

>
> 368 + x = 0
> 369 + width = 0
> 370 + } else {
> 371 + x = -parent.width
> 372 + width = parent.width
>
> 456 + rect.clicked()
>
> 482 + y = 0
> 483 + height = 0
> 484 + } else {
> 485 + y = -parent.height
> 486 + height = parent.height
>
> Semi-colons.

Done.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Components/DragHandle.qml'
2--- Components/DragHandle.qml 2013-06-28 19:32:16 +0000
3+++ Components/DragHandle.qml 2013-07-01 16:37:36 +0000
4@@ -17,6 +17,7 @@
5 import QtQuick 2.0
6 import Ubuntu.Components 0.1
7 import Ubuntu.Gestures 0.1
8+import "Math.js" as MathLocal
9
10 /*
11 Put a DragHandle inside a Showable to enable the user to drag it from that handle.
12@@ -45,19 +46,122 @@
13 */
14 EdgeDragArea {
15 id: dragArea
16+ objectName: "dragHandle"
17+
18+ property bool stretch: false
19+
20+ property alias autoCompleteDragThreshold: dragEvaluator.dragThreshold
21
22 // How far you can drag
23- property real maxTotalDragDistance: Direction.isHorizontal(direction) ? parent.width : parent.height
24-
25- property var __previousStatus
26- property real __totalDragDistance: 0
27+ property real maxTotalDragDistance: {
28+ if (stretch) {
29+ 0; // not enough context information to set a sensible default
30+ } else {
31+ Direction.isHorizontal(direction) ? parent.width : parent.height;
32+ }
33+ }
34+
35+ property real hintDisplacement: 0
36+ SmoothedAnimation {
37+ id: hintingAnimation
38+ target: hintingAnimation
39+ property: "targetValue"
40+ duration: 150
41+ velocity: -1
42+ to: Direction.isPositive(direction) ? d.startValue + hintDisplacement
43+ : d.startValue - hintDisplacement
44+ property real targetValue
45+ onTargetValueChanged: {
46+ if (!running) {
47+ return;
48+ }
49+
50+ if (Direction.isPositive(direction)) {
51+ if (parent[d.targetProp] < targetValue) {
52+ parent[d.targetProp] = targetValue;
53+ }
54+ } else {
55+ if (parent[d.targetProp] > targetValue) {
56+ parent[d.targetProp] = targetValue;
57+ }
58+ }
59+ }
60+ }
61+
62+ // Private stuff
63+ QtObject {
64+ id: d
65+ property var previousStatus: undefined
66+ property real startValue
67+ property real minValue: Direction.isPositive(direction) ? startValue
68+ : startValue - maxTotalDragDistance
69+ property real maxValue: Direction.isPositive(direction) ? startValue + maxTotalDragDistance
70+ : startValue
71+
72+ property var dragParent: dragArea.parent
73+
74+ // The property of DragHandle's parent that will be modified
75+ property string targetProp: {
76+ if (stretch) {
77+ Direction.isHorizontal(direction) ? "width" : "height";
78+ } else {
79+ Direction.isHorizontal(direction) ? "x" : "y";
80+ }
81+ }
82+
83+ function limitMovement(step) {
84+ var targetValue = MathLocal.clamp(dragParent[targetProp] + step, minValue, maxValue);
85+ var step = targetValue - dragParent[targetProp];
86+
87+ if (hintDisplacement == 0) {
88+ return step;
89+ }
90+
91+ // we should not go behind hintingAnimation's current value
92+ if (Direction.isPositive(direction)) {
93+ if (dragParent[targetProp] + step < hintingAnimation.targetValue) {
94+ step = hintingAnimation.targetValue - dragParent[targetProp];
95+ }
96+ } else {
97+ if (dragParent[targetProp] + step > hintingAnimation.targetValue) {
98+ step = hintingAnimation.targetValue - dragParent[targetProp];
99+ }
100+ }
101+
102+ return step;
103+ }
104+
105+ function onFinishedRecognizedGesture() {
106+ if (dragEvaluator.shouldAutoComplete()) {
107+ completeDrag();
108+ } else {
109+ rollbackDrag();
110+ }
111+ }
112+
113+ function completeDrag() {
114+ if (dragParent.shown) {
115+ dragParent.hide();
116+ } else {
117+ dragParent.show();
118+ }
119+ }
120+
121+ function rollbackDrag() {
122+ if (dragParent.shown) {
123+ dragParent.show();
124+ } else {
125+ dragParent.hide();
126+ }
127+ }
128+ }
129
130 property alias edgeDragEvaluator: dragEvaluator
131
132 EdgeDragEvaluator {
133 objectName: "edgeDragEvaluator"
134 id: dragEvaluator
135- trackedPosition: Direction.isHorizontal(direction) ? parent.x + touchX : parent.y + touchY
136+ trackedPosition: sceneDistance
137 maxDragDistance: maxTotalDragDistance
138 direction: dragArea.direction
139 }
140@@ -67,75 +171,38 @@
141 // don't go the whole distance in order to smooth out the movement
142 var step = distance * 0.3;
143
144- step = __limitMovement(step);
145-
146- __totalDragDistance += step;
147-
148- if (Direction.isHorizontal(direction)) {
149- parent.x += step;
150- } else {
151- parent.y += step;
152- }
153+ step = d.limitMovement(step);
154+
155+ parent[d.targetProp] += step;
156 }
157 }
158
159-
160- function __limitMovement(step) {
161- if (Direction.isPositive(direction)) {
162- if (__totalDragDistance + step > maxTotalDragDistance) {
163- step = maxTotalDragDistance - __totalDragDistance;
164- } else if (__totalDragDistance + step < 0) {
165- step = 0 - __totalDragDistance;
166+ onDraggingChanged: {
167+ if (dragging) {
168+ if (hintDisplacement > 0) {
169+ hintingAnimation.targetValue = d.startValue;
170+ hintingAnimation.start();
171 }
172 } else {
173- if (__totalDragDistance + step < -maxTotalDragDistance) {
174- step = -maxTotalDragDistance - __totalDragDistance;
175- } else if (__totalDragDistance + step > 0) {
176- step = 0 - __totalDragDistance;
177- }
178+ hintingAnimation.stop();
179 }
180-
181- return step;
182 }
183
184 onStatusChanged: {
185 if (status === DirectionalDragArea.WaitingForTouch) {
186- if (__previousStatus === DirectionalDragArea.Recognized) {
187- __onFinishedRecognizedGesture();
188+ if (d.previousStatus === DirectionalDragArea.Recognized) {
189+ d.onFinishedRecognizedGesture();
190 }
191- __totalDragDistance = 0;
192+ d.startValue = parent[d.targetProp];
193 }
194- else if (status === DirectionalDragArea.Undecided) {
195+
196+ if (d.previousStatus === DirectionalDragArea.WaitingForTouch ||
197+ d.previousStatus === undefined) {
198 dragEvaluator.reset();
199- }
200- else if (status === DirectionalDragArea.Recognized) {
201- if (__previousStatus === DirectionalDragArea.WaitingForTouch)
202- dragEvaluator.reset();
203- }
204- __previousStatus = status;
205- }
206-
207- function __onFinishedRecognizedGesture() {
208- if (dragEvaluator.shouldAutoComplete()) {
209- __completeDrag();
210- } else {
211- __rollbackDrag();
212- }
213- }
214-
215- function __completeDrag() {
216- if (parent.shown) {
217- parent.hide();
218- } else {
219- parent.show();
220- }
221- }
222-
223- function __rollbackDrag() {
224- if (parent.shown) {
225- parent.show();
226- } else {
227- parent.hide();
228- }
229- }
230+ d.startValue = parent[d.targetProp];
231+ }
232+
233+ d.previousStatus = status;
234+ }
235+
236 }
237
238=== modified file 'tests/qmltests/Components/tst_DragHandle.cpp'
239--- tests/qmltests/Components/tst_DragHandle.cpp 2013-06-27 13:16:53 +0000
240+++ tests/qmltests/Components/tst_DragHandle.cpp 2013-07-01 16:37:36 +0000
241@@ -59,6 +59,9 @@
242
243 void dragThreshold_horizontal();
244 void dragThreshold_vertical();
245+ void stretch_horizontal();
246+ void stretch_vertical();
247+ void hintingAnimation();
248
249 private:
250 void flickAndHold(DirectionalDragArea *dragHandle, qreal distance);
251@@ -290,6 +293,103 @@
252 QCOMPARE(parentItem->property("shown").toBool(), false);
253 }
254
255+/*
256+ Checks that when the stretch property is true, dragging the DragHandle increases
257+ the width or height (depending on its direction) of its parent Showable
258+ */
259+void tst_DragHandle::stretch_horizontal()
260+{
261+ DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("rightwardsDragHandle");
262+ qreal totalDragDistance = dragHandle->property("maxTotalDragDistance").toReal();
263+ QQuickItem *parentItem = dragHandle->parentItem();
264+
265+ // enable strech mode
266+ m_view->rootObject()->setProperty("stretch", QVariant(true));
267+
268+ QCOMPARE(parentItem->width(), 0.0);
269+
270+ // flick all the way
271+ flickAndHold(dragHandle, totalDragDistance);
272+
273+ // should keep going until completion
274+ // Parent item should now have its full height
275+ tryCompare([&](){ return parentItem->width(); }, totalDragDistance);
276+ QCOMPARE(parentItem->property("shown").toBool(), true);
277+
278+ dragHandle = fetchAndSetupDragHandle("leftwardsDragHandle");
279+
280+ // flick all the way
281+ flickAndHold(dragHandle, totalDragDistance);
282+
283+ // should keep going until completion
284+ // Parent item should now have its full height
285+ tryCompare([&](){ return parentItem->width(); }, 0.0);
286+ QCOMPARE(parentItem->property("shown").toBool(), false);
287+}
288+
289+void tst_DragHandle::stretch_vertical()
290+{
291+ DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
292+ qreal totalDragDistance = dragHandle->property("maxTotalDragDistance").toReal();
293+ QQuickItem *parentItem = dragHandle->parentItem();
294+
295+ // enable strech mode
296+ m_view->rootObject()->setProperty("stretch", QVariant(true));
297+
298+ QCOMPARE(parentItem->height(), 0.0);
299+
300+ // flick all the way
301+ flickAndHold(dragHandle, totalDragDistance);
302+
303+ // should keep going until completion
304+ // Parent item should now have its full height
305+ tryCompare([&](){ return parentItem->height(); }, totalDragDistance);
306+ QCOMPARE(parentItem->property("shown").toBool(), true);
307+
308+ dragHandle = fetchAndSetupDragHandle("upwardsDragHandle");
309+
310+ // flick all the way
311+ flickAndHold(dragHandle, totalDragDistance);
312+
313+ // should keep going until completion
314+ // Parent item should now have its full height
315+ tryCompare([&](){ return parentItem->height(); }, 0.0);
316+ QCOMPARE(parentItem->property("shown").toBool(), false);
317+}
318+
319+/*
320+ Set DragHandle.hintDisplacement to a value bigger than zero.
321+ Then lay a finger on the DragHandle.
322+ The expected behavior is that it will move or strech its parent Showable
323+ by hintDisplacement pixels.
324+ */
325+void tst_DragHandle::hintingAnimation()
326+{
327+ DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
328+ QQuickItem *parentItem = dragHandle->parentItem();
329+ qreal hintDisplacement = 100.0;
330+
331+ // enable hinting animations and stretch mode
332+ m_view->rootObject()->setProperty("hintDisplacement", QVariant(hintDisplacement));
333+ m_view->rootObject()->setProperty("stretch", QVariant(true));
334+
335+ QCOMPARE(parentItem->height(), 0.0);
336+
337+ QPointF initialTouchPos = dragHandle->mapToScene(
338+ QPointF(dragHandle->width() / 2.0, dragHandle->height() / 2.0));
339+ QPointF touchPoint = initialTouchPos;
340+
341+ // Pressing causes the Showable to be stretched by hintDisplacement pixels
342+ QTest::touchEvent(m_view, m_device).press(0, touchPoint.toPoint());
343+ tryCompare([&](){ return parentItem->height(); }, hintDisplacement);
344+
345+ // Releasing causes the Showable to shrink back to 0 pixels.
346+ QTest::touchEvent(m_view, m_device).release(0, touchPoint.toPoint());
347+ tryCompare([&](){ return parentItem->height(); }, 0.0);
348+
349+ QCOMPARE(parentItem->property("shown").toBool(), false);
350+}
351+
352 QTEST_MAIN(tst_DragHandle)
353
354 #include "tst_DragHandle.moc"
355
356=== modified file 'tests/qmltests/Components/tst_DragHandle.qml'
357--- tests/qmltests/Components/tst_DragHandle.qml 2013-06-27 13:16:53 +0000
358+++ tests/qmltests/Components/tst_DragHandle.qml 2013-07-01 16:37:36 +0000
359@@ -34,12 +34,19 @@
360
361 property var dragHandle
362
363+ property bool stretch: false
364+ property real hintDisplacement: 0
365+
366 VerticalShowable {
367 onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
368+ stretch: root.stretch
369+ hintDisplacement: root.hintDisplacement
370 }
371
372 HorizontalShowable {
373 onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
374+ stretch: root.stretch
375+ hintDisplacement: root.hintDisplacement
376 }
377
378 // Visually mark drag threshold
379@@ -111,4 +118,29 @@
380 }
381 }
382 }
383+
384+ TestButton {
385+ id: stretchButton
386+ anchors.bottom: parent.bottom
387+ anchors.left: parent.left
388+ anchors.margins: units.gu(1)
389+
390+ text: root.stretch ? "stretch" : "move"
391+ onClicked: { root.stretch = !root.stretch; }
392+ }
393+
394+ TestButton {
395+ anchors.bottom: parent.bottom
396+ anchors.left: stretchButton.right
397+ anchors.margins: units.gu(1)
398+
399+ text: root.hintDisplacement > 0 ? "hint" : "no hint"
400+ onClicked: {
401+ if (root.hintDisplacement > 0) {
402+ root.hintDisplacement = 0;
403+ } else {
404+ root.hintDisplacement = units.gu(6);
405+ }
406+ }
407+ }
408 }
409
410=== modified file 'tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml'
411--- tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml 2013-06-27 13:16:53 +0000
412+++ tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml 2013-07-01 16:37:36 +0000
413@@ -21,18 +21,35 @@
414
415 Showable {
416 id: showable
417- x: -width
418- width: parent.width
419+ x: stretch ? 0 : -width
420+ width: stretch ? 0 : parent.width
421 height: parent.height
422
423+ property bool stretch
424+ property real hintDisplacement
425+
426+ onStretchChanged: {
427+ if (stretch) {
428+ x = 0;
429+ width = 0;
430+ } else {
431+ x = -parent.width;
432+ width = parent.width;
433+ }
434+ }
435+
436 shown: false
437
438 signal dragHandleRecognizedGesture(var dragHandle)
439
440- showAnimation: StandardAnimation { property: "x"; to: 0 }
441- hideAnimation: StandardAnimation { property: "x"; to: -width }
442-
443- Rectangle { color: "blue"; anchors.fill: parent }
444+ property string animatedProp: stretch ? "width" : "x"
445+ property real propValueWhenShown: stretch ? parent.width : 0
446+ property real propValueWhenHidden: stretch ? 0 : -width
447+
448+ showAnimation: StandardAnimation { property: animatedProp; to: propValueWhenShown }
449+ hideAnimation: StandardAnimation { property: animatedProp; to: propValueWhenHidden }
450+
451+ Image { source: "UnityLogo.png"; anchors.fill: parent }
452
453 DragHandle {
454 objectName: "leftwardsDragHandle"
455@@ -44,6 +61,9 @@
456 width: units.gu(2)
457
458 direction: Direction.Leftwards
459+ stretch: showable.stretch
460+ maxTotalDragDistance: showable.parent.width
461+ hintDisplacement: showable.hintDisplacement
462
463 onStatusChanged: {
464 if (status === DirectionalDragArea.Recognized) {
465@@ -64,6 +84,9 @@
466 width: units.gu(2)
467
468 direction: Direction.Rightwards
469+ stretch: showable.stretch
470+ maxTotalDragDistance: showable.parent.width
471+ hintDisplacement: showable.hintDisplacement
472
473 onStatusChanged: {
474 if (status === DirectionalDragArea.Recognized) {
475
476=== added file 'tests/qmltests/Components/tst_DragHandle/TestButton.qml'
477--- tests/qmltests/Components/tst_DragHandle/TestButton.qml 1970-01-01 00:00:00 +0000
478+++ tests/qmltests/Components/tst_DragHandle/TestButton.qml 2013-07-01 16:37:36 +0000
479@@ -0,0 +1,41 @@
480+/*
481+ * Copyright (C) 2013 Canonical, Ltd.
482+ *
483+ * This program is free software; you can redistribute it and/or modify
484+ * it under the terms of the GNU General Public License as published by
485+ * the Free Software Foundation; version 3.
486+ *
487+ * This program is distributed in the hope that it will be useful,
488+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
489+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
490+ * GNU General Public License for more details.
491+ *
492+ * You should have received a copy of the GNU General Public License
493+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
494+ */
495+
496+import QtQuick 2.0
497+import Ubuntu.Components 0.1
498+
499+Rectangle {
500+ id: rect
501+ width: childrenRect.width
502+ height: childrenRect.height
503+
504+ property alias text: textComponent.text
505+
506+ signal clicked
507+
508+ color: "yellow"
509+ Text {
510+ id: textComponent
511+ font.pixelSize: units.gu(2)
512+ text: root.stretch ? "stretch" : "move"
513+ MouseArea {
514+ anchors.fill: parent
515+ onClicked: {
516+ rect.clicked()
517+ }
518+ }
519+ }
520+}
521
522=== added file 'tests/qmltests/Components/tst_DragHandle/UnityLogo.png'
523Binary files tests/qmltests/Components/tst_DragHandle/UnityLogo.png 1970-01-01 00:00:00 +0000 and tests/qmltests/Components/tst_DragHandle/UnityLogo.png 2013-07-01 16:37:36 +0000 differ
524=== modified file 'tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml'
525--- tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml 2013-06-27 13:16:53 +0000
526+++ tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml 2013-07-01 16:37:36 +0000
527@@ -21,18 +21,35 @@
528
529 Showable {
530 id: showable
531- y: -height
532+ y: stretch ? 0 : -height
533 width: parent.width
534- height: parent.height
535+ height: stretch ? 0 : parent.height
536+
537+ property bool stretch
538+ property real hintDisplacement
539+
540+ onStretchChanged: {
541+ if (stretch) {
542+ y = 0;
543+ height = 0;
544+ } else {
545+ y = -parent.height;
546+ height = parent.height;
547+ }
548+ }
549
550 shown: false
551
552 signal dragHandleRecognizedGesture(var dragHandle)
553
554- showAnimation: StandardAnimation { property: "y"; to: 0 }
555- hideAnimation: StandardAnimation { property: "y"; to: -height }
556-
557- Rectangle { color: "blue"; anchors.fill: parent }
558+ property string animatedProp: stretch ? "height" : "y"
559+ property real propValueWhenShown: stretch ? parent.height : 0
560+ property real propValueWhenHidden: stretch ? 0 : -height
561+
562+ showAnimation: StandardAnimation { property: animatedProp; to: propValueWhenShown }
563+ hideAnimation: StandardAnimation { property: animatedProp; to: propValueWhenHidden }
564+
565+ Image { source: "UnityLogo.png"; anchors.fill: parent }
566
567 DragHandle {
568 objectName: "upwardsDragHandle"
569@@ -44,6 +61,9 @@
570 height: units.gu(2)
571
572 direction: Direction.Upwards
573+ stretch: showable.stretch
574+ maxTotalDragDistance: showable.parent.height
575+ hintDisplacement: showable.hintDisplacement
576
577 onStatusChanged: {
578 if (status === DirectionalDragArea.Recognized) {
579@@ -64,6 +84,9 @@
580 height: units.gu(2)
581
582 direction: Direction.Downwards
583+ stretch: showable.stretch
584+ maxTotalDragDistance: showable.parent.height
585+ hintDisplacement: showable.hintDisplacement
586
587 onStatusChanged: {
588 if (status === DirectionalDragArea.Recognized) {

Subscribers

People subscribed via source and target branches