Merge lp:~nik90/ubuntu-clock-app/replace-clock-hand-animation into lp:ubuntu-clock-app/saucy

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Michael Hall
Approved revision: 128
Merged at revision: 130
Proposed branch: lp:~nik90/ubuntu-clock-app/replace-clock-hand-animation
Merge into: lp:ubuntu-clock-app/saucy
Diff against target: 347 lines (+100/-122)
5 files modified
clock/AnalogClockFace.qml (+10/-13)
common/AnalogClockHand.qml (+30/-24)
stopwatch/AnalogStopwatch.qml (+6/-9)
timer/AnalogTimer.qml (+4/-3)
timer/AnalogTouchHand.qml (+50/-73)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/replace-clock-hand-animation
Reviewer Review Type Date Requested Status
Michael Hall Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+173341@code.launchpad.net

Commit message

Removes clock hand spring animation since it was causing delays which caused the second hand to sometimes skip seconds in order to catch up with the current time. It also refactors analog touch hand based on the new clock hand implementation.

Description of the change

Removes clock hand spring animation since it was causing delays which caused the second hand to sometimes skip seconds in order to catch up with the current time. It also refactors analog touch hand based on the new clock hand implementation.

Still requires device testing! Do not merge!

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Hall (mhall119) wrote :

Second hand ticks are consistent on the Nexus 7 with this change

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clock/AnalogClockFace.qml'
2--- clock/AnalogClockFace.qml 2013-06-09 10:36:55 +0000
3+++ clock/AnalogClockFace.qml 2013-07-07 09:56:23 +0000
4@@ -37,7 +37,7 @@
5 function timeChanged(now) {
6 hours = now.getHours()
7 minutes = now.getMinutes()
8- seconds = now.getUTCSeconds();
9+ seconds = now.getUTCSeconds();
10 }
11
12 // FIXME 1: Replace this with UbuntuShape when the widget has landed in the SDK.
13@@ -50,34 +50,31 @@
14 radius: width / 2;
15 anchors.centerIn: parent;
16 color: Constants.coolGrey;
17- antialiasing: true;
18+ antialiasing: true;
19 }
20
21 AnalogClockHand {
22 id: hourHand
23
24 z: parent.z
25- height: units.gu(12.5); width: units.gu(1);
26- rotationAngle: (clockRoot.hours * 30) + (clockRoot.minutes / 2);
27- antialiasing: true;
28+ handHeight: units.gu(12.5); handWidth: units.gu(1);
29+ rotation: (clockRoot.hours * 30) + (clockRoot.minutes / 2);
30 }
31
32 AnalogClockHand {
33 id: minuteHand
34
35- z: parent.z
36- height: units.gu(14.5); width: units.gu(0.5);
37- rotationAngle: clockRoot.minutes * 6;
38- antialiasing: true;
39+ z: parent.z + 1
40+ handHeight: units.gu(14.5); handWidth: units.gu(0.5);
41+ rotation: clockRoot.minutes * 6;
42 }
43
44 AnalogClockHand {
45 id: secondsHand
46
47- z: parent.z - 1;
48- height: units.gu(17); width: units.gu(0.5)
49- rotationAngle: clockRoot.seconds * 6;
50- antialiasing: true;
51+ z: clockRoot.z - 1;
52+ handHeight: units.gu(17); handWidth: units.gu(0.5)
53+ rotation: clockRoot.seconds * 6;
54 }
55
56 MouseArea {
57
58=== modified file 'common/AnalogClockHand.qml'
59--- common/AnalogClockHand.qml 2013-06-21 22:06:05 +0000
60+++ common/AnalogClockHand.qml 2013-07-07 09:56:23 +0000
61@@ -13,33 +13,39 @@
62 * You should have received a copy of the GNU General Public License
63 * along with this program. If not, see <http://www.gnu.org/licenses/>.
64 *
65- * Authored by: Juha Ristolainen <juha.ristolainen@codemancers.fi>
66- * Nekhelesh Ramananthan <krnekhelesh@gmail.com>
67- * Nick Leppänen Larsson <frals@frals.se>
68+ * Authored by: Nekhelesh Ramananthan <krnekhelesh@gmail.com>
69 */
70
71 import QtQuick 2.0
72 import "../common/Constants.js" as Constants
73
74-Rectangle {
75- id: hand
76-
77- property alias rotationAngle: handRotation.angle
78-
79- x: (parent.width / 2) - (width / 2); y: (parent.height / 2) - height; z: 2
80- width: units.gu(1); height: units.gu(14);
81- radius: units.gu(1)
82- color: Constants.coolGrey
83- antialiasing: true
84-
85- transform: Rotation {
86- id: handRotation
87-
88- origin { x: hand.width / 2; y: hand.height }
89-
90- Behavior on angle {
91- SpringAnimation { spring: 2; damping: 0.3; modulus: 360 }
92- }
93- }
94-
95+// Qml component to draw the analog clock hand
96+Rectangle{
97+ id: analogClockHandContainer
98+
99+ property alias handHeight: analogClockHand.height
100+ property alias handWidth: analogClockHand.width
101+ property alias handRotationAnimation: analogClockHandRotation.enabled
102+
103+ radius: width / 2
104+ anchors.fill: parent
105+ transformOrigin: Item.Center
106+ color: "transparent";
107+
108+ Rectangle {
109+ id: analogClockHand
110+
111+ x: (parent.width / 2) - (width / 2); y: (parent.height / 2) - height; z: 2;
112+ width: units.gu(1); height: units.gu(14);
113+ radius: units.gu(1)
114+ color: Constants.coolGrey
115+ antialiasing: true
116+ }
117+
118+ Behavior on rotation {
119+ id: analogClockHandRotation
120+ enabled: true;
121+ RotationAnimation { direction: RotationAnimation.Shortest }
122+ }
123 }
124+
125
126=== modified file 'stopwatch/AnalogStopwatch.qml'
127--- stopwatch/AnalogStopwatch.qml 2013-06-25 21:51:35 +0000
128+++ stopwatch/AnalogStopwatch.qml 2013-07-07 09:56:23 +0000
129@@ -130,26 +130,23 @@
130 id: hourHand
131
132 z: parent.z
133- height: units.gu(12.5); width: units.gu(1);
134- rotationAngle: hours * 15;
135- antialiasing: true;
136+ handHeight: units.gu(12.5); handWidth: units.gu(1);
137+ rotation: hours * 15;
138 }
139
140 AnalogClockHand {
141 id: minuteHand
142
143 z: parent.z
144- height: units.gu(14.5); width: units.gu(0.5);
145- rotationAngle: minutes * 6;
146- antialiasing: true;
147+ handHeight: units.gu(14.5); handWidth: units.gu(0.5);
148+ rotation: minutes * 6;
149 }
150
151 AnalogClockHand {
152 id: secondHand
153
154 z: parent.z - 1;
155- height: units.gu(17); width: units.gu(0.5)
156- rotationAngle: seconds * 6;
157- antialiasing: true;
158+ handHeight: units.gu(17); handWidth: units.gu(0.5)
159+ rotation: seconds * 6;
160 }
161 }
162
163=== modified file 'timer/AnalogTimer.qml'
164--- timer/AnalogTimer.qml 2013-06-25 21:43:57 +0000
165+++ timer/AnalogTimer.qml 2013-07-07 09:56:23 +0000
166@@ -110,9 +110,10 @@
167 onTimerValueChanged: hours = timerValue;
168
169 handHeight: units.gu(12.5); handWidth: units.gu(1);
170- zOrder: minuteHand.z + 1;
171+ z: minuteHand.z + 1;
172 animateFlag: inProgressFlag;
173 enabled: !inProgressFlag;
174+ grabMargin: units.gu(3);
175 }
176
177 // Minute hand with touch/mouse drag support
178@@ -124,7 +125,7 @@
179 handHeight: units.gu(14.5); handWidth: units.gu(0.5);
180 animateFlag: inProgressFlag;
181 enabled: !inProgressFlag;
182- grabMargin: -units.gu(1)
183+ grabMargin: units.gu(0)
184 grabHeight: units.gu(7)
185 }
186
187@@ -135,7 +136,7 @@
188 onTimerValueChanged: seconds = timerValue;
189
190 handHeight: units.gu(17); handWidth: units.gu(0.5);
191- zOrder: parent.z - 1;
192+ z: parent.z - 1;
193 animateFlag: inProgressFlag;
194 enabled: !inProgressFlag;
195 grabMargin: -units.gu(2)
196
197=== modified file 'timer/AnalogTouchHand.qml'
198--- timer/AnalogTouchHand.qml 2013-06-25 21:43:57 +0000
199+++ timer/AnalogTouchHand.qml 2013-07-07 09:56:23 +0000
200@@ -32,97 +32,74 @@
201 Enable/Disable rotation animation. Disable it while dragging the clock hand to avoid
202 receiving inaccurate input values.
203 */
204- property alias animateFlag: rotation.enabled;
205+ property alias animateFlag: hand.handRotationAnimation
206
207 /*!
208 Set if the dial should be rotated by the seconds, minutes or hours. This generally needs to be
209 multiplied by 6 to convert it into degrees per second/hour/minute.
210 */
211- property alias rotationValue: rotatingDial.rotation;
212-
213+ property alias rotationValue: hand.rotation;
214
215 // Set the touch/mouse grab area height and top margin
216 property alias grabHeight: grabArea.height;
217 property int grabMargin: units.gu(0);
218
219 // Height and width of the clock hand
220- property alias handHeight: hand.height;
221- property alias handWidth: hand.width;
222-
223- // z order of the clock hand
224- property alias zOrder: touchHand.z;
225+ property alias handHeight: hand.handHeight;
226+ property alias handWidth: hand.handWidth;
227
228 // internal properties required for the functioning of the AnalogTouchHand
229- property int timerValue: 0;
230- property real centerX : (width / 2);
231- property real centerY : (height / 2);
232-
233- // Dial which covers the clock hand and does the actual rotatio
234- Rectangle{
235- id: rotatingDial;
236-
237- color: "transparent";
238- transformOrigin: Item.Center;
239- radius: (width / 2);
240- antialiasing: true;
241- anchors.fill: parent;
242-
243- // Clock hand which lies above the rotating dial. This is stationary w.r.t to the rotating dial.
244- AnalogClockHand {
245- id: hand
246-
247- height: units.gu(0); width: units.gu(0);
248- antialiasing: true;
249-
250- /*!
251+ property int timerValue: 0
252+ property real centerX : width / 2
253+ property real centerY : height / 2
254+
255+ // Clock hand which lies above the rotating dial. This is stationary w.r.t to the rotating dial.
256+ AnalogClockHand {
257+ id: hand
258+
259+ handHeight: units.gu(0); handWidth: units.gu(0);
260+
261+ /*!
262 Element to define the grab area of the clock hand. This allows us to define small clock hand
263 which are still easier to grab.
264 */
265- Rectangle {
266- id: grabArea
267- color: "transparent"
268- width: units.gu(5); height: width;
269- anchors { top: hand.top; topMargin: touchHand.grabMargin; horizontalCenter: hand.horizontalCenter }
270- }
271-
272- MouseArea{
273- anchors.fill: grabArea;
274- preventStealing: true;
275- enabled: true;
276- onPositionChanged: {
277- var point = mapToItem (touchHand, mouse.x, mouse.y);
278- var diffX = (point.x - touchHand.centerX);
279- var diffY = -1 * (point.y - touchHand.centerY);
280- var rad = Math.atan (diffY / diffX);
281- var deg = (rad * 180 / Math.PI);
282-
283- if (diffX > 0 && diffY > 0) {
284- rotatingDial.rotation = 90 - Math.abs (deg);
285- }
286- else if (diffX > 0 && diffY < 0) {
287- rotatingDial.rotation = 90 + Math.abs (deg);
288- }
289- else if (diffX < 0 && diffY > 0) {
290- rotatingDial.rotation = 270 + Math.abs (deg);
291- }
292- else if (diffX < 0 && diffY < 0) {
293- rotatingDial.rotation = 270 - Math.abs (deg);
294- }
295-
296- if (Math.round(rotatingDial.rotation/6) == 60) {
297- touchHand.timerValue == 0
298- } else {
299- touchHand.timerValue = Math.round(rotatingDial.rotation/6);
300- }
301-
302- }
303- }
304+ Rectangle {
305+ id: grabArea
306+ color: "transparent"
307+ width: units.gu(5); height: width;
308+ anchors { top: hand.top; topMargin: touchHand.grabMargin; horizontalCenter: hand.horizontalCenter }
309 }
310
311- Behavior on rotation {
312- id: rotation;
313- enabled: false;
314- RotationAnimation { direction: RotationAnimation.Shortest }
315+ MouseArea{
316+ anchors.fill: grabArea;
317+ preventStealing: true;
318+ enabled: true;
319+ onPositionChanged: {
320+ var point = mapToItem (touchHand, mouse.x, mouse.y);
321+ var diffX = (point.x - touchHand.centerX);
322+ var diffY = -1 * (point.y - touchHand.centerY);
323+ var rad = Math.atan (diffY / diffX);
324+ var deg = (rad * 180 / Math.PI);
325+
326+ if (diffX > 0 && diffY > 0) {
327+ hand.rotation = 90 - Math.abs (deg);
328+ }
329+ else if (diffX > 0 && diffY < 0) {
330+ hand.rotation = 90 + Math.abs (deg);
331+ }
332+ else if (diffX < 0 && diffY > 0) {
333+ hand.rotation = 270 + Math.abs (deg);
334+ }
335+ else if (diffX < 0 && diffY < 0) {
336+ hand.rotation = 270 - Math.abs (deg);
337+ }
338+
339+ if (Math.round(hand.rotation/6) === 60) {
340+ touchHand.timerValue = 0
341+ } else {
342+ touchHand.timerValue = Math.round(hand.rotation/6);
343+ }
344+ }
345 }
346 }
347 }

Subscribers

People subscribed via source and target branches