on 859dfd9 help sign in
unity8/Components/AnimationControllerWithSignals.qml
64 lines 1.7 kB history raw
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 */
17import QtQuick 2.0
19AnimationController {
20 signal animationCompletedAtBeginning()
21 signal animationCompletedAtEnd()
22 readonly property bool completed: progress == 1.0 || progress == 0.0
23 property bool completing: false
25 function __completeAtBeginning() {
26 completing = false;
27 animationCompletedAtBeginning();
28 }
30 function __completeAtEnd() {
31 completing = false;
32 animationCompletedAtEnd();
33 }
35 function completeToBeginningWithSignal() {
36 if (progress == 0.0) {
37 __completeAtBeginning()
38 } else {
39 completing = true;
40 completeToBeginning();
41 }
42 }
44 function completeToEndWithSignal() {
45 if (progress == 1.0) {
46 __completeAtEnd()
47 } else {
48 completing = true;
49 completeToEnd();
50 }
51 }
53 onProgressChanged: {
54 if (!completing) {
55 return;
56 }
58 if (progress == 0.0) {
59 __completeAtBeginning()
60 } else if (progress == 1.0) {
61 __completeAtEnd()
62 }
63 }