Debian Codegraph @

tests/unit/swipearea13/DownwardsLauncher.qml

raw
1 /*
2 * Copyright 2015 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18 import QtQuick 2.4
19 import Lomiri.Components 1.3
20
21 Item {
22
23 function reset() { launcher.y = -launcher.height }
24
25 Rectangle {
26 id: launcher
27 color: "blue"
28 width: parent.width
29 height: units.gu(15)
30 x: 0
31 y: followDragArea()
32
33 function followDragArea() {
34 return swipeArea.distance < height ? -height + swipeArea.distance : 0
35 }
36 }
37
38 Rectangle {
39 id: dragAreaRect
40 opacity: swipeArea.dragging ? 0.5 : 0.0
41 color: "green"
42 anchors.fill: swipeArea
43 }
44
45 SwipeArea {
46 id: swipeArea
47 objectName: "vpDragArea"
48
49 height: units.gu(5)
50
51 direction: SwipeArea.Downwards
52
53 onDraggingChanged: {
54 if (dragging) {
55 launcher.y = Qt.binding(launcher.followDragArea)
56 }
57 }
58
59 anchors {
60 left: parent.left
61 right: parent.right
62 top: parent.top
63 }
64 }
65
66 SwipeArea {
67 id: swipeAreaNoGrab
68 objectName: "vpDragAreaNoGrab"
69
70 grabGesture: false
71 height: swipeArea.height
72 direction: swipeArea.direction
73 anchors {
74 left: swipeArea.left
75 right: swipeArea.right
76 top: swipeArea.top
77 }
78 }
79
80 Label {
81 text: "Downwards"
82 anchors.top: parent.top
83 anchors.horizontalCenter: parent.horizontalCenter
84 anchors.topMargin: units.gu(1)
85 }
86 }