~nick-dedekind/unity8/indicators.hint-interval

« back to all changes in this revision

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

  • Committer: Nick Dedekind
  • Date: 2014-03-07 15:54:57 UTC
  • mfrom: (638.1.118 unity8)
  • Revision ID: nicholas.dedekind@gmail.com-20140307155457-f0s1zu5ll2czt3rq
merged with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 */
30
30
Item {
31
31
    id: root
32
 
    width: 700
33
 
    height: 500
 
32
    width: units.gu(70)
 
33
    height: units.gu(70)
34
34
 
35
35
    property var dragHandle
36
36
 
37
37
    property bool stretch: false
38
38
    property real hintDisplacement: 0
39
39
 
40
 
    VerticalShowable {
41
 
        onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
42
 
        stretch: root.stretch
43
 
        hintDisplacement: root.hintDisplacement
44
 
    }
45
 
 
46
 
    HorizontalShowable {
47
 
        onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
48
 
        stretch: root.stretch
49
 
        hintDisplacement: root.hintDisplacement
50
 
    }
51
 
 
52
 
    // Visually mark drag threshold
53
 
    Rectangle {
54
 
        color: "black"
55
 
        width: 2
56
 
        height: parent.height
57
 
 
58
 
        visible: dragHandle !== undefined && Direction.isHorizontal(dragHandle.direction)
59
 
 
60
 
        x: {
61
 
            if (dragHandle) {
62
 
                if (dragHandle.direction === Direction.Rightwards) {
63
 
                    dragHandle.edgeDragEvaluator.dragThreshold;
 
40
    Item {
 
41
        id: baseItem
 
42
        objectName: "baseItem"
 
43
        anchors.fill: parent
 
44
 
 
45
        VerticalShowable {
 
46
            onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
 
47
            stretch: root.stretch
 
48
            hintDisplacement: root.hintDisplacement
 
49
        }
 
50
 
 
51
        HorizontalShowable {
 
52
            onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
 
53
            stretch: root.stretch
 
54
            hintDisplacement: root.hintDisplacement
 
55
        }
 
56
 
 
57
        // Visually mark drag threshold
 
58
        Rectangle {
 
59
            color: "black"
 
60
            width: 2
 
61
            height: parent.height
 
62
 
 
63
            visible: dragHandle !== undefined && Direction.isHorizontal(dragHandle.direction)
 
64
 
 
65
            x: {
 
66
                if (dragHandle) {
 
67
                    if (dragHandle.direction === Direction.Rightwards) {
 
68
                        dragHandle.edgeDragEvaluator.dragThreshold;
 
69
                    } else {
 
70
                        parent.width - dragHandle.edgeDragEvaluator.dragThreshold;
 
71
                    }
64
72
                } else {
65
 
                    parent.width - dragHandle.edgeDragEvaluator.dragThreshold;
 
73
                    0
66
74
                }
67
 
            } else {
68
 
                0
69
75
            }
70
76
        }
71
 
    }
72
 
    Rectangle {
73
 
        color: "black";
74
 
        height: 2
75
 
        width: parent.width
76
 
 
77
 
        visible: dragHandle !== undefined && Direction.isVertical(dragHandle.direction)
78
 
 
79
 
        y: {
80
 
            if (dragHandle) {
81
 
                if (dragHandle.direction === Direction.Downwards) {
82
 
                    dragHandle.edgeDragEvaluator.dragThreshold;
 
77
        Rectangle {
 
78
            color: "black";
 
79
            height: 2
 
80
            width: parent.width
 
81
 
 
82
            visible: dragHandle !== undefined && Direction.isVertical(dragHandle.direction)
 
83
 
 
84
            y: {
 
85
                if (dragHandle) {
 
86
                    if (dragHandle.direction === Direction.Downwards) {
 
87
                        dragHandle.edgeDragEvaluator.dragThreshold;
 
88
                    } else {
 
89
                        parent.height - dragHandle.edgeDragEvaluator.dragThreshold;
 
90
                    }
83
91
                } else {
84
 
                    parent.height - dragHandle.edgeDragEvaluator.dragThreshold;
 
92
                    0
85
93
                }
86
 
            } else {
87
 
                0
88
94
            }
89
95
        }
90
96
    }
119
125
        }
120
126
    }
121
127
 
122
 
    TestButton {
123
 
        id: stretchButton
 
128
    Row {
124
129
        anchors.bottom: parent.bottom
125
130
        anchors.left: parent.left
126
131
        anchors.margins: units.gu(1)
127
 
 
128
 
        text: root.stretch ? "stretch" : "move"
129
 
        onClicked: { root.stretch = !root.stretch; }
130
 
    }
131
 
 
132
 
    TestButton {
133
 
        anchors.bottom: parent.bottom
134
 
        anchors.left: stretchButton.right
135
 
        anchors.margins: units.gu(1)
136
 
 
137
 
        text: root.hintDisplacement > 0 ? "hint" : "no hint"
138
 
        onClicked: {
139
 
            if (root.hintDisplacement > 0) {
140
 
                root.hintDisplacement = 0;
141
 
            } else {
142
 
                root.hintDisplacement = units.gu(6);
 
132
        spacing: units.gu(1)
 
133
 
 
134
        Button {
 
135
            id: stretchButton
 
136
            text: root.stretch ? "stretch" : "move"
 
137
            onClicked: { root.stretch = !root.stretch; }
 
138
        }
 
139
 
 
140
        Button {
 
141
            text: root.hintDisplacement > 0 ? "hint" : "no hint"
 
142
            onClicked: {
 
143
                if (root.hintDisplacement > 0) {
 
144
                    root.hintDisplacement = 0;
 
145
                } else {
 
146
                    root.hintDisplacement = units.gu(6);
 
147
                }
 
148
            }
 
149
        }
 
150
 
 
151
        Button {
 
152
            text: "rotation: " + baseItem.rotation
 
153
            onClicked: {
 
154
                if (baseItem.rotation === 0.0) {
 
155
                    baseItem.rotation = 90.0
 
156
                } else {
 
157
                    baseItem.rotation = 0.0
 
158
                }
143
159
            }
144
160
        }
145
161
    }