~mzanetti/unity8/fix-left-edge-on-spread

« back to all changes in this revision

Viewing changes to tests/qmltests/Components/tst_DragHandle/BidirectionalShowable.qml

  • Committer: Michael Zanetti
  • Date: 2015-01-12 11:21:17 UTC
  • mfrom: (1459.1.85 unity8)
  • Revision ID: michael.zanetti@canonical.com-20150112112117-0x9srs9dx0ndp60g
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2014 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 "../../../../qml/Components"
 
19
import Ubuntu.Components 0.1
 
20
import Ubuntu.Gestures 0.1
 
21
 
 
22
Item {
 
23
    id: root
 
24
    x: 0
 
25
    width: parent.width
 
26
    height: parent.height
 
27
 
 
28
    property bool shown: true
 
29
 
 
30
    signal dragHandleRecognizedGesture(var dragHandle)
 
31
 
 
32
    property bool fullyHidden: x == -width || x == width
 
33
 
 
34
    function show() {
 
35
        shown = true;
 
36
        animation.stop();
 
37
        animation.to = 0;
 
38
        animation.start();
 
39
    }
 
40
 
 
41
    function hide() {
 
42
        shown = false;
 
43
        animation.stop();
 
44
        animation.to = x > 0 ? width : -width;
 
45
        animation.start();
 
46
    }
 
47
 
 
48
    StandardAnimation {
 
49
        id: animation
 
50
        target: root
 
51
        property: "x"
 
52
    }
 
53
 
 
54
    Image { source: "../../UnityLogo.png"; anchors.fill: parent }
 
55
 
 
56
    DragHandle {
 
57
        id: dragHandle
 
58
        anchors.fill: parent
 
59
        direction: Direction.Horizontal
 
60
        maxTotalDragDistance: root.parent.width
 
61
        autoCompleteDragThreshold: parent.width / 3
 
62
 
 
63
        onStatusChanged: {
 
64
            if (status === DirectionalDragArea.Recognized) {
 
65
                dragHandleRecognizedGesture(dragHandle);
 
66
            }
 
67
        }
 
68
    }
 
69
}