~saviq/unity8/build-arm64

« back to all changes in this revision

Viewing changes to tests/plugins/Ubuntu/Gestures/DownwardsLauncher.qml

  • Committer: Michał Sawicz
  • Date: 2016-07-15 09:51:02 UTC
  • mfrom: (2400.1.142 unity8)
  • Revision ID: michal.sawicz@canonical.com-20160715095102-hf5ac4iqnfn1itpw
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2013 Canonical, Ltd.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU 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 General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 */
16
 
 
17
 
import QtQuick 2.4
18
 
import Ubuntu.Gestures 0.1
19
 
import Ubuntu.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 dragArea.distance < height ? -height + dragArea.distance : 0
35
 
        }
36
 
    }
37
 
 
38
 
    Rectangle {
39
 
        id: dragAreaRect
40
 
        opacity: dragArea.dragging ? 0.5 : 0.0
41
 
        color: "green"
42
 
        anchors.fill: dragArea
43
 
    }
44
 
 
45
 
    DirectionalDragArea {
46
 
        id: dragArea
47
 
        objectName: "vpDragArea"
48
 
 
49
 
        height: units.gu(5)
50
 
 
51
 
        direction: Direction.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
 
    Label {
67
 
        text: "Downwards"
68
 
        anchors.top: parent.top
69
 
        anchors.horizontalCenter: parent.horizontalCenter
70
 
        anchors.topMargin: units.gu(1)
71
 
    }
72
 
}