Merge lp:~dandrader/unity8/remove_revealer into lp:unity8

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 893
Merged at revision: 903
Proposed branch: lp:~dandrader/unity8/remove_revealer
Merge into: lp:unity8
Diff against target: 607 lines (+0/-582)
4 files modified
qml/Components/Revealer.qml (+0/-241)
tests/qmltests/CMakeLists.txt (+0/-1)
tests/qmltests/Components/RevealingRectangle.qml (+0/-78)
tests/qmltests/Components/tst_Revealer.qml (+0/-262)
To merge this branch: bzr merge lp:~dandrader/unity8/remove_revealer
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+219511@code.launchpad.net

Commit message

Remove Revealer component

It's not used anywhere anymore. It's been replaced by DragHandle.

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.
No.

 * Did you perform an exploratory manual test run of your code change and any related functionality?
No, but it's not really applicable to this case.

 * Did you make sure that your branch does not contain spurious tags?
Yes.

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable.

 * If you changed the UI, has there been a design review?
Not applicable.

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes, everything still works as Reveleaer wasn't used

* Did CI run pass? If not, please explain why.
Not yet, will wait for it before top approving

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

One day we'll get qmluitests back!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== removed file 'qml/Components/Revealer.qml'
--- qml/Components/Revealer.qml 2013-10-25 14:26:29 +0000
+++ qml/Components/Revealer.qml 1970-01-01 00:00:00 +0000
@@ -1,241 +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
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19
20Item {
21 id: revealer
22
23 property Showable target
24 property var hintingAnimation: hintingAnimation
25 property string boundProperty: orientation == Qt.Vertical ? "y" : "x"
26 property int orientation: Qt.Vertical
27 property int direction: Qt.LeftToRight
28 property real openedValue: orientation == Qt.Vertical ? y : x
29 property real closedValue: orientation == Qt.Vertical ? y + (direction == Qt.LeftToRight ? -height : height) : x + (direction == Qt.LeftToRight ? -width : width)
30 property real hintDisplacement: 0
31 property real handleSize: units.gu(2)
32 property real dragVelocity: draggingArea.dragVelocity != 0 ? Math.abs(draggingArea.dragVelocity) : -1
33 property real dragVelocityThreshold: units.gu(5)
34 property bool dragging: false
35 property bool pressed: draggingArea.pressed
36 property int lateralPosition: draggingArea.lateralPosition
37 property real dragPosition
38 property bool openOnPress: true
39
40 signal openPressed(int mouseX, int mouseY)
41 signal openReleased(int mouseX, int mouseY)
42 signal closePressed
43 signal openClicked
44 signal closeClicked
45
46 dragPosition: {
47 var value
48 if (orientation == Qt.Vertical) {
49 value = draggingArea.dragValue + draggingArea.y
50 if (direction == Qt.RightToLeft) {
51 value += draggingArea.height - height
52 }
53 } else {
54 value = draggingArea.dragValue + draggingArea.x
55 if (direction == Qt.RightToLeft) {
56 value += draggingArea.width - width
57 }
58 }
59 if (__opened) {
60 if (direction == Qt.LeftToRight) {
61 value += handleSize
62 } else {
63 value -= handleSize
64 }
65 } else if (dragging) {
66 if (direction == Qt.LeftToRight) {
67 value += hintDisplacement
68 } else {
69 value -= hintDisplacement
70 }
71 }
72
73 return value
74 }
75 property var draggingArea: leftDraggingArea.enabled ? leftDraggingArea : rightDraggingArea
76
77 property real __hintValue: closedValue + (direction == Qt.LeftToRight ? hintDisplacement : -hintDisplacement)
78
79 function dragToValue(dragPosition) {
80 return dragPosition + closedValue
81 }
82
83 property bool __opened: target.shown
84 enabled: target.available
85
86 // Can be replaced with a fake implementation during tests
87 // property var __getCurrentTimeMs: function () { return new Date().getTime() }
88 property var __dateTime: new function() {
89 this.getCurrentTimeMs = function() {return new Date().getTime()}
90 }
91
92 Component.onCompleted: target[boundProperty] = __opened ? openedValue : closedValue
93 onOpenedValueChanged: if (__opened && !dragging) target[boundProperty] = openedValue
94 onClosedValueChanged: if (!__opened && !dragging) target[boundProperty] = closedValue
95
96 function __computeValue(dragPosition) {
97 return MathUtils.clamp(dragToValue(dragPosition), __hintValue, openedValue)
98 }
99
100 function __open() {
101 hintingAnimation.stop()
102 target.show()
103 }
104
105 function __close() {
106 hintingAnimation.stop()
107 target.hide()
108 }
109
110 function __hint() {
111 target.showAnimation.stop()
112 target.hideAnimation.stop()
113 hintingAnimation.restart()
114 }
115
116 function __settle() {
117 hintingAnimation.stop()
118 if (__opened) target.show()
119 else target.hide()
120 }
121
122 function __startDragging() {
123 hintingAnimation.stop()
124 dragging = true
125 }
126
127 function __endDragging(dragVelocity) {
128 dragging = false
129 if (revealer.direction == Qt.RightToLeft) {
130 dragVelocity = -dragVelocity
131 }
132 if (Math.abs(dragVelocity) >= dragVelocityThreshold) {
133 if (dragVelocity > 0) __open()
134 else __close()
135 } else {
136 __settle()
137 }
138 }
139
140 Binding {
141 id: dragBinding
142
143 target: revealer.target
144 property: revealer.boundProperty
145 value: __computeValue(dragPosition)
146 when: dragging
147 }
148
149 SmoothedAnimation {
150 id: hintingAnimation
151
152 target: revealer.target
153 property: revealer.boundProperty
154 duration: 150
155 to: revealer.__hintValue
156 }
157
158 DraggingArea {
159 id: leftDraggingArea
160
161 property bool isOpeningArea: revealer.direction == Qt.LeftToRight
162
163 height: orientation == Qt.Vertical ? handleSize : parent.height
164 width: orientation == Qt.Horizontal ? handleSize : parent.width
165 orientation: revealer.orientation
166 enabled: isOpeningArea ? !revealer.__opened : revealer.__opened
167
168 __dateTime: revealer.__dateTime
169
170 onPressed: {
171 if (isOpeningArea) {
172 if (revealer.openOnPress) {
173 revealer.openPressed(mouseX, mouseY)
174 __hint()
175 }
176 } else {
177 revealer.closePressed()
178 }
179 }
180 onReleased: {
181 if (isOpeningArea && revealer.openOnPress) {
182 revealer.openReleased(mouseX, mouseY)
183 __settle()
184 }
185 }
186 onDragStart: __startDragging()
187 onDragEnd: __endDragging(dragVelocity)
188 onClicked: {
189 if (clickValidated) {
190 if (isOpeningArea) {
191 if (revealer.openOnPress) revealer.openClicked()
192 } else {
193 revealer.closeClicked()
194 }
195 }
196 }
197 }
198
199 DraggingArea {
200 id: rightDraggingArea
201
202 property bool isOpeningArea: revealer.direction == Qt.RightToLeft
203
204 x: orientation == Qt.Vertical ? 0 : parent.width - width
205 y: orientation == Qt.Vertical ? parent.height - height : 0
206 height: orientation == Qt.Vertical ? handleSize : parent.height
207 width: orientation == Qt.Horizontal ? handleSize : parent.width
208 orientation: revealer.orientation
209 enabled: isOpeningArea ? !revealer.__opened : revealer.__opened
210
211 __dateTime: revealer.__dateTime
212
213 onPressed: {
214 if (isOpeningArea) {
215 if (revealer.openOnPress) {
216 revealer.openPressed(mouseX, mouseY)
217 __hint()
218 }
219 } else {
220 revealer.closePressed()
221 }
222 }
223 onReleased: {
224 if (isOpeningArea && revealer.openOnPress) {
225 revealer.openReleased(mouseX, mouseY)
226 __settle()
227 }
228 }
229 onDragStart: __startDragging()
230 onDragEnd: __endDragging(dragVelocity)
231 onClicked: {
232 if (clickValidated) {
233 if (isOpeningArea) {
234 if (revealer.openOnPress) revealer.openClicked()
235 } else {
236 revealer.closeClicked()
237 }
238 }
239 }
240 }
241}
2420
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2014-05-06 07:55:56 +0000
+++ tests/qmltests/CMakeLists.txt 2014-05-14 12:48:24 +0000
@@ -28,7 +28,6 @@
28add_qml_test(Components Rating)28add_qml_test(Components Rating)
29add_qml_test(Components ResponsiveFlowView)29add_qml_test(Components ResponsiveFlowView)
30add_qml_test(Components ResponsiveGridView)30add_qml_test(Components ResponsiveGridView)
31add_qml_test(Components Revealer)
32add_qml_test(Components SeeMore)31add_qml_test(Components SeeMore)
33add_qml_test(Components Showable)32add_qml_test(Components Showable)
34add_qml_test(Components PageHeaderLabel)33add_qml_test(Components PageHeaderLabel)
3534
=== removed file 'tests/qmltests/Components/RevealingRectangle.qml'
--- tests/qmltests/Components/RevealingRectangle.qml 2013-12-17 16:04:47 +0000
+++ tests/qmltests/Components/RevealingRectangle.qml 1970-01-01 00:00:00 +0000
@@ -1,78 +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
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import "../../../qml/Components"
20
21Item {
22 id: revealingRectangle
23
24 property int orientation: Qt.Vertical
25 property int direction: Qt.LeftToRight
26 property Revealer revealer: __revealer
27 property Showable showable: __showable
28
29 Revealer {
30 id: __revealer
31
32 target: __showable
33 width: target.width
34 height: target.height
35 x: orientation == Qt.Vertical ? 0 : direction == Qt.LeftToRight ? 0 : parent.width - width
36 y: orientation == Qt.Horizontal ? 0 : direction == Qt.LeftToRight ? 0 : parent.height - height
37 handleSize: orientation == Qt.Vertical ? handle.height : handle.width
38 hintDisplacement: handleSize
39 orientation: revealingRectangle.orientation
40 direction: revealingRectangle.direction
41 }
42
43 Showable {
44 id: __showable
45
46 width: orientation == Qt.Horizontal ? units.gu(24) : parent.width
47 height: orientation == Qt.Vertical ? units.gu(24) : parent.height
48
49 shown: false
50 showAnimation: SmoothedAnimation {
51 property: orientation == Qt.Horizontal ? "x" : "y"
52 velocity: __revealer.dragVelocity
53 duration: 200
54 to: __revealer.openedValue
55 }
56 hideAnimation: SmoothedAnimation {
57 property: orientation == Qt.Horizontal ? "x" : "y"
58 velocity: __revealer.dragVelocity
59 duration: 200
60 to: __revealer.closedValue
61 }
62
63 Rectangle {
64 anchors.fill: parent
65 color: "red"
66 }
67
68 Rectangle {
69 id: handle
70
71 x: orientation == Qt.Vertical ? 0 : direction == Qt.LeftToRight ? parent.width - width : 0
72 y: orientation == Qt.Horizontal ? 0 : direction == Qt.LeftToRight ? parent.height - height : 0
73 width: orientation == Qt.Horizontal ? units.gu(2) : parent.width
74 height: orientation == Qt.Vertical ? units.gu(2) : parent.height
75 color: "black"
76 }
77 }
78}
790
=== removed file 'tests/qmltests/Components/tst_Revealer.qml'
--- tests/qmltests/Components/tst_Revealer.qml 2013-06-05 22:03:08 +0000
+++ tests/qmltests/Components/tst_Revealer.qml 1970-01-01 00:00:00 +0000
@@ -1,262 +0,0 @@
1/*
2 * Copyright 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
17import QtQuick 2.0
18import QtTest 1.0
19import Unity.Test 0.1 as UT
20import ".."
21
22/*
23 There's a revealer on each window edge. If you press and hold any edge you
24 should see a black bar appearing from that edge. If you them slide the
25 pointer/finger towards the opposite edge, that black bar should follow
26 the movement up to around the center of the window. Next to the black bar,
27 which represents the "handle" area of the Revealer, You should see a red rectangle,
28 which is the main body of the Showable concrolled by the Revealer (Showable = red
29 + black rects).
30 */
31Item {
32 width: units.gu(75)
33 height: units.gu(50)
34
35 RevealingRectangle {
36 id: topRevealingRectangle
37 anchors.fill: parent
38 orientation: Qt.Vertical
39 direction: Qt.LeftToRight
40 }
41
42 RevealingRectangle {
43 id: bottomRevealingRectangle
44 anchors.fill: parent
45 orientation: Qt.Vertical
46 direction: Qt.RightToLeft
47 }
48
49 RevealingRectangle {
50 id: leftRevealingRectangle
51 anchors.fill: parent
52 orientation: Qt.Horizontal
53 direction: Qt.LeftToRight
54 }
55
56 RevealingRectangle {
57 id: rightRevealingRectangle
58 anchors.fill: parent
59 orientation: Qt.Horizontal
60 direction: Qt.RightToLeft
61 }
62
63 UT.UnityTestCase {
64 name: "Revealer"
65 when: windowShown
66
67 /*
68 A bit of the showable should be displayed when you press over the
69 handle area of the Revealer.
70
71 Once released, it should go out of sight again.
72 */
73 function test_showHintOnPress() {
74 var revealer = topRevealingRectangle.revealer
75 var showable = topRevealingRectangle.showable
76
77 // It starts out of sight
78 compare(showable.y, -showable.height)
79
80 // (item, x, y, button, modifiers, delay)
81 mousePress(revealer,
82 revealer.width/2,
83 revealer.handleSize/2,
84 Qt.LeftButton, Qt.NoModifier, 0);
85
86 tryCompare(showable, "y", -showable.height + revealer.handleSize)
87
88 // (item, x, y, button, modifiers, delay)
89 mouseRelease(revealer,
90 revealer.width/2,
91 revealer.handleSize/2,
92 Qt.LeftButton, Qt.NoModifier, 0);
93
94 tryCompare(showable, "y", -showable.height)
95 }
96
97 /*
98 Press over the handle area of the Revealer and drag it to pull
99 its target Showable. Release it half-way and the Showable will
100 continue moving by itself until it's completely shown.
101
102
103 Press over the handle area and drag it back to hide the Showable.
104 Release it half-way and it will continue moving by itself until it's
105 completely hidden again.
106 */
107 function test_dragToRevealAndDragBackToHide_top() {
108 var revealer = topRevealingRectangle.revealer
109 var showable = topRevealingRectangle.showable
110 revealer.__dateTime = fakeDateTime
111
112 // It starts out of sight
113 compare(showable.y, -showable.height)
114
115 mouseFlick(revealer,
116 revealer.width/2, // from_x
117 revealer.handleSize/2, // from_y
118 revealer.width/2, // to_x
119 showable.height/2); // to_y
120
121 // Should eventually get fully extended
122 tryCompare(showable, "y", 0)
123
124 // Now drag it back to get it hidden
125
126 mouseFlick(revealer,
127 revealer.width/2,
128 showable.height - (revealer.handleSize/2),
129 revealer.width/2,
130 showable.height/2)
131
132 // Should eventually be completely out of sight
133 tryCompare(showable, "y", -showable.height)
134 }
135
136 function test_dragToRevealAndDragBackToHide_bottom() {
137 var revealer = bottomRevealingRectangle.revealer
138 var showable = bottomRevealingRectangle.showable
139 var revRect = bottomRevealingRectangle
140 revealer.__dateTime = fakeDateTime
141
142 // It starts out of sight
143 compare(showable.y, revRect.height)
144
145 mouseFlick(revealer,
146 revealer.width/2, // from_x
147 revealer.height - revealer.handleSize/2, // from_y
148 revealer.width/2, // to_x
149 revealer.height - showable.height/2); // to_y
150
151 // Should eventually get fully extended
152 tryCompare(showable, "y", revRect.height - showable.height)
153
154 // Now drag it back to get it hidden
155
156 mouseFlick(revealer,
157 revealer.width/2,
158 revealer.handleSize/2,
159 revealer.width/2,
160 revealer.height - showable.height/2)
161
162 // Should eventually be completely out of sight
163 tryCompare(showable, "y", revRect.height)
164 }
165
166 function test_dragToRevealAndDragBackToHide_left() {
167 var revealer = leftRevealingRectangle.revealer
168 var showable = leftRevealingRectangle.showable
169 revealer.__dateTime = fakeDateTime
170
171 // It starts out of sight
172 compare(showable.x, -showable.width)
173
174 mouseFlick(revealer,
175 revealer.handleSize/2, // from_x
176 revealer.height/2, // from_y
177 showable.width/2, // to_x
178 revealer.height/2) // to_y
179
180 // Should eventually get fully extended
181 tryCompare(showable, "x", 0)
182
183 // Now drag it back to get it hidden
184
185 mouseFlick(revealer,
186 showable.width - (revealer.handleSize/2),
187 revealer.height/2,
188 showable.width/2,
189 revealer.height/2)
190
191 // Should eventually be completely out of sight
192 tryCompare(showable, "x", -showable.width)
193 }
194
195 function test_dragToRevealAndDragBackToHide_right() {
196 var revealer = rightRevealingRectangle.revealer
197 var showable = rightRevealingRectangle.showable
198 var revRect = rightRevealingRectangle
199 revealer.__dateTime = fakeDateTime
200
201 // It starts out of sight
202 compare(showable.x, revRect.width)
203
204 mouseFlick(revealer,
205 revealer.width - revealer.handleSize/2, // from_x
206 revealer.height/2, // from_y
207 revealer.width - showable.width/2, // to_x
208 revealer.height/2) // to_y
209
210 // Should eventually get fully extended
211 tryCompare(showable, "x", revRect.width - showable.width)
212
213 // Now drag it back to get it hidden
214
215 mouseFlick(revealer,
216 revealer.handleSize/2,
217 revealer.height/2,
218 revealer.width - showable.width/2,
219 revealer.height/2)
220
221 // Should eventually be completely out of sight
222 tryCompare(showable, "x", revRect.width)
223 }
224
225 /*
226 Start dragging down (pulling the showable into view) and then,
227 midway, drag a bit upwards and release it.
228 The showable should keep moving away, ending up hidden again.
229 */
230 function test_dragForthAndBackReturnsOriginalState() {
231 var revealer = topRevealingRectangle.revealer
232 var showable = topRevealingRectangle.showable
233 revealer.__dateTime = fakeDateTime
234
235 // It starts out of sight
236 compare(showable.y, -showable.height)
237
238 mouseFlick(revealer,
239 revealer.width/2, // from_x
240 revealer.handleSize/2, // from_y
241 revealer.width/2, // to_x
242 showable.height/2, // to_y
243 true /* do press */, false /* don't release */);
244
245 // Should be about half-extended
246 verify(showable.y > -showable.height*3/4)
247 verify(showable.y < -showable.height*1/4)
248
249
250 // Now drag it back a bit
251 mouseFlick(revealer,
252 revealer.width/2, // from_x
253 showable.height/2, // from_y
254 revealer.width/2, // to_x
255 showable.height/4, // to_y
256 false /* don't press */, true /* do release */);
257
258 // Should eventually be completely out of sight again
259 tryCompare(showable, "y", -showable.height)
260 }
261 }
262}

Subscribers

People subscribed via source and target branches