~aacid/unity8/desktopRotatedCamera

« back to all changes in this revision

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

  • Committer: Albert Astals Cid
  • Date: 2016-06-02 07:43:13 UTC
  • mfrom: (2039.198.42 unity8)
  • Revision ID: albert.astals@canonical.com-20160602074313-qycavrlys0yftjfd
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 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 "../../../../qml/Components"
 
19
import Ubuntu.Components 1.3
 
20
import Ubuntu.Gestures 0.1
 
21
 
 
22
Showable {
 
23
    id: root
 
24
    x: parent.width
 
25
    width: parent.width
 
26
    height: parent.height
 
27
 
 
28
    property bool stretch
 
29
    property real hintDisplacement
 
30
 
 
31
    Binding {
 
32
        when: stretch
 
33
        target: root
 
34
        property: "x"
 
35
        value: root.parent.width - root.width
 
36
    }
 
37
 
 
38
    onStretchChanged: {
 
39
        // reset
 
40
        shown = false;
 
41
        if (stretch) {
 
42
            width = 0;
 
43
        } else {
 
44
            x = parent.width;
 
45
            width = parent.width;
 
46
        }
 
47
    }
 
48
 
 
49
    shown: false
 
50
 
 
51
    signal dragHandleRecognizedGesture(var dragHandle)
 
52
 
 
53
    property string animatedProp: stretch ? "width" : "x"
 
54
    property real propValueWhenShown: stretch ? parent.width : 0
 
55
    property real propValueWhenHidden: stretch ? 0 : parent.width
 
56
 
 
57
    showAnimation: StandardAnimation { property: animatedProp; to: propValueWhenShown }
 
58
    hideAnimation: StandardAnimation { property: animatedProp; to: propValueWhenHidden }
 
59
 
 
60
    Image { source: "../../UnityLogo.png"; anchors.fill: parent }
 
61
 
 
62
    DragHandle {
 
63
        objectName: "rightEdgeHideDragHandle"
 
64
        id: hideDragHandle
 
65
        anchors.top: parent.top
 
66
        anchors.bottom: parent.bottom
 
67
        anchors.left: parent.left
 
68
 
 
69
        width: units.gu(2)
 
70
 
 
71
        direction: Direction.Rightwards
 
72
        stretch: root.stretch
 
73
        maxTotalDragDistance: root.parent.width
 
74
        hintDisplacement: root.hintDisplacement
 
75
 
 
76
        onDraggingChanged: {
 
77
            if (dragging) {
 
78
                dragHandleRecognizedGesture(hideDragHandle);
 
79
            }
 
80
        }
 
81
 
 
82
        Rectangle { color: "red"; anchors.fill: parent }
 
83
    }
 
84
 
 
85
    DragHandle {
 
86
        objectName: "rightEdgeShowDragHandle"
 
87
        id: showDragHandle
 
88
        anchors.top: parent.top
 
89
        anchors.bottom: parent.bottom
 
90
        anchors.right: parent.left
 
91
 
 
92
        width: units.gu(2)
 
93
 
 
94
        direction: Direction.Leftwards
 
95
        stretch: root.stretch
 
96
        maxTotalDragDistance: root.parent.width
 
97
        hintDisplacement: root.hintDisplacement
 
98
 
 
99
        onDraggingChanged: {
 
100
            if (dragging) {
 
101
                dragHandleRecognizedGesture(showDragHandle);
 
102
            }
 
103
        }
 
104
 
 
105
        Rectangle { color: "green"; anchors.fill: parent }
 
106
    }
 
107
 
 
108
}