on xenial help sign in
Add "rotate" button to tst_DragHandle

You can now rotate the DragHandles in the test by pressing the "rotated: 0" button, which will rotate then 90 degrees clockwise. Useful to test if DragHandles still work normally when rotated (which they don't, at the momement).

commit6982cb78cf061b28a1ea78417e2e095ab029bb19 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 12 Feb 2014, 15:19 (13 years ago) parent6872f77
2 files changed+71−97
tests/qmltests/Components/tst_DragHandle.qml+71−56 tests/qmltests/Components/tst_DragHandle/TestButton.qml−41
tests/qmltests/Components/tst_DragHandle.qml+71−56
@@ -29,62 +29,67 @@ import Ubuntu.Gestures 0.1
2929 */
3030Item {
3131 id: root
32− width: 700
33− height: 500
32+ width: units.gu(70)
33+ height: units.gu(70)
3434
3535 property var dragHandle
3636
3737 property bool stretch: false
3838 property real hintDisplacement: 0
3939
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− }
40+ Item {
41+ id: baseItem
42+ anchors.fill: parent
5143
52− // Visually mark drag threshold
53− Rectangle {
54− color: "black"
55− width: 2
56− height: parent.height
44+ VerticalShowable {
45+ onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
46+ stretch: root.stretch
47+ hintDisplacement: root.hintDisplacement
48+ }
5749
58− visible: dragHandle !== undefined && Direction.isHorizontal(dragHandle.direction)
50+ HorizontalShowable {
51+ onDragHandleRecognizedGesture: { root.dragHandle = dragHandle }
52+ stretch: root.stretch
53+ hintDisplacement: root.hintDisplacement
54+ }
5955
60− x: {
61− if (dragHandle) {
62− if (dragHandle.direction === Direction.Rightwards) {
63− dragHandle.edgeDragEvaluator.dragThreshold;
56+ // Visually mark drag threshold
57+ Rectangle {
58+ color: "black"
59+ width: 2
60+ height: parent.height
61+
62+ visible: dragHandle !== undefined && Direction.isHorizontal(dragHandle.direction)
63+
64+ x: {
65+ if (dragHandle) {
66+ if (dragHandle.direction === Direction.Rightwards) {
67+ dragHandle.edgeDragEvaluator.dragThreshold;
68+ } else {
69+ parent.width - dragHandle.edgeDragEvaluator.dragThreshold;
70+ }
6471 } else {
65− parent.width - dragHandle.edgeDragEvaluator.dragThreshold;
72+ 0
6673 }
67− } else {
68− 0
6974 }
7075 }
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;
76+ Rectangle {
77+ color: "black";
78+ height: 2
79+ width: parent.width
80+
81+ visible: dragHandle !== undefined && Direction.isVertical(dragHandle.direction)
82+
83+ y: {
84+ if (dragHandle) {
85+ if (dragHandle.direction === Direction.Downwards) {
86+ dragHandle.edgeDragEvaluator.dragThreshold;
87+ } else {
88+ parent.height - dragHandle.edgeDragEvaluator.dragThreshold;
89+ }
8390 } else {
84− parent.height - dragHandle.edgeDragEvaluator.dragThreshold;
91+ 0
8592 }
86− } else {
87− 0
8893 }
8994 }
9095 }
@@ -119,27 +124,37 @@ Item {
119124 }
120125 }
121126
122− TestButton {
123− id: stretchButton
127+ Row {
124128 anchors.bottom: parent.bottom
125129 anchors.left: parent.left
126130 anchors.margins: units.gu(1)
131+ spacing: units.gu(1)
127132
128− text: root.stretch ? "stretch" : "move"
129− onClicked: { root.stretch = !root.stretch; }
130− }
133+ Button {
134+ id: stretchButton
135+ text: root.stretch ? "stretch" : "move"
136+ onClicked: { root.stretch = !root.stretch; }
137+ }
131138
132− TestButton {
133− anchors.bottom: parent.bottom
134− anchors.left: stretchButton.right
135− anchors.margins: units.gu(1)
139+ Button {
140+ text: root.hintDisplacement > 0 ? "hint" : "no hint"
141+ onClicked: {
142+ if (root.hintDisplacement > 0) {
143+ root.hintDisplacement = 0;
144+ } else {
145+ root.hintDisplacement = units.gu(6);
146+ }
147+ }
148+ }
136149
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);
150+ Button {
151+ text: "rotation: " + baseItem.rotation
152+ onClicked: {
153+ if (baseItem.rotation === 0.0) {
154+ baseItem.rotation = 90.0
155+ } else {
156+ baseItem.rotation = 0.0
157+ }
143158 }
144159 }
145160 }
tests/qmltests/Components/tst_DragHandle/TestButton.qmldeleted−41
@@ -1,41 +0,0 @@
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.Components 0.1
19−
20−Rectangle {
21− id: rect
22− width: childrenRect.width
23− height: childrenRect.height
24−
25− property alias text: textComponent.text
26−
27− signal clicked
28−
29− color: "yellow"
30− Text {
31− id: textComponent
32− font.pixelSize: units.gu(2)
33− text: root.stretch ? "stretch" : "move"
34− MouseArea {
35− anchors.fill: parent
36− onClicked: {
37− rect.clicked()
38− }
39− }
40− }
41−}