on xenial help sign in
adhere to the project's coding style
commit648e4f295fa6dae94b67deb9f693988a4791de2f authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 26 Jun 2013, 13:49 (13 years ago) parent9cb758a
7 files changed+65−59
Components/DragHandle.qml+30−27 Components/EdgeDragEvaluator.qml+13−12 Components/Stage.qml+1−1 Shell.qml+2−3 tests/qmltests/Components/tst_DragHandle.qml+15−12 tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+2−2 tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+2−2
Components/DragHandle.qml+30−27
@@ -72,16 +72,16 @@ DirectionalDragArea {
7272 onDistanceChanged: {
7373 if (status === DirectionalDragArea.Recognized) {
7474 // don't go the whole distance in order to smooth out the movement
75− var step = distance * 0.3
75+ var step = distance * 0.3;
7676
77− step = __limitMovement(step)
77+ step = __limitMovement(step);
7878
79− __totalDragDistance += step
79+ __totalDragDistance += step;
8080
8181 if (Direction.isHorizontal(direction)) {
82− parent.x += step
82+ parent.x += step;
8383 } else {
84− parent.y += step
84+ parent.y += step;
8585 }
8686 }
8787 }
@@ -90,56 +90,59 @@ DirectionalDragArea {
9090 function __limitMovement(step) {
9191 if (Direction.isPositive(direction)) {
9292 if (__totalDragDistance + step > maxTotalDragDistance) {
93− step = maxTotalDragDistance - __totalDragDistance
93+ step = maxTotalDragDistance - __totalDragDistance;
9494 } else if (__totalDragDistance + step < 0) {
95− step = 0 - __totalDragDistance
95+ step = 0 - __totalDragDistance;
9696 }
9797 } else {
9898 if (__totalDragDistance + step < -maxTotalDragDistance) {
99− step = -maxTotalDragDistance - __totalDragDistance
99+ step = -maxTotalDragDistance - __totalDragDistance;
100100 } else if (__totalDragDistance + step > 0) {
101− step = 0 - __totalDragDistance
101+ step = 0 - __totalDragDistance;
102102 }
103103 }
104104
105− return step
105+ return step;
106106 }
107107
108108 onStatusChanged: {
109109 if (status === DirectionalDragArea.WaitingForTouch) {
110110 if (__previousStatus === DirectionalDragArea.Recognized) {
111− __onFinishedRecognizedGesture()
111+ __onFinishedRecognizedGesture();
112112 }
113− __totalDragDistance = 0
113+ __totalDragDistance = 0;
114114 }
115115 else if (status === DirectionalDragArea.Undecided) {
116− dragEvaluator.reset()
116+ dragEvaluator.reset();
117117 }
118118 else if (status === DirectionalDragArea.Recognized) {
119119 if (__previousStatus === DirectionalDragArea.WaitingForTouch)
120− dragEvaluator.reset()
120+ dragEvaluator.reset();
121121 }
122− __previousStatus = status
122+ __previousStatus = status;
123123 }
124124
125125 function __onFinishedRecognizedGesture() {
126− if (dragEvaluator.shouldAutoComplete())
127− __completeDrag()
128− else
129− __rollbackDrag()
126+ if (dragEvaluator.shouldAutoComplete()) {
127+ __completeDrag();
128+ } else {
129+ __rollbackDrag();
130+ }
130131 }
131132
132133 function __completeDrag() {
133− if (parent.shown)
134− parent.hide()
135− else
136− parent.show()
134+ if (parent.shown) {
135+ parent.hide();
136+ } else {
137+ parent.show();
138+ }
137139 }
138140
139141 function __rollbackDrag() {
140− if (parent.shown)
141− parent.show()
142− else
143− parent.hide()
142+ if (parent.shown) {
143+ parent.show();
144+ } else {
145+ parent.hide();
146+ }
144147 }
145148}
Components/EdgeDragEvaluator.qml+13−12
@@ -52,21 +52,22 @@ AxisVelocityCalculator {
5252
5353 // Returns whether the drag should continue by itself until completed.
5454 function shouldAutoComplete() {
55− var deltaPos = trackedPosition - __startPosition
55+ var deltaPos = trackedPosition - __startPosition;
5656 if (Math.abs(deltaPos) < minDragDistance) {
57− velocity = 0
58− minVelocity = 0
59− return false
57+ velocity = 0;
58+ minVelocity = 0;
59+ return false;
6060 }
6161
62− minVelocity = __calculateMinimumVelocityForAutoCompletion(deltaPos)
63− velocity = calculate()
62+ minVelocity = __calculateMinimumVelocityForAutoCompletion(deltaPos);
63+ velocity = calculate();
6464
6565 if (Direction.isPositive(direction) && (velocity >= minVelocity)
66− || !Direction.isPositive(direction) && (velocity <= minVelocity))
67− return true
68− else
69− return false
66+ || !Direction.isPositive(direction) && (velocity <= minVelocity)) {
67+ return true;
68+ } else {
69+ return false;
70+ }
7071 }
7172
7273 property real __startPosition
@@ -78,10 +79,10 @@ AxisVelocityCalculator {
7879 property real __v0: Direction.isPositive(direction) ? __speedThresholdMs : - __speedThresholdMs
7980
8081 function __calculateMinimumVelocityForAutoCompletion(distance) {
81− return __v0 - ((__speedThresholdMs / dragThreshold) * distance)
82+ return __v0 - ((__speedThresholdMs / dragThreshold) * distance);
8283 }
8384
8485 function reset() {
85− __startPosition = trackedPosition
86+ __startPosition = trackedPosition;
8687 }
8788}
Components/Stage.qml+1−1
@@ -480,7 +480,7 @@ Showable {
480480 }
481481
482482 function onUndecided() {
483− dragEvaluator.reset()
483+ dragEvaluator.reset();
484484
485485 var nextApplication = null;
486486 if (stage.applications.count > 1) {
Shell.qml+2−3
@@ -170,9 +170,9 @@ FocusScope {
170170 opacity: 1.0 - disappearingAnimationProgress
171171 property real disappearingAnimationProgress: {
172172 if (greeter.shown) {
173− return greeter.showProgress
173+ return greeter.showProgress;
174174 } else {
175− return stagesOuterContainer.showProgress
175+ return stagesOuterContainer.showProgress;
176176 }
177177 }
178178
@@ -439,7 +439,6 @@ FocusScope {
439439 var bgPath = greeter.model.data(uid, LightDM.UserRoles.BackgroundPathRole)
440440 shell.background = bgPath ? bgPath : default_background
441441 }
442−
443442 }
444443
445444 InputFilterArea {
tests/qmltests/Components/tst_DragHandle.qml+15−12
@@ -70,10 +70,11 @@ Item {
7070
7171 y: {
7272 if (dragHandle) {
73− if (dragHandle.direction === Direction.Downwards)
74− dragHandle.edgeDragEvaluator.dragThreshold
75− else
76− parent.height - dragHandle.edgeDragEvaluator.dragThreshold
73+ if (dragHandle.direction === Direction.Downwards) {
74+ dragHandle.edgeDragEvaluator.dragThreshold;
75+ } else {
76+ parent.height - dragHandle.edgeDragEvaluator.dragThreshold;
77+ }
7778 } else {
7879 0
7980 }
@@ -90,20 +91,22 @@ Item {
9091 id: velocityText
9192 font.pixelSize: units.gu(2)
9293 text: {
93− if (dragHandle !== undefined)
94− "Velocity: " + (dragHandle.edgeDragEvaluator.velocity * 1000)
95− else
96− "Velocity: -"
94+ if (dragHandle !== undefined) {
95+ "Velocity: " + (dragHandle.edgeDragEvaluator.velocity * 1000);
96+ } else {
97+ "Velocity: -";
98+ }
9799 }
98100 }
99101 Text {
100102 anchors.top: velocityText.bottom
101103 font.pixelSize: units.gu(2)
102104 text: {
103− if (dragHandle !== undefined)
104− "Minimum velocity: " + (dragHandle.edgeDragEvaluator.minVelocity * 1000)
105− else
106− "Minimum velocity: -"
105+ if (dragHandle !== undefined) {
106+ "Minimum velocity: " + (dragHandle.edgeDragEvaluator.minVelocity * 1000);
107+ } else {
108+ "Minimum velocity: -";
109+ }
107110 }
108111 }
109112 }
tests/qmltests/Components/tst_DragHandle/HorizontalShowable.qml+2−2
@@ -47,7 +47,7 @@ Showable {
4747
4848 onStatusChanged: {
4949 if (status === DirectionalDragArea.Recognized)
50− dragHandleRecognizedGesture(leftwardsDragHandle)
50+ dragHandleRecognizedGesture(leftwardsDragHandle);
5151 }
5252
5353 Rectangle { color: "red"; anchors.fill: parent }
@@ -66,7 +66,7 @@ Showable {
6666
6767 onStatusChanged: {
6868 if (status === DirectionalDragArea.Recognized)
69− dragHandleRecognizedGesture(rightwardsDragHandle)
69+ dragHandleRecognizedGesture(rightwardsDragHandle);
7070 }
7171
7272 Rectangle { color: "green"; anchors.fill: parent }
tests/qmltests/Components/tst_DragHandle/VerticalShowable.qml+2−2
@@ -47,7 +47,7 @@ Showable {
4747
4848 onStatusChanged: {
4949 if (status === DirectionalDragArea.Recognized)
50− dragHandleRecognizedGesture(upwardsDragHandle)
50+ dragHandleRecognizedGesture(upwardsDragHandle);
5151 }
5252
5353 Rectangle { color: "red"; anchors.fill: parent }
@@ -66,7 +66,7 @@ Showable {
6666
6767 onStatusChanged: {
6868 if (status === DirectionalDragArea.Recognized)
69− dragHandleRecognizedGesture(downwardsDragHandle)
69+ dragHandleRecognizedGesture(downwardsDragHandle);
7070 }
7171
7272 Rectangle { color: "green"; anchors.fill: parent }