on xenial help sign in
Removes Math.js and its usage. Use SDK ones.

Approved by PS Jenkins bot, Albert Astals Cid.

commitc3793e5ab938b632bdfbb42ce11d66aab9b7bb13 authorAndrea Cimitan <andrea.cimitan@gmail.com> dateFri 8 Nov 2013, 19:56 (13 years ago) parent8e1a8069c181e4
10 files changed+9−133
Bottombar/Bottombar.qml+3−3 Components/DragHandle.qml+1−2 Components/DraggingArea.qml+1−2 Components/Math.js−26 Components/Revealer.qml+1−2 Greeter/Greeter.qml+1−2 Panel/Indicators.qml+1−2 Shell.qml+1−2 tests/qmltests/CMakeLists.txt−1 tests/qmltests/Components/tst_MathLocal.qml−91
Bottombar/Bottombar.qml+3−3
@@ -16,10 +16,10 @@
1616
1717import QtQuick 2.0
1818import "../Components"
19−import "../Components/Math.js" as MathLocal
2019import Unity 0.1
2120import Unity.Application 0.1
2221import Ubuntu.Gestures 0.1
22+import Ubuntu.Components 0.1
2323
2424Item {
2525 id: bottombar
@@ -82,7 +82,7 @@ Item {
8282
8383 readonly property bool centeredHud: parent.width < units.gu(68) // Nexus 7 has 67 gu width
8484
85− x: centeredHud ? parent.width / 2 - width / 2 : MathLocal.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
85+ x: centeredHud ? parent.width / 2 - width / 2 : MathUtils.clamp(dragArea.touchStartX - (width / 2), 0, bottombar.width - width)
8686 y: bottombar.height - bottomEdgeButtonCenterDistance - (height / 2) - bottomMargin
8787 z: 1
8888 visible: opacity != 0
@@ -136,7 +136,7 @@ Item {
136136 readonly property real distanceFromThreshold: (-distance) - distanceThreshold // distance is negative
137137 readonly property real revealDistance: units.gu(2)
138138 readonly property real commitDistance: units.gu(6)
139− readonly property real commitProgress: MathLocal.clamp(distanceFromThreshold / commitDistance, 0, 1)
139+ readonly property real commitProgress: MathUtils.clamp(distanceFromThreshold / commitDistance, 0, 1)
140140
141141 onStatusChanged: {
142142 if (status === DirectionalDragArea.WaitingForTouch) {
Components/DragHandle.qml+1−2
@@ -17,7 +17,6 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
1919import Ubuntu.Gestures 0.1
20−import "Math.js" as MathLocal
2120
2221/*
2322 Put a DragHandle inside a Showable to enable the user to drag it from that handle.
@@ -117,7 +116,7 @@ EdgeDragArea {
117116 }
118117
119118 function limitMovement(inputStep) {
120− var targetValue = MathLocal.clamp(dragParent[targetProp] + inputStep, minValue, maxValue);
119+ var targetValue = MathUtils.clamp(dragParent[targetProp] + inputStep, minValue, maxValue);
121120 var step = targetValue - dragParent[targetProp];
122121
123122 if (hintDisplacement == 0) {
Components/DraggingArea.qml+1−2
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import "Math.js" as MathLocal
2019
2120MouseArea {
2221 id: draggingArea
@@ -26,7 +25,7 @@ MouseArea {
2625 property real dragVelocity: 0
2726 property real dragValue: (orientation == Qt.Vertical ? (mouseY - __pressedPosition.y)
2827 : (mouseX - __pressedPosition.x))
29− property real lateralPosition: orientation == Qt.Horizontal ? MathLocal.clamp(mouseY, 0, height) : MathLocal.clamp(mouseX, 0, width)
28+ property real lateralPosition: orientation == Qt.Horizontal ? MathUtils.clamp(mouseY, 0, height) : MathUtils.clamp(mouseX, 0, width)
3029 property point __pressedPosition: Qt.point(0, 0)
3130 property var __dragEvents: []
3231 property bool clickValidated: true
Components/Math.jsdeleted−26
@@ -1,26 +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−.pragma library
18−
19−function clamp(value, min, max) {
20− if (min <= max) {
21− return Math.max(min, Math.min(max, value))
22− } else {
23− // swap min/max if min > max
24− return clamp(value, max, min)
25− }
26−}
Components/Revealer.qml+1−2
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19−import "Math.js" as MathLocal
2019
2120Item {
2221 id: revealer
@@ -95,7 +94,7 @@ Item {
9594 onClosedValueChanged: if (!__opened && !dragging) target[boundProperty] = closedValue
9695
9796 function __computeValue(dragPosition) {
98− return MathLocal.clamp(dragToValue(dragPosition), __hintValue, openedValue)
97+ return MathUtils.clamp(dragToValue(dragPosition), __hintValue, openedValue)
9998 }
10099
101100 function __open() {
Greeter/Greeter.qml+1−2
@@ -19,7 +19,6 @@ import Ubuntu.Components 0.1
1919import Ubuntu.Gestures 0.1
2020import LightDM 0.1 as LightDM
2121import "../Components"
22−import "../Components/Math.js" as MathLocal
2322
2423Showable {
2524 id: greeter
@@ -29,7 +28,7 @@ Showable {
2928 property url defaultBackground
3029
3130 // 1 when fully shown and 0 when fully hidden
32− property real showProgress: MathLocal.clamp((width + x) / width, 0, 1)
31+ property real showProgress: MathUtils.clamp((width + x) / width, 0, 1)
3332
3433 showAnimation: StandardAnimation { property: "x"; to: 0 }
3534 hideAnimation: StandardAnimation { property: "x"; to: -width }
Panel/Indicators.qml+1−2
@@ -21,7 +21,6 @@ import Unity.Indicators 0.1 as Indicators
2121
2222import "../Components"
2323import "../Components/ListItems"
24−import "../Components/Math.js" as MathLocal
2524
2625Showable {
2726 id: indicators
@@ -100,7 +99,7 @@ Showable {
10099 Otherwise it contains the bar's location as a fraction of the distance between hintValue (is 0) and lockThreshold (is 1).
101100 */
102101 var verticalProgress =
103− MathLocal.clamp((indicators.height - handle.height - hintValue) /
102+ MathUtils.clamp((indicators.height - handle.height - hintValue) /
104103 (lockThreshold - hintValue), 0, 1);
105104
106105 /*
Shell.qml+1−2
@@ -30,7 +30,6 @@ import "Launcher"
3030import "Panel"
3131import "Hud"
3232import "Components"
33−import "Components/Math.js" as MathLocal
3433import "Bottombar"
3534import "SideStage"
3635import "Notifications"
@@ -237,7 +236,7 @@ FocusScope {
237236 Behavior on x {SmoothedAnimation{velocity: 600}}
238237
239238 property real showProgress:
240− MathLocal.clamp(1 - (x + stages.x) / shell.width, 0, 1)
239+ MathUtils.clamp(1 - (x + stages.x) / shell.width, 0, 1)
241240
242241 Showable {
243242 id: stages
tests/qmltests/CMakeLists.txt−1
@@ -13,7 +13,6 @@ set(qmltest_DEFAULT_NO_ADD_TEST FALSE)
1313set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
1414add_qml_test(Components AnimationControllerWithSignals)
1515add_qml_test(Components Carousel)
16−add_qml_test(Components MathLocal)
1716add_qml_test(Components OpenEffect)
1817add_qml_test(Components RatingStars)
1918add_qml_test(Components TimeLocal)
tests/qmltests/Components/tst_MathLocal.qmldeleted−91
@@ -1,91 +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−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import "../../../Components/Math.js" as MathLocal
20−
21−TestCase {
22− name: "MathLocal"
23−
24− property int minValue
25− property int maxValue
26− property int clampValue
27− property int clamped
28−
29− function test_clamp_positive_lower() {
30− minValue = 9
31− maxValue = 42
32− clampValue = -7
33−
34− clamped = MathLocal.clamp(clampValue, minValue, maxValue)
35− compare(clamped, minValue, "clamped value not within range")
36− }
37−
38− function test_clamp_positive_greater() {
39− minValue = 9
40− maxValue = 42
41− clampValue = 111
42−
43− clamped = MathLocal.clamp(clampValue, minValue, maxValue)
44− compare(clamped, maxValue, "clamped value not within range")
45− }
46−
47− function test_clamp_positive_within() {
48− minValue = 9
49− maxValue = 53
50− clampValue = 42
51−
52− clamped = MathLocal.clamp(clampValue, minValue, maxValue)
53− compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
54− }
55−
56− function test_clamp_positive_on_border() {
57− minValue = 9
58− maxValue = 42
59− clampValue = 9
60−
61− clamped = MathLocal.clamp(clampValue, minValue, maxValue)
62− compare(clamped, clampValue, "clamped value changed even though it shouldn't have")
63− }
64−
65− function test_clamp_negative_lower() {
66− minValue = -42
67− maxValue = -9
68− clampValue = -50
69−
70− clamped = MathLocal.clamp(clampValue, minValue, maxValue)
71− compare(clamped, minValue, "clamped value not within range")
72− }
73−
74− function test_clamp_negative_greater() {
75− minValue = -42
76− maxValue = -9
77− clampValue = 50
78−
79− clamped = MathLocal.clamp(clampValue, minValue, maxValue)
80− compare(clamped, maxValue, "clamped value not within range")
81− }
82−
83− function test_clamp_postive_and_negative_greater() {
84− minValue = -42
85− maxValue = 9
86− clampValue = 50
87−
88− clamped = MathLocal.clamp(clampValue, minValue, maxValue)
89− compare(clamped, maxValue, "clamped value not within range")
90− }
91−}