summaryrefslogtreecommitdiffstats
path: root/animators/test/TestTransitionSequentialAnimation.qml
blob: 2dbc4c0614e06403ecd9545fd809e3a7a59e5ec3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import QtQuick 2.0
import Animators 1.0 as Rt

Rectangle {
    id: root
    width: 320
    height: 480
    color: "black"
    property var out33in60: [ 0.33, 0.0, 0.40, 1.0, 1.0, 1.0 ]
    property var out60in33: [ 0.60, 0.0, 0.67, 1.0, 1.0, 1.0 ]

    Timer {
        repeat: false
        interval: 1000
        running: true
        onTriggered: {
            console.log("onTriggered: changing test state.")
            renderThreadItem.state = "moved"
            mainThreadItem.state = "moved"
        }
    }

    Rt.Item {
        id: renderThreadItem
        width: parent.width
        height: parent.height / 2
        visible: !renderThreadAnimationsDisabled

        Text {
            anchors.centerIn: parent
            text: "Render thread animation"
            smooth: true
            color: "white"
            font.pixelSize: 20
        }

        states: State {
              name: "moved"
              PropertyChanges { target: renderThreadItem; rotation: 360 }
        }

        transitions: Transition {
            Rt.SequentialAnimation {
                Rt.NumberAnimation {
                    target: renderThreadItem
                    property: "rotation"
                    easing.type: Easing.Bezier
                    easing.bezierCurve: out60in33
                    duration: 6000
                    to: 360
                    from: 0
                }
                Rt.NumberAnimation {
                    target: renderThreadItem
                    property: "scale"
                    from: 1.0
                    to: 0.3
                    easing.type: Easing.Bezier
                    easing.bezierCurve: out60in33
                    duration: 6000
                }
            }
        }
    }

    Item {
        id: mainThreadItem
        y: parent.height / 2
        width: parent.width
        height: parent.height / 2
        visible: !mainThreadAnimationsDisabled

        Text {
            anchors.centerIn: parent
            text: "Main thread animation"
            smooth: true
            color: "white"
            font.pixelSize: 20
        }

        states: State {
              name: "moved"
              PropertyChanges { target: mainThreadItem; rotation: 360 }
        }

        transitions: Transition {
            SequentialAnimation {
                NumberAnimation {
                    target: mainThreadItem
                    property: "rotation"
                    easing.type: Easing.Bezier
                    easing.bezierCurve: out60in33
                    duration: 6000
                }
                NumberAnimation {
                    target: mainThreadItem
                    property: "scale"
                    to: 0.3
                    easing.type: Easing.Bezier
                    easing.bezierCurve: out60in33
                    duration: 6000
                }
            }
        }
    }

    Control {
        id: control
        anchors.bottom: parent.bottom
        running: true
    }
}