4c8e892f33b3689ae0c4a0544edb82b9805fa843
[profile/ivi/qtdeclarative.git] / examples / declarative / qtquick1 / animation / easing / easing.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
6 **
7 ** This file is part of the examples of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:BSD$
10 ** You may use this file under the terms of the BSD license as follows:
11 **
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
14 ** met:
15 **   * Redistributions of source code must retain the above copyright
16 **     notice, this list of conditions and the following disclaimer.
17 **   * Redistributions in binary form must reproduce the above copyright
18 **     notice, this list of conditions and the following disclaimer in
19 **     the documentation and/or other materials provided with the
20 **     distribution.
21 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 **     the names of its contributors may be used to endorse or promote
23 **     products derived from this software without specific prior written
24 **     permission.
25 **
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 import QtQuick 1.0
42 import "content"
43
44 Rectangle {
45     id: window
46     width: 600; height: 460; color: "#232323"
47
48     ListModel {
49         id: easingTypes
50         ListElement { name: "Easing.Linear"; type: Easing.Linear; ballColor: "DarkRed" }
51         ListElement { name: "Easing.InQuad"; type: Easing.InQuad; ballColor: "IndianRed" }
52         ListElement { name: "Easing.OutQuad"; type: Easing.OutQuad; ballColor: "Salmon" }
53         ListElement { name: "Easing.InOutQuad"; type: Easing.InOutQuad; ballColor: "Tomato" }
54         ListElement { name: "Easing.OutInQuad"; type: Easing.OutInQuad; ballColor: "DarkOrange" }
55         ListElement { name: "Easing.InCubic"; type: Easing.InCubic; ballColor: "Gold" }
56         ListElement { name: "Easing.OutCubic"; type: Easing.OutCubic; ballColor: "Yellow" }
57         ListElement { name: "Easing.InOutCubic"; type: Easing.InOutCubic; ballColor: "PeachPuff" }
58         ListElement { name: "Easing.OutInCubic"; type: Easing.OutInCubic; ballColor: "Thistle" }
59         ListElement { name: "Easing.InQuart"; type: Easing.InQuart; ballColor: "Orchid" }
60         ListElement { name: "Easing.OutQuart"; type: Easing.OutQuart; ballColor: "Purple" }
61         ListElement { name: "Easing.InOutQuart"; type: Easing.InOutQuart; ballColor: "SlateBlue" }
62         ListElement { name: "Easing.OutInQuart"; type: Easing.OutInQuart; ballColor: "Chartreuse" }
63         ListElement { name: "Easing.InQuint"; type: Easing.InQuint; ballColor: "LimeGreen" }
64         ListElement { name: "Easing.OutQuint"; type: Easing.OutQuint; ballColor: "SeaGreen" }
65         ListElement { name: "Easing.InOutQuint"; type: Easing.InOutQuint; ballColor: "DarkGreen" }
66         ListElement { name: "Easing.OutInQuint"; type: Easing.OutInQuint; ballColor: "Olive" }
67         ListElement { name: "Easing.InSine"; type: Easing.InSine; ballColor: "DarkSeaGreen" }
68         ListElement { name: "Easing.OutSine"; type: Easing.OutSine; ballColor: "Teal" }
69         ListElement { name: "Easing.InOutSine"; type: Easing.InOutSine; ballColor: "Turquoise" }
70         ListElement { name: "Easing.OutInSine"; type: Easing.OutInSine; ballColor: "SteelBlue" }
71         ListElement { name: "Easing.InExpo"; type: Easing.InExpo; ballColor: "SkyBlue" }
72         ListElement { name: "Easing.OutExpo"; type: Easing.OutExpo; ballColor: "RoyalBlue" }
73         ListElement { name: "Easing.InOutExpo"; type: Easing.InOutExpo; ballColor: "MediumBlue" }
74         ListElement { name: "Easing.OutInExpo"; type: Easing.OutInExpo; ballColor: "MidnightBlue" }
75         ListElement { name: "Easing.InCirc"; type: Easing.InCirc; ballColor: "CornSilk" }
76         ListElement { name: "Easing.OutCirc"; type: Easing.OutCirc; ballColor: "Bisque" }
77         ListElement { name: "Easing.InOutCirc"; type: Easing.InOutCirc; ballColor: "RosyBrown" }
78         ListElement { name: "Easing.OutInCirc"; type: Easing.OutInCirc; ballColor: "SandyBrown" }
79         ListElement { name: "Easing.InElastic"; type: Easing.InElastic; ballColor: "DarkGoldenRod" }
80         ListElement { name: "Easing.OutElastic"; type: Easing.OutElastic; ballColor: "Chocolate" }
81         ListElement { name: "Easing.InOutElastic"; type: Easing.InOutElastic; ballColor: "SaddleBrown" }
82         ListElement { name: "Easing.OutInElastic"; type: Easing.OutInElastic; ballColor: "Brown" }
83         ListElement { name: "Easing.InBack"; type: Easing.InBack; ballColor: "Maroon" }
84         ListElement { name: "Easing.OutBack"; type: Easing.OutBack; ballColor: "LavenderBlush" }
85         ListElement { name: "Easing.InOutBack"; type: Easing.InOutBack; ballColor: "MistyRose" }
86         ListElement { name: "Easing.OutInBack"; type: Easing.OutInBack; ballColor: "Gainsboro" }
87         ListElement { name: "Easing.OutBounce"; type: Easing.OutBounce; ballColor: "Silver" }
88         ListElement { name: "Easing.InBounce"; type: Easing.InBounce; ballColor: "DimGray" }
89         ListElement { name: "Easing.InOutBounce"; type: Easing.InOutBounce; ballColor: "SlateGray" }
90         ListElement { name: "Easing.OutInBounce"; type: Easing.OutInBounce; ballColor: "DarkSlateGray" }
91     }
92
93     Component {
94         id: delegate
95
96         Item {
97             height: 56; width: window.width
98
99             Text { text: name; anchors.centerIn: parent; color: "White" }
100
101             Rectangle {
102                 id: slot1; color: "#121212"; x: 30; height: 46; width: 46
103                 border.color: "#343434"; border.width: 1; radius: 12
104                 anchors.verticalCenter: parent.verticalCenter
105             }
106
107             Rectangle {
108                 id: slot2; color: "#121212"; x: window.width - 76; height: 46; width: 46
109                 border.color: "#343434"; border.width: 1; radius: 12
110                 anchors.verticalCenter: parent.verticalCenter
111             }
112
113             Rectangle {
114                 id: rect; x: 30; color: "#454545"
115                 border.color: "White"; border.width: 2
116                 height: 46; width: 46; radius: 12
117                 anchors.verticalCenter: parent.verticalCenter
118
119                 MouseArea {
120                     onClicked: if (rect.state == '') rect.state = "right"; else rect.state = ''
121                     anchors.fill: parent
122                     anchors.margins: -5 // Make MouseArea bigger than the rectangle, itself
123                 }
124
125                 states : State {
126                     name: "right"
127                     PropertyChanges { target: rect; x: window.width - 76; color: ballColor }
128                 }
129
130                 transitions: Transition {
131                     NumberAnimation { properties: "x"; easing.type: type; duration: 1000 }
132                     ColorAnimation { properties: "color"; easing.type: type; duration: 1000 }
133                 }
134             }
135         }
136     }
137
138     Flickable {
139         anchors.fill: parent
140         contentHeight: layout.height+50
141         Rectangle {
142             id: titlePane
143             color: "#444444"
144             height: 35
145             anchors { top: parent.top; left: parent.left; right: parent.right }
146             QuitButton {
147                 id: quitButton
148                 anchors.verticalCenter: parent.verticalCenter
149                 anchors.right: parent.right
150                 anchors.rightMargin: 10
151             }
152         }
153         Column {
154             id: layout
155             anchors { top: titlePane.bottom; topMargin: 10; left: parent.left; right: parent.right }
156             Repeater { model: easingTypes; delegate: delegate }
157         }
158     }
159 }