Merge lp:~fboucault/ubuntu-ui-toolkit/standard_animations into lp:ubuntu-ui-toolkit
- standard_animations
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 492 |
Merged at revision: | 494 |
Proposed branch: | lp:~fboucault/ubuntu-ui-toolkit/standard_animations |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
792 lines (+471/-42) 19 files modified
examples/ubuntu-ui-toolkit-gallery/AnimationCircle.qml (+31/-0) examples/ubuntu-ui-toolkit-gallery/Animations.qml (+187/-0) examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml (+6/-0) modules/Ubuntu/Components/Header.qml (+1/-1) modules/Ubuntu/Components/ListItems/Empty.qml (+2/-4) modules/Ubuntu/Components/ListItems/ValueSelector.qml (+5/-4) modules/Ubuntu/Components/OrientationHelper.qml (+2/-2) modules/Ubuntu/Components/Panel.qml (+4/-8) modules/Ubuntu/Components/UbuntuNumberAnimation.qml (+56/-0) modules/Ubuntu/Components/plugin/plugin.cpp (+2/-0) modules/Ubuntu/Components/plugin/plugin.pro (+4/-2) modules/Ubuntu/Components/plugin/ucubuntuanimation.cpp (+94/-0) modules/Ubuntu/Components/plugin/ucubuntuanimation.h (+61/-0) modules/Ubuntu/Components/qmldir (+1/-0) themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml (+1/-1) themes/Ambiance/qmltheme/ButtonDelegate.qml (+1/-1) themes/Ambiance/qmltheme/CheckBoxDelegate.qml (+1/-1) themes/Ambiance/qmltheme/ToolbarDelegate.qml (+1/-1) themes/Ambiance/qmltheme/default.qmltheme (+11/-17) |
To merge this branch: | bzr merge lp:~fboucault/ubuntu-ui-toolkit/standard_animations |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Zsombor Egri | Needs Information | ||
Florian Boucault (community) | Needs Fixing | ||
Review via email: mp+163205@code.launchpad.net |
Commit message
New UbuntuAnimation durations and easing constants.
New UbuntuNumberAni
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:485
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Zsombor Egri (zsombi) wrote : | # |
212 + qmlRegisterSing
Why singleton type? The class functionality mostly consists of defining values, those can be handled with enums/flags, and that doesn't require any instance just a non-creatable type.
- 486. By Florian Boucault
-
Made properties CONSTANT.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:486
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 487. By Florian Boucault
-
Improved documentation.
- 488. By Florian Boucault
-
Use standard animations in toolkit.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:487
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Florian Boucault (fboucault) wrote : | # |
> Not ready for merging. Todo:
> - more representative examples
DONE.
> - improved documentation
DONE.
> - check that Fast is the right/most used default duration
DONE.
> - think again about API (UbuntuNumberAn
NO FURTHER IDEAS.
- 489. By Florian Boucault
-
Improved Animations example.
- 490. By Florian Boucault
-
Better examples.
- 491. By Florian Boucault
-
Better examples.
- 492. By Florian Boucault
-
Switched durations to be int instead of float.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:489
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:492
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === added file 'examples/ubuntu-ui-toolkit-gallery/AnimationCircle.qml' |
2 | --- examples/ubuntu-ui-toolkit-gallery/AnimationCircle.qml 1970-01-01 00:00:00 +0000 |
3 | +++ examples/ubuntu-ui-toolkit-gallery/AnimationCircle.qml 2013-05-14 14:31:25 +0000 |
4 | @@ -0,0 +1,31 @@ |
5 | +/* |
6 | + * Copyright 2013 Canonical Ltd. |
7 | + * |
8 | + * This program is free software; you can redistribute it and/or modify |
9 | + * it under the terms of the GNU Lesser General Public License as published by |
10 | + * the Free Software Foundation; version 3. |
11 | + * |
12 | + * This program is distributed in the hope that it will be useful, |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | + * GNU Lesser General Public License for more details. |
16 | + * |
17 | + * You should have received a copy of the GNU Lesser General Public License |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | + */ |
20 | + |
21 | +import QtQuick 2.0 |
22 | + |
23 | +Rectangle { |
24 | + id: circle |
25 | + |
26 | + color: "#dd4814" |
27 | + width: radius |
28 | + height: radius |
29 | + radius: units.gu(12) |
30 | + antialiasing: true |
31 | + gradient: Gradient { |
32 | + GradientStop { position: 0.0; color: Qt.lighter(circle.color, 1.3) } |
33 | + GradientStop { position: 1.0; color: circle.color } |
34 | + } |
35 | +} |
36 | |
37 | === added file 'examples/ubuntu-ui-toolkit-gallery/Animations.qml' |
38 | --- examples/ubuntu-ui-toolkit-gallery/Animations.qml 1970-01-01 00:00:00 +0000 |
39 | +++ examples/ubuntu-ui-toolkit-gallery/Animations.qml 2013-05-14 14:31:25 +0000 |
40 | @@ -0,0 +1,187 @@ |
41 | +/* |
42 | + * Copyright 2013 Canonical Ltd. |
43 | + * |
44 | + * This program is free software; you can redistribute it and/or modify |
45 | + * it under the terms of the GNU Lesser General Public License as published by |
46 | + * the Free Software Foundation; version 3. |
47 | + * |
48 | + * This program is distributed in the hope that it will be useful, |
49 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
50 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
51 | + * GNU Lesser General Public License for more details. |
52 | + * |
53 | + * You should have received a copy of the GNU Lesser General Public License |
54 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
55 | + */ |
56 | + |
57 | +import QtQuick 2.0 |
58 | +import Ubuntu.Components 0.1 |
59 | + |
60 | +Template { |
61 | + TemplateSection { |
62 | + title: i18n.tr("NumberAnimation") |
63 | + className: "UbuntuNumberAnimation" |
64 | + |
65 | + TemplateRow { |
66 | + title: i18n.tr("Standard") |
67 | + |
68 | + Item { |
69 | + width: units.gu(14) |
70 | + height: units.gu(14) |
71 | + |
72 | + AnimationCircle { |
73 | + radius: units.gu(6) |
74 | + anchors.centerIn: parent |
75 | + |
76 | + SequentialAnimation on radius { |
77 | + loops: Animation.Infinite |
78 | + PauseAnimation { |
79 | + duration: 1000 |
80 | + } |
81 | + UbuntuNumberAnimation { |
82 | + from: units.gu(6) |
83 | + to: units.gu(12) |
84 | + } |
85 | + UbuntuNumberAnimation { |
86 | + from: units.gu(12) |
87 | + to: units.gu(6) |
88 | + } |
89 | + } |
90 | + } |
91 | + } |
92 | + } |
93 | + } |
94 | + |
95 | + TemplateSection { |
96 | + title: i18n.tr("Standard Durations") |
97 | + className: "UbuntuAnimation" |
98 | + |
99 | + TemplateRow { |
100 | + title: i18n.tr("Snap") |
101 | + |
102 | + Repeater { |
103 | + id: repeaterSnap |
104 | + model: 6 |
105 | + AnimationCircle { |
106 | + radius: units.gu(2) |
107 | + |
108 | + SequentialAnimation on color { |
109 | + PauseAnimation { |
110 | + duration: index * UbuntuAnimation.SnapDuration |
111 | + } |
112 | + SequentialAnimation { |
113 | + loops: Animation.Infinite |
114 | + ColorAnimation { |
115 | + from: "#dd4814" |
116 | + to: "#ddcc14" |
117 | + duration: UbuntuAnimation.SnapDuration |
118 | + } |
119 | + PauseAnimation { |
120 | + duration: repeaterSnap.count * UbuntuAnimation.SnapDuration |
121 | + } |
122 | + ColorAnimation { |
123 | + from: "#ddcc14" |
124 | + to: "#dd4814" |
125 | + duration: UbuntuAnimation.SnapDuration |
126 | + } |
127 | + PauseAnimation { |
128 | + duration: repeaterSnap.count * UbuntuAnimation.SnapDuration |
129 | + } |
130 | + } |
131 | + } |
132 | + } |
133 | + } |
134 | + } |
135 | + TemplateRow { |
136 | + title: i18n.tr("Fast") |
137 | + |
138 | + Repeater { |
139 | + id: repeaterFast |
140 | + model: 2 |
141 | + AnimationCircle { |
142 | + radius: units.gu(11) |
143 | + |
144 | + SequentialAnimation on color { |
145 | + PauseAnimation { |
146 | + duration: index * UbuntuAnimation.FastDuration |
147 | + } |
148 | + SequentialAnimation { |
149 | + loops: Animation.Infinite |
150 | + ColorAnimation { |
151 | + from: "#dd4814" |
152 | + to: "#ddcc14" |
153 | + duration: UbuntuAnimation.SnapDuration |
154 | + } |
155 | + PauseAnimation { |
156 | + duration: repeaterFast.count * UbuntuAnimation.FastDuration |
157 | + } |
158 | + ColorAnimation { |
159 | + from: "#ddcc14" |
160 | + to: "#dd4814" |
161 | + duration: UbuntuAnimation.SnapDuration |
162 | + } |
163 | + PauseAnimation { |
164 | + duration: repeaterFast.count * UbuntuAnimation.FastDuration |
165 | + } |
166 | + } |
167 | + } |
168 | + } |
169 | + } |
170 | + } |
171 | + TemplateRow { |
172 | + title: i18n.tr("Slow") |
173 | + |
174 | + AnimationCircle { |
175 | + radius: units.gu(12) |
176 | + |
177 | + SequentialAnimation on x { |
178 | + loops: Animation.Infinite |
179 | + PauseAnimation { |
180 | + duration: 1000 |
181 | + } |
182 | + UbuntuNumberAnimation { |
183 | + from: 0 |
184 | + to: units.gu(12) |
185 | + duration: UbuntuAnimation.SlowDuration |
186 | + } |
187 | + PauseAnimation { |
188 | + duration: 300 |
189 | + } |
190 | + PropertyAction { |
191 | + value: 0 |
192 | + } |
193 | + } |
194 | + } |
195 | + } |
196 | + TemplateRow { |
197 | + title: i18n.tr("Sleepy") |
198 | + |
199 | + Item { |
200 | + width: units.gu(10) |
201 | + height: units.gu(42) |
202 | + |
203 | + AnimationCircle { |
204 | + radius: units.gu(22) |
205 | + |
206 | + SequentialAnimation on y { |
207 | + loops: Animation.Infinite |
208 | + PauseAnimation { |
209 | + duration: 1000 |
210 | + } |
211 | + UbuntuNumberAnimation { |
212 | + from: 0 |
213 | + to: units.gu(20) |
214 | + duration: UbuntuAnimation.SleepyDuration |
215 | + } |
216 | + PauseAnimation { |
217 | + duration: 300 |
218 | + } |
219 | + PropertyAction { |
220 | + value: 0 |
221 | + } |
222 | + } |
223 | + } |
224 | + } |
225 | + } |
226 | + } |
227 | +} |
228 | |
229 | === modified file 'examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml' |
230 | --- examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2013-05-06 08:17:02 +0000 |
231 | +++ examples/ubuntu-ui-toolkit-gallery/WidgetsModel.qml 2013-05-14 14:31:25 +0000 |
232 | @@ -75,4 +75,10 @@ |
233 | label: "Sheet" |
234 | source: "Sheet.qml" |
235 | } |
236 | + |
237 | + // Not in design guidelines yet |
238 | + ListElement { |
239 | + label: "Animations" |
240 | + source: "Animations.qml" |
241 | + } |
242 | } |
243 | |
244 | === modified file 'modules/Ubuntu/Components/Header.qml' |
245 | --- modules/Ubuntu/Components/Header.qml 2013-05-01 21:21:11 +0000 |
246 | +++ modules/Ubuntu/Components/Header.qml 2013-05-14 14:31:25 +0000 |
247 | @@ -41,7 +41,7 @@ |
248 | Behavior on y { |
249 | enabled: !(header.flickable && header.flickable.moving) |
250 | SmoothedAnimation { |
251 | - duration: 200 |
252 | + duration: Theming.UbuntuAnimation.FastDuration |
253 | } |
254 | } |
255 | height: units.gu(10) |
256 | |
257 | === modified file 'modules/Ubuntu/Components/ListItems/Empty.qml' |
258 | --- modules/Ubuntu/Components/ListItems/Empty.qml 2013-04-26 19:23:36 +0000 |
259 | +++ modules/Ubuntu/Components/ListItems/Empty.qml 2013-05-14 14:31:25 +0000 |
260 | @@ -322,8 +322,7 @@ |
261 | Behavior on x { |
262 | enabled: !priv.held |
263 | SequentialAnimation { |
264 | - NumberAnimation { |
265 | - duration: 200 |
266 | + UbuntuNumberAnimation { |
267 | } |
268 | ScriptAction { |
269 | script: { |
270 | @@ -386,11 +385,10 @@ |
271 | id: removeItemAnimation |
272 | |
273 | running: false |
274 | - NumberAnimation { |
275 | + UbuntuNumberAnimation { |
276 | target: emptyListItem |
277 | property: "implicitHeight" |
278 | to: 0 |
279 | - duration: 200 |
280 | } |
281 | ScriptAction { |
282 | script: { |
283 | |
284 | === modified file 'modules/Ubuntu/Components/ListItems/ValueSelector.qml' |
285 | --- modules/Ubuntu/Components/ListItems/ValueSelector.qml 2013-04-26 20:53:31 +0000 |
286 | +++ modules/Ubuntu/Components/ListItems/ValueSelector.qml 2013-05-14 14:31:25 +0000 |
287 | @@ -15,6 +15,7 @@ |
288 | */ |
289 | |
290 | import QtQuick 2.0 |
291 | +import Ubuntu.Components 0.1 |
292 | |
293 | /*! |
294 | \qmltype ValueSelector |
295 | @@ -206,10 +207,10 @@ |
296 | ] |
297 | |
298 | transitions: Transition { |
299 | - PropertyAnimation { |
300 | + UbuntuNumberAnimation { |
301 | target: accordionIcon |
302 | properties: "rotation" |
303 | - duration: 100 |
304 | + duration: UbuntuAnimation.SnapDuration |
305 | } |
306 | } |
307 | } |
308 | @@ -238,10 +239,10 @@ |
309 | ] |
310 | |
311 | transitions: Transition { |
312 | - PropertyAnimation { |
313 | + UbuntuNumberAnimation { |
314 | target: valueRepeater |
315 | properties: "valueHeight" |
316 | - duration: 100 |
317 | + duration: UbuntuAnimation.SnapDuration |
318 | } |
319 | } |
320 | |
321 | |
322 | === modified file 'modules/Ubuntu/Components/OrientationHelper.qml' |
323 | --- modules/Ubuntu/Components/OrientationHelper.qml 2013-04-25 17:19:46 +0000 |
324 | +++ modules/Ubuntu/Components/OrientationHelper.qml 2013-05-14 14:31:25 +0000 |
325 | @@ -125,8 +125,8 @@ |
326 | RotationAnimation { |
327 | target: orientationHelper |
328 | properties: "rotation" |
329 | - duration: 250 |
330 | - easing.type: Easing.OutQuint |
331 | + duration: UbuntuAnimation.FastDuration |
332 | + easing: UbuntuAnimation.StandardEasing |
333 | direction: RotationAnimation.Shortest |
334 | } |
335 | } |
336 | |
337 | === modified file 'modules/Ubuntu/Components/Panel.qml' |
338 | --- modules/Ubuntu/Components/Panel.qml 2013-05-02 19:18:51 +0000 |
339 | +++ modules/Ubuntu/Components/Panel.qml 2013-05-14 14:31:25 +0000 |
340 | @@ -248,29 +248,26 @@ |
341 | transitions: [ |
342 | Transition { |
343 | to: "" |
344 | - PropertyAnimation { |
345 | + UbuntuNumberAnimation { |
346 | target: bar |
347 | properties: "position" |
348 | duration: internal.transitionDuration |
349 | - easing.type: Easing.OutQuad |
350 | } |
351 | }, |
352 | Transition { |
353 | to: "hint" |
354 | - PropertyAnimation { |
355 | + UbuntuNumberAnimation { |
356 | target: bar |
357 | properties: "position" |
358 | duration: internal.transitionDuration |
359 | - easing.type: Easing.OutQuad |
360 | } |
361 | }, |
362 | Transition { |
363 | to: "spread" |
364 | - PropertyAnimation { |
365 | + UbuntuNumberAnimation { |
366 | target: bar |
367 | properties: "position" |
368 | duration: internal.transitionDuration |
369 | - easing.type: Easing.OutQuad |
370 | } |
371 | } |
372 | ] |
373 | @@ -281,9 +278,8 @@ |
374 | /*! |
375 | The duration in milliseconds of sliding in or out transitions when opening, closing, and showing the hint. |
376 | Default value: 250 |
377 | - // FIXME: Update to use ubuntuFastBeat when animation speeds are added to the SDK. |
378 | */ |
379 | - property real transitionDuration: 250 |
380 | + property real transitionDuration: Toolkit.UbuntuAnimation.FastDuration |
381 | |
382 | |
383 | property string previousState: "" |
384 | |
385 | === added file 'modules/Ubuntu/Components/UbuntuNumberAnimation.qml' |
386 | --- modules/Ubuntu/Components/UbuntuNumberAnimation.qml 1970-01-01 00:00:00 +0000 |
387 | +++ modules/Ubuntu/Components/UbuntuNumberAnimation.qml 2013-05-14 14:31:25 +0000 |
388 | @@ -0,0 +1,56 @@ |
389 | +/* |
390 | + * Copyright 2013 Canonical Ltd. |
391 | + * |
392 | + * This program is free software; you can redistribute it and/or modify |
393 | + * it under the terms of the GNU Lesser General Public License as published by |
394 | + * the Free Software Foundation; version 3. |
395 | + * |
396 | + * This program is distributed in the hope that it will be useful, |
397 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
398 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
399 | + * GNU Lesser General Public License for more details. |
400 | + * |
401 | + * You should have received a copy of the GNU Lesser General Public License |
402 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
403 | + * |
404 | + */ |
405 | + |
406 | +import QtQuick 2.0 |
407 | +import Ubuntu.Components 0.1 as Ubuntu |
408 | + |
409 | +/*! |
410 | + \qmltype UbuntuNumberAnimation |
411 | + \inqmlmodule Ubuntu.Components 0.1 |
412 | + \ingroup ubuntu |
413 | + \brief UbuntuNumberAnimation is a NumberAnimation that has predefined |
414 | + settings to ensure that Ubuntu applications are consistent in their animations. |
415 | + |
416 | + Example of use: |
417 | + |
418 | + \qml |
419 | + import QtQuick 2.0 |
420 | + import Ubuntu.Components 0.1 |
421 | + |
422 | + Rectangle { |
423 | + width: 100; height: 100 |
424 | + color: "red" |
425 | + |
426 | + UbuntuNumberAnimation on x { to: 50 } |
427 | + } |
428 | + \endqml |
429 | + |
430 | + UbuntuNumberAnimation is predefined with the following settings: |
431 | + \list |
432 | + \li \e duration: \l{UbuntuAnimation::FastDuration}{UbuntuAnimation.FastDuration} |
433 | + \li \e easing: \l{UbuntuAnimation::StandardEasing}{UbuntuAnimation.StandardEasing} |
434 | + \endlist |
435 | + |
436 | + If the standard duration and easing used by UbuntuNumberAnimation do not |
437 | + satisfy a use case or you need to use a different type of Animation |
438 | + (e.g. ColorAnimation), use standard durations and easing defined in |
439 | + \l UbuntuAnimation manually in order to ensure consistency. |
440 | +*/ |
441 | +NumberAnimation { |
442 | + duration: Ubuntu.UbuntuAnimation.FastDuration |
443 | + easing: Ubuntu.UbuntuAnimation.StandardEasing |
444 | +} |
445 | |
446 | === modified file 'modules/Ubuntu/Components/plugin/plugin.cpp' |
447 | --- modules/Ubuntu/Components/plugin/plugin.cpp 2013-04-25 00:03:08 +0000 |
448 | +++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-05-14 14:31:25 +0000 |
449 | @@ -40,6 +40,7 @@ |
450 | #include "qquickmimedata.h" |
451 | #include "bottombarvisibilitycommunicator.h" |
452 | #include "ucstyle.h" |
453 | +#include "ucubuntuanimation.h" |
454 | |
455 | #include <sys/types.h> |
456 | #include <unistd.h> |
457 | @@ -69,6 +70,7 @@ |
458 | qmlRegisterType<QQuickMimeData>(uri, 0, 1, "MimeData"); |
459 | qmlRegisterSingletonType<QQuickClipboard>(uri, 0, 1, "Clipboard", registerClipboard); |
460 | qmlRegisterType<UCStyle>(uri, 0, 1, "Style"); |
461 | + qmlRegisterSingletonType<UCUbuntuAnimation>(uri, 0, 1, "UbuntuAnimation", registerUCUbuntuAnimation); |
462 | } |
463 | |
464 | void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
465 | |
466 | === modified file 'modules/Ubuntu/Components/plugin/plugin.pro' |
467 | --- modules/Ubuntu/Components/plugin/plugin.pro 2013-03-27 12:01:27 +0000 |
468 | +++ modules/Ubuntu/Components/plugin/plugin.pro 2013-05-14 14:31:25 +0000 |
469 | @@ -43,7 +43,8 @@ |
470 | qquickmimedata.h \ |
471 | qquickclipboard_p.h \ |
472 | selector_p.h \ |
473 | - ucstyle.h |
474 | + ucstyle.h \ |
475 | + ucubuntuanimation.h |
476 | |
477 | SOURCES += plugin.cpp \ |
478 | themeengine.cpp \ |
479 | @@ -64,7 +65,8 @@ |
480 | qquickclipboard.cpp \ |
481 | qquickmimedata.cpp \ |
482 | selector.cpp \ |
483 | - ucstyle.cpp |
484 | + ucstyle.cpp \ |
485 | + ucubuntuanimation.cpp |
486 | |
487 | # deployment rules for the plugin |
488 | installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /) |
489 | |
490 | === added file 'modules/Ubuntu/Components/plugin/ucubuntuanimation.cpp' |
491 | --- modules/Ubuntu/Components/plugin/ucubuntuanimation.cpp 1970-01-01 00:00:00 +0000 |
492 | +++ modules/Ubuntu/Components/plugin/ucubuntuanimation.cpp 2013-05-14 14:31:25 +0000 |
493 | @@ -0,0 +1,94 @@ |
494 | +/* |
495 | + * Copyright 2013 Canonical Ltd. |
496 | + * |
497 | + * This program is free software; you can redistribute it and/or modify |
498 | + * it under the terms of the GNU Lesser General Public License as published by |
499 | + * the Free Software Foundation; version 3. |
500 | + * |
501 | + * This program is distributed in the hope that it will be useful, |
502 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
503 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
504 | + * GNU Lesser General Public License for more details. |
505 | + * |
506 | + * You should have received a copy of the GNU Lesser General Public License |
507 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
508 | + * |
509 | + */ |
510 | + |
511 | +#include "ucubuntuanimation.h" |
512 | + |
513 | +/*! |
514 | + * \qmltype UbuntuAnimation |
515 | + * \instantiates UCUbuntuAnimation |
516 | + * \inqmlmodule Ubuntu.Components 0.1 |
517 | + * \ingroup ubuntu |
518 | + * \brief Singleton defining standard Ubuntu durations and easing for animations |
519 | + * that should be used to ensure that Ubuntu applications are consistent |
520 | + * in their animations. |
521 | + * |
522 | + * Example of use: |
523 | + * |
524 | + * \qml |
525 | + * RotationAnimation { |
526 | + * duration: UbuntuAnimation.SlowDuration |
527 | + * easing: UbuntuAnimation.StandardEasing |
528 | + * } |
529 | + * \endqml |
530 | + * |
531 | + * Animation durations should be selected depending on the frequency and |
532 | + * disruptiveness of the animation. The more frequent an animation is, the |
533 | + * faster it should be. The more disruptive an animation is, the slower it should |
534 | + * be. Rule of thumb to select durations: |
535 | + * \list |
536 | + * \li SnapDuration: very frequent, non-disruptive. |
537 | + * \li FastDuration: frequent, non-disruptive. |
538 | + * \li SlowDuration: less frequent, non-disruptive. |
539 | + * \li SleepyDuration: disruptive. |
540 | + * \endlist |
541 | + * |
542 | + * Note that \l UbuntuNumberAnimation provides a standard NumberAnimation for |
543 | + * Ubuntu applications. |
544 | + * |
545 | + */ |
546 | + |
547 | +UCUbuntuAnimation::UCUbuntuAnimation(QObject *parent) : |
548 | + QObject(parent) |
549 | +{ |
550 | +} |
551 | + |
552 | +/*! |
553 | + * \qmlproperty int UbuntuAnimation::SnapDuration |
554 | + * Used for very frequent and non-disruptive transitions on small objects. |
555 | + * The user would perceive the change as instant but smooth. |
556 | + * |
557 | + * The value is 125ms. |
558 | + */ |
559 | + |
560 | +/*! |
561 | + * \qmlproperty int UbuntuAnimation::FastDuration |
562 | + * Used for frequent and non-disruptive transitions. |
563 | + * |
564 | + * The value is 250ms. |
565 | + */ |
566 | + |
567 | +/*! |
568 | + * \qmlproperty int UbuntuAnimation::SlowDuration |
569 | + * Used for delay after key press and for less frequent and non-disruptive |
570 | + * transitions. |
571 | + * |
572 | + * The value is 500ms. |
573 | + */ |
574 | + |
575 | +/*! |
576 | + * \qmlproperty int UbuntuAnimation::SleepyDuration |
577 | + * Used for disruptive transitions. |
578 | + * |
579 | + * The value is 1000ms. |
580 | + */ |
581 | + |
582 | +/*! |
583 | + * \qmlproperty QEasingCurve UbuntuAnimation::StandardEasing |
584 | + * Used for animations trigerred by user actions. |
585 | + * |
586 | + * The type is Easing.OutQuint. |
587 | + */ |
588 | |
589 | === added file 'modules/Ubuntu/Components/plugin/ucubuntuanimation.h' |
590 | --- modules/Ubuntu/Components/plugin/ucubuntuanimation.h 1970-01-01 00:00:00 +0000 |
591 | +++ modules/Ubuntu/Components/plugin/ucubuntuanimation.h 2013-05-14 14:31:25 +0000 |
592 | @@ -0,0 +1,61 @@ |
593 | +/* |
594 | + * Copyright 2013 Canonical Ltd. |
595 | + * |
596 | + * This program is free software; you can redistribute it and/or modify |
597 | + * it under the terms of the GNU Lesser General Public License as published by |
598 | + * the Free Software Foundation; version 3. |
599 | + * |
600 | + * This program is distributed in the hope that it will be useful, |
601 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
602 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
603 | + * GNU Lesser General Public License for more details. |
604 | + * |
605 | + * You should have received a copy of the GNU Lesser General Public License |
606 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
607 | + * |
608 | + */ |
609 | + |
610 | +#ifndef UCUBUNTUANIMATION_H |
611 | +#define UCUBUNTUANIMATION_H |
612 | + |
613 | +#include <QObject> |
614 | +#include <QtCore/QEasingCurve> |
615 | + |
616 | +class UCUbuntuAnimation : public QObject |
617 | +{ |
618 | + Q_OBJECT |
619 | + Q_PROPERTY(int SnapDuration READ SnapDuration CONSTANT) |
620 | + Q_PROPERTY(int FastDuration READ FastDuration CONSTANT) |
621 | + Q_PROPERTY(int SlowDuration READ SlowDuration CONSTANT) |
622 | + Q_PROPERTY(int SleepyDuration READ SleepyDuration CONSTANT) |
623 | + Q_PROPERTY(QEasingCurve StandardEasing READ StandardEasing CONSTANT) |
624 | + |
625 | +public: |
626 | + explicit UCUbuntuAnimation(QObject *parent = 0); |
627 | + |
628 | + int SnapDuration() const { return 125; } |
629 | + int FastDuration() const { return 250; } |
630 | + int SlowDuration() const { return 500; } |
631 | + int SleepyDuration() const { return 1000; } |
632 | + QEasingCurve StandardEasing() const { |
633 | + static QEasingCurve standardEasing(QEasingCurve::OutQuint); |
634 | + return standardEasing; |
635 | + } |
636 | +}; |
637 | + |
638 | +/* |
639 | + * Registration function used by qmlRegisterSingletonType |
640 | + */ |
641 | +class QQmlEngine; |
642 | +class QJSEngine; |
643 | + |
644 | +static QObject *registerUCUbuntuAnimation(QQmlEngine *engine, QJSEngine *scriptEngine) |
645 | +{ |
646 | + Q_UNUSED(engine) |
647 | + Q_UNUSED(scriptEngine) |
648 | + |
649 | + UCUbuntuAnimation *animation = new UCUbuntuAnimation(); |
650 | + return animation; |
651 | +} |
652 | + |
653 | +#endif // UCUBUNTUANIMATION_H |
654 | |
655 | === modified file 'modules/Ubuntu/Components/qmldir' |
656 | --- modules/Ubuntu/Components/qmldir 2013-04-29 18:36:03 +0000 |
657 | +++ modules/Ubuntu/Components/qmldir 2013-05-14 14:31:25 +0000 |
658 | @@ -38,6 +38,7 @@ |
659 | ComponentUtils 0.1 componentUtils.js |
660 | SliderUtils 0.1 sliderUtils.js |
661 | ScrollbarUtils 0.1 scrollbarUtils.js |
662 | +UbuntuNumberAnimation 0.1 UbuntuNumberAnimation.qml |
663 | |
664 | internal TextCursor TextCursor.qml |
665 | internal TextInputPopover TextInputPopover.qml |
666 | |
667 | === modified file 'themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml' |
668 | --- themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml 2013-03-27 12:24:22 +0000 |
669 | +++ themes/Ambiance/qmltheme/ActivityIndicatorDelegate.qml 2013-05-14 14:31:25 +0000 |
670 | @@ -32,6 +32,6 @@ |
671 | from: 0 |
672 | to: 360 |
673 | loops: Animation.Infinite |
674 | - duration: 1300 |
675 | + duration: UbuntuAnimation.SleepyDuration |
676 | } |
677 | } |
678 | |
679 | === modified file 'themes/Ambiance/qmltheme/ButtonDelegate.qml' |
680 | --- themes/Ambiance/qmltheme/ButtonDelegate.qml 2013-03-27 07:51:04 +0000 |
681 | +++ themes/Ambiance/qmltheme/ButtonDelegate.qml 2013-05-14 14:31:25 +0000 |
682 | @@ -51,7 +51,7 @@ |
683 | color: item.color |
684 | borderSource: visuals.borderPressed |
685 | opacity: item.pressed ? 1.0 : 0.0 |
686 | - Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } } |
687 | + Behavior on opacity { UbuntuNumberAnimation {} } |
688 | } |
689 | |
690 | TransparentButtonDelegate { |
691 | |
692 | === modified file 'themes/Ambiance/qmltheme/CheckBoxDelegate.qml' |
693 | --- themes/Ambiance/qmltheme/CheckBoxDelegate.qml 2013-03-13 12:03:30 +0000 |
694 | +++ themes/Ambiance/qmltheme/CheckBoxDelegate.qml 2013-05-14 14:31:25 +0000 |
695 | @@ -54,7 +54,7 @@ |
696 | source: checkMarkSource |
697 | opacity: item.checked ? 1.0 : 0.0 |
698 | Behavior on opacity { |
699 | - NumberAnimation { duration: 100; easing.type: Easing.OutQuad } |
700 | + UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } |
701 | } |
702 | } |
703 | } |
704 | |
705 | === modified file 'themes/Ambiance/qmltheme/ToolbarDelegate.qml' |
706 | --- themes/Ambiance/qmltheme/ToolbarDelegate.qml 2013-05-01 23:38:10 +0000 |
707 | +++ themes/Ambiance/qmltheme/ToolbarDelegate.qml 2013-05-14 14:31:25 +0000 |
708 | @@ -42,7 +42,7 @@ |
709 | source: Qt.resolvedUrl("artwork/toolbar_dropshadow.png") |
710 | opacity: item.opened || item.animating ? 0.5 : 0.0 |
711 | Behavior on opacity { |
712 | - NumberAnimation { duration: 50; easing.type: Easing.OutQuad } |
713 | + UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration } |
714 | } |
715 | } |
716 | } |
717 | |
718 | === modified file 'themes/Ambiance/qmltheme/default.qmltheme' |
719 | --- themes/Ambiance/qmltheme/default.qmltheme 2013-04-26 16:39:56 +0000 |
720 | +++ themes/Ambiance/qmltheme/default.qmltheme 2013-05-14 14:31:25 +0000 |
721 | @@ -99,7 +99,7 @@ |
722 | checkedColor: "#DD4814"; |
723 | uncheckedColor: Qt.rgba(0.0, 0.0, 0.0, 0.1); |
724 | checkMarkSource: url("artwork/CheckMark.png"); |
725 | - backgroundColorAnimation: ColorAnimation { duration: 100; easing.type: Easing.OutQuad }; |
726 | + backgroundColorAnimation: ColorAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing }; |
727 | } |
728 | |
729 | .switch { |
730 | @@ -110,8 +110,8 @@ |
731 | thumbSpacing: units.dp(2); |
732 | checkedThumbColor: "#DD4814"; |
733 | uncheckedThumbColor: "#bbbbbb"; |
734 | - thumbColorAnimation: ColorAnimation { duration: 100; easing.type: Easing.OutQuad }; |
735 | - moveThumbAnimation: NumberAnimation { duration: 100; easing.type: Easing.OutQuad }; |
736 | + thumbColorAnimation: ColorAnimation { duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing }; |
737 | + moveThumbAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }; |
738 | backgroundColor: Qt.rgba(0.78, 0.78, 0.78, 0.1); |
739 | } |
740 | |
741 | @@ -186,7 +186,7 @@ |
742 | .popover { |
743 | edgeMargins: units.gu(2); |
744 | callerMargin: units.gu(1); |
745 | - fadingAnimation: PropertyAnimation{duration: 125; easing.type: Easing.OutQuint}; |
746 | + fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }; |
747 | } |
748 | |
749 | .popover .foreground { |
750 | @@ -200,7 +200,7 @@ |
751 | } |
752 | |
753 | .sheet { |
754 | - fadingAnimation: PropertyAnimation{duration: 125; easing.type: Easing.OutQuint}; |
755 | + fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }; |
756 | } |
757 | .sheet .foreground { |
758 | headerColor: "darkgray"; |
759 | @@ -212,7 +212,7 @@ |
760 | .dialog { |
761 | edgeMargins: units.gu(2); |
762 | callerMargin: units.gu(1); |
763 | - fadingAnimation: PropertyAnimation{duration: 125; easing.type: Easing.OutQuint}; |
764 | + fadingAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }; |
765 | } |
766 | .dialog .background { |
767 | dim: true; |
768 | @@ -269,19 +269,13 @@ |
769 | overlayOpacityWhenShown: 0.6; |
770 | overlayOpacityWhenHidden: 0.0; |
771 | |
772 | - scrollbarFadeInAnimation: NumberAnimation { |
773 | - duration: 100; |
774 | - easing.type: Easing.InOutQuad; |
775 | - }; |
776 | + scrollbarFadeInAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }; |
777 | scrollbarFadeOutPause: 300; |
778 | - scrollbarFadeOutAnimation: NumberAnimation { |
779 | - duration: 500; |
780 | - easing.type: Easing.InOutQuad; |
781 | - }; |
782 | + scrollbarFadeOutAnimation: UbuntuNumberAnimation { duration: UbuntuAnimation.SlowDuration }; |
783 | |
784 | - sliderAnimation: NumberAnimation {duration: 200; easing.type: Easing.InOutQuad}; |
785 | - thumbConnectorFading: NumberAnimation {duration: 100; easing.type: Easing.InOutQuad}; |
786 | - thumbFading: NumberAnimation {duration: 100; easing.type: Easing.InOutQuad}; |
787 | + sliderAnimation: UbuntuNumberAnimation {}; |
788 | + thumbConnectorFading: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }; |
789 | + thumbFading: UbuntuNumberAnimation { duration: UbuntuAnimation.SnapDuration }; |
790 | backwardThumbReleased : (item.align === Qt.AlignLeading || item.align === Qt.AlignTrailing) ? url("artwork/ScrollbarTopIdle.png") : url("artwork/ScrollbarLeftIdle.png"); |
791 | backwardThumbPressed: (item.align === Qt.AlignLeading || item.align === Qt.AlignTrailing) ? url("artwork/ScrollbarTopPressed.png") : url("artwork/ScrollbarLeftPressed.png"); |
792 | forwardThumbReleased: (item.align === Qt.AlignLeading || item.align === Qt.AlignTrailing) ? url("artwork/ScrollbarBottomIdle.png") : url("artwork/ScrollbarRightIdle.png"); |
Not ready for merging. Todo: imation vs. UbuntuAnimation)
- more representative examples
- improved documentation
- check that Fast is the right/most used default duration
- think again about API (UbuntuNumberAn