~unity-team/+junk/dashboard-playground

« back to all changes in this revision

Viewing changes to tests/plugins/Ubuntu/Gestures/DownwardsLauncher.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
 
 
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
            if (dragArea.status === DirectionalDragArea.Rejected)
 
35
                return -height
 
36
            else
 
37
                return dragArea.distance < height ? -height + dragArea.distance : 0
 
38
        }
 
39
    }
 
40
 
 
41
    Rectangle {
 
42
        id: dragAreaRect
 
43
        color: "yellow"
 
44
        opacity: 0.0
 
45
        anchors.fill: dragArea
 
46
    }
 
47
 
 
48
    DirectionalDragArea {
 
49
        id: dragArea
 
50
        objectName: "vpDragArea"
 
51
 
 
52
        height: units.gu(5)
 
53
 
 
54
        direction: DirectionalDragArea.Downwards
 
55
        maxDeviation: units.gu(2)
 
56
        wideningAngle: 10
 
57
        distanceThreshold: units.gu(4)
 
58
 
 
59
        onStatusChanged: {
 
60
            switch (status) {
 
61
                case DirectionalDragArea.WaitingForTouch:
 
62
                    dragAreaRect.opacity = 0.0
 
63
                    break;
 
64
                case DirectionalDragArea.Undecided:
 
65
                    dragAreaRect.color = "yellow"
 
66
                    dragAreaRect.opacity = 0.3
 
67
                    launcher.y = Qt.binding(launcher.followDragArea)
 
68
                    break;
 
69
                case DirectionalDragArea.Recognized:
 
70
                    dragAreaRect.color = "green"
 
71
                    dragAreaRect.opacity = 0.5
 
72
                    break;
 
73
                default: //case DirectionalDragArea.Rejected:
 
74
                    dragAreaRect.color = "red"
 
75
                    dragAreaRect.opacity = 0.5
 
76
                    launcher.y = -launcher.height
 
77
                    break;
 
78
            }
 
79
        }
 
80
 
 
81
        anchors {
 
82
            left: parent.left
 
83
            right: parent.right
 
84
            top: parent.top
 
85
        }
 
86
    }
 
87
}