Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qmlvisual / animation / parentAnimation2 / parentAnimation2.qml
1 import QtQuick 1.0
2
3 /*
4 Blue rect fills (with 10px margin) screen, then red, then green, then screen again.
5 */
6
7 Rectangle {
8     id: whiteRect
9     width: 640; height: 480;
10
11     Rectangle {
12         id: redRect
13         x: 400; y: 50
14         width: 100; height: 100
15         color: "red"
16     }
17
18     Rectangle {
19         id: greenRect
20         x: 100; y: 150
21         width: 200; height: 300
22         color: "green"
23     }
24
25     Rectangle {
26         id: blueRect
27         x: 5; y: 5
28         width: parent.width-10
29         height: parent.height-10
30         color: "lightblue"
31
32         //Text { text: "Click me!"; anchors.centerIn: parent }
33
34         MouseArea {
35             anchors.fill: parent
36             onClicked: {
37             switch(blueRect.state) {
38                 case "": blueRect.state = "inRed"; break;
39                 case "inRed": blueRect.state = "inGreen"; break;
40                 case "inGreen": blueRect.state = ""; break;
41                 }
42             }
43         }
44
45         states: [
46             State {
47                 name: "inRed"
48                 ParentChange { target: blueRect; parent: redRect; x: 5; y: 5; width: parent.width-10; height: parent.height-10 }
49                 PropertyChanges { target: redRect; z: 1 }
50             },
51             State {
52                 name: "inGreen"
53                 ParentChange { target: blueRect; parent: greenRect; x: 5; y: 5; width: parent.width-10; height: parent.height-10 }
54                 PropertyChanges { target: greenRect; z: 1 }
55             }
56         ]
57
58         transitions: Transition {
59             ParentAnimation { target: blueRect; //via: whiteRect;
60                 NumberAnimation { properties: "x, y, width, height"; duration: 500 }
61             }
62         }
63     }
64 }