~gerboland/unity/8-refactor-wm-and-test

« back to all changes in this revision

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

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

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.0
 
18
import Ubuntu.Gestures 0.1
 
19
import Ubuntu.Components 0.1
 
20
 
 
21
Item {
 
22
    id: root
 
23
 
 
24
    function reset() { launcher.y = root.height }
 
25
 
 
26
    Rectangle {
 
27
        id: launcher
 
28
        color: "blue"
 
29
        width: parent.width
 
30
        height: units.gu(15)
 
31
        x: 0
 
32
        y: root.height
 
33
 
 
34
        function followDragArea() {
 
35
            if (dragArea.status === DirectionalDragArea.Rejected)
 
36
                return root.height
 
37
            else
 
38
                return dragArea.distance > -height ?
 
39
                            root.height + dragArea.distance
 
40
                        :
 
41
                            root.height - height
 
42
        }
 
43
    }
 
44
 
 
45
    Rectangle {
 
46
        id: dragAreaRect
 
47
        opacity: 0.0
 
48
        anchors.fill: dragArea
 
49
    }
 
50
 
 
51
    DirectionalDragArea {
 
52
        id: dragArea
 
53
        objectName: "vnDragArea"
 
54
 
 
55
        height: units.gu(5)
 
56
 
 
57
        direction: DirectionalDragArea.Upwards
 
58
        maxDeviation: units.gu(2)
 
59
        wideningAngle: 10
 
60
        distanceThreshold: units.gu(4)
 
61
 
 
62
        onStatusChanged: {
 
63
            switch (status) {
 
64
                case DirectionalDragArea.WaitingForTouch:
 
65
                    dragAreaRect.opacity = 0.0
 
66
                    break;
 
67
                case DirectionalDragArea.Undecided:
 
68
                    dragAreaRect.color = "yellow"
 
69
                    dragAreaRect.opacity = 0.3
 
70
                    launcher.y = Qt.binding(launcher.followDragArea)
 
71
                    break;
 
72
                case DirectionalDragArea.Recognized:
 
73
                    dragAreaRect.color = "green"
 
74
                    dragAreaRect.opacity = 0.5
 
75
                    break;
 
76
                default: //case DirectionalDragArea.Rejected:
 
77
                    dragAreaRect.color = "red"
 
78
                    dragAreaRect.opacity = 0.5
 
79
                    launcher.y = -launcher.height
 
80
                    break;
 
81
            }
 
82
        }
 
83
 
 
84
        anchors {
 
85
            left: parent.left
 
86
            right: parent.right
 
87
            bottom: parent.bottom
 
88
        }
 
89
    }
 
90
}