Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qmlvisual / animation / reanchorRTL / reanchor.qml
1 import QtQuick 1.1
2
3 Rectangle {
4     id: container
5     width: 200; height: 200
6     Rectangle {
7         id: myRect
8         anchors.layoutDirection: Qt.RightToLeft
9         objectName: "MyRect"
10         color: "green";
11         anchors.left: parent.left
12         anchors.right: rightGuideline.left
13         anchors.top: topGuideline.top
14         anchors.bottom: container.bottom
15     }
16     Item { id: leftGuideline; x: 10 }
17     Item { id: rightGuideline; x: 150 }
18     Item { id: topGuideline; y: 10 }
19     Item { id: bottomGuideline; y: 150 }
20     Item { id: topGuideline2; y: 50 }
21     Item { id: bottomGuideline2; y: 175 }
22     MouseArea {
23         id: wholeArea
24         anchors.fill: parent
25         onClicked: {
26             if (container.state == "") {
27                 container.state = "reanchored";
28             } else if (container.state == "reanchored") {
29                 container.state = "reanchored2";
30             } else if (container.state == "reanchored2")
31                 container.state = "reanchored";
32         }
33     }
34
35     states: [ State {
36         name: "reanchored"
37         AnchorChanges {
38             target: myRect;
39             anchors.left: leftGuideline.left
40             anchors.right: container.right
41             anchors.top: container.top
42             anchors.bottom: bottomGuideline.bottom
43         }
44     }, State {
45         name: "reanchored2"
46         AnchorChanges {
47             target: myRect;
48             anchors.left: undefined
49             anchors.right: undefined
50             anchors.top: topGuideline2.top
51             anchors.bottom: bottomGuideline2.bottom
52         }
53     }]
54
55     transitions: Transition {
56         AnchorAnimation { }
57     }
58
59     MouseArea {
60         width: 50; height: 50
61         anchors.right: parent.right
62         anchors.bottom: parent.bottom
63         onClicked: {
64             container.state = "";
65         }
66     }
67
68     state: "reanchored"
69 }