examples/QtQuick/qmlanimationex/qml/qmlanimationex/main.qml

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation
00006 **
00007 **
00008 ** $QT_BEGIN_LICENSE:BSD$
00009 ** You may use this file under the terms of the BSD license as follows:
00010 **
00011 ** "Redistribution and use in source and binary forms, with or without
00012 ** modification, are permitted provided that the following conditions are
00013 ** met:
00014 **   * Redistributions of source code must retain the above copyright
00015 **     notice, this list of conditions and the following disclaimer.
00016 **   * Redistributions in binary form must reproduce the above copyright
00017 **     notice, this list of conditions and the following disclaimer in
00018 **     the documentation and/or other materials provided with the
00019 **     distribution.
00020 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00021 **     the names of its contributors may be used to endorse or promote
00022 **     products derived from this software without specific prior written
00023 **     permission.
00024 **
00025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00036 ** $QT_END_LICENSE$
00037 **
00038 ****************************************************************************/
00039 
00040 import QtQuick 1.0
00041 import com.nokia.symbian 1.0
00042 
00043 // Main window of the example.
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         // Page heading
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             // this is a standalone animation, it's not running by default
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 

Generated by  doxygen 1.6.2