Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / tests / benchmarks / declarative / holistic / data / largeTargets / layoutdirection.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the examples of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 **   * Redistributions of source code must retain the above copyright
15 **     notice, this list of conditions and the following disclaimer.
16 **   * Redistributions in binary form must reproduce the above copyright
17 **     notice, this list of conditions and the following disclaimer in
18 **     the documentation and/or other materials provided with the
19 **     distribution.
20 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 **     the names of its contributors may be used to endorse or promote
22 **     products derived from this software without specific prior written
23 **     permission.
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 import QtQuick 1.1
42
43 Rectangle {
44
45     width: column.width + 100
46     height: column.height + 100
47     property int direction: Qt.application.layoutDirection
48
49     Column {
50         id: column
51         spacing: 10
52         anchors.centerIn: parent
53         width: 230
54
55         Text {
56             text: "Row"
57             anchors.horizontalCenter: parent.horizontalCenter
58         }
59         Row {
60             layoutDirection: direction
61             spacing: 10
62             move: Transition {
63                 NumberAnimation {
64                     properties: "x"
65                 }
66             }
67             Repeater {
68                 model: 4
69                 Loader {
70                     property int value: index
71                     sourceComponent: delegate
72                 }
73             }
74         }
75         Text {
76             text: "Grid"
77             anchors.horizontalCenter: parent.horizontalCenter
78         }
79         Grid {
80            layoutDirection: direction
81            spacing: 10; columns: 4
82            move: Transition {
83                NumberAnimation {
84                    properties: "x"
85                }
86            }
87            Repeater {
88                model: 11
89                Loader {
90                    property int value: index
91                    sourceComponent: delegate
92                }
93             }
94         }
95         Text {
96             text: "Flow"
97             anchors.horizontalCenter: parent.horizontalCenter
98         }
99         Flow {
100            layoutDirection: direction
101            spacing: 10; width: parent.width
102            move: Transition {
103                NumberAnimation {
104                    properties: "x"
105                }
106            }
107            Repeater {
108                model: 10
109                Loader {
110                    property int value: index
111                    sourceComponent: delegate
112                }
113             }
114         }
115         Rectangle {
116            height: 50; width: parent.width
117            color: mouseArea.pressed ? "black" : "gray"
118            Text {
119                 text: direction ? "Right to left" : "Left to right"
120                 color: "white"
121                 font.pixelSize: 16
122                 anchors.centerIn: parent
123             }
124             MouseArea {
125                 id: mouseArea
126                 onClicked: {
127                     if (direction == Qt.LeftToRight) {
128                         direction = Qt.RightToLeft;
129                     } else {
130                         direction = Qt.LeftToRight;
131                     }
132                 }
133                 anchors.fill: parent
134             }
135         }
136     }
137
138     Component {
139         id: delegate
140         Rectangle {
141             width: 50; height: 50
142             color: Qt.rgba(0.8/(parent.value+1),0.8/(parent.value+1),0.8/(parent.value+1),1.0)
143             Text {
144                 text: parent.parent.value+1
145                 color: "white"
146                 font.pixelSize: 20
147                 anchors.centerIn: parent
148             }
149         }
150     }
151 }