00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 import QtQuick 1.0
00041 import com.nokia.symbian 1.0
00042
00043
00044 ApplicationWindow {
00045 id: mainWindow
00046
00047 ToolBarLayout {
00048 id: commonTools
00049 ToolButton {
00050 flat: true
00051 iconSource: "toolbar_back.svg"
00052 onClicked: Qt.quit()
00053 }
00054 ToolButton {
00055 flat: true
00056 iconSource: "toolbar_options.svg"
00057 onClicked: pageMenu.open()
00058 }
00059 }
00060
00061 Page{
00062 id: page
00063 tools: commonTools
00064
00065 property string animationDetails: ""
00066
00067
00068 PageHeading{
00069 id: heading
00070 anchors.top: parent.top
00071 width: parent.width
00072 text: qsTr("Animations Example")
00073 }
00074
00075 Button{
00076 id: button1
00077 x: 0; y: 50
00078 width: 100
00079 height: 50
00080 text: "button1"
00081
00082
00083 SequentialAnimation{
00084 id: animation
00085 PropertyAnimation { target: button1; property: "width"; to: 30; duration: 500 }
00086 PropertyAnimation { target: button1; property: "width"; to: 100; duration: 500 }
00087 }
00088
00089
00090 onClicked: animation.running = true
00091 }
00092
00093 Button{
00094 id: button2
00095 x: 0
00096 y: 120
00097 width: 150
00098 height: 50
00099 text: "button2"
00100 SequentialAnimation on x {
00101 loops: Animation.Infinite
00102 PropertyAnimation { to: 200; easing.type: Easing.InOutQuad }
00103 PropertyAnimation { to: 0; duration: 500; easing.type: Easing.InQuad }
00104 }
00105 }
00106
00107 Button{
00108 id: button3
00109 x: 0
00110 y: 190
00111 width: 150
00112 height: 50
00113 text: "button3"
00114 SequentialAnimation{
00115 id: animation2
00116 ParallelAnimation{
00117 PropertyAnimation { target: button3; property: "width"; to: 30; duration: 500 }
00118 PropertyAnimation { target: button3; property: "x"; to: 200; duration: 500 }
00119 }
00120 PropertyAnimation { target: button3; property: "x"; to: 0; duration: 500 }
00121 PropertyAnimation { target: button3; property: "width"; to: 150; duration: 500 }
00122
00123 }
00124 onClicked: animation2.running = true;
00125
00126 }
00127
00128 TextArea{
00129 id: displayInfo
00130 anchors.bottom: parent.bottom
00131 readOnly: true
00132 width: parent.width
00133 height: 100
00134 text: "Click buttons to see how they animate.\nUse Menu options to apply transitions" +
00135 parent.animationDetails
00136 }
00137
00138 Menu{
00139 id: pageMenu
00140
00141
00142 content: Column{
00143 width: pageMenu.width
00144 MenuItem{
00145 id: menu1
00146 text: qsTr("Apply State1")
00147 onClicked:{
00148 page.state = "state1"
00149 pageMenu.close();
00150 }
00151 }
00152
00153 MenuItem{
00154 id: menu2
00155 text: qsTr("Apply State2")
00156 onClicked:{
00157 page.state = "state2"
00158 pageMenu.close();
00159 }
00160 }
00161
00162 MenuItem{
00163 id: menu3
00164 text: qsTr("Apply State3")
00165 onClicked:{
00166 page.state = "state3"
00167 pageMenu.close();
00168 }
00169 }
00170
00171 }
00172 }
00173
00174 states: [
00175
00176 State{
00177 name: "state1"
00178 },
00179
00180 State{
00181 name: "state2"
00182 },
00183
00184
00185 State{
00186 name: "state3"
00187 }
00188
00189
00190 ]
00191
00192 transitions:[
00193
00194 Transition{
00195 to: "state1"
00196 SequentialAnimation{
00197 NumberAnimation { target: button1; property: "x"; to: 30 }
00198 NumberAnimation { target: button1; property: "x"; to: 0 }
00199 }
00200
00201 },
00202
00203 Transition{
00204 to: "state2"
00205 from: "state1"
00206 SequentialAnimation{
00207 ParallelAnimation{
00208 PropertyAnimation { target: button1; property: "x"; to: 30 }
00209 PropertyAnimation { target: button3; property: "x"; to: 30 }
00210 }
00211 ParallelAnimation{
00212 PropertyAnimation { target: button1; property: "x"; to: 0 }
00213 PropertyAnimation { target: button3; property: "x"; to: 0 }
00214 }
00215 }
00216
00217
00218 },
00219
00220 Transition{
00221 SequentialAnimation{
00222 ParallelAnimation{
00223 PropertyAnimation { target: button1; property: "x"; to: 80 }
00224 PropertyAnimation { target: button3; property: "x"; to: 80 }
00225 }
00226 ParallelAnimation{
00227 PropertyAnimation { target: button1; property: "x"; to: 0 }
00228 PropertyAnimation { target: button3; property: "x"; to: 0 }
00229 }
00230 }
00231
00232 }
00233
00234 ]
00235
00236 }
00237
00238 Component.onCompleted: {
00239 pageStack.push(page)
00240 }
00241
00242 }
00243
00244
00245