/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the documentation of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage ** This file contains pre-release code and may not be distributed. ** You may use this file in accordance with the terms and conditions ** contained in the either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. ** $QT_END_LICENSE$ ** ****************************************************************************/ /*! \page qmlanimation.html \target qmlanimation \title QML Animation QML supports three different forms of animation - basic property animation, states and transitions and property behaviors. \section1 Property Animation Animation in QML is done by animating properties of objects. Any property of a recognizable type can be animated. Currently those types include: \list \o qreal \o int \o Most of QVariant's built-in types \endlist Animations can also involve numerous properties on numerous objects. Other Features: \list \o Support for a large set of parameterized easing curves. (based on the Penner easing equations) \o Animation synchronization \endlist The simplest form of animation is using \l NumberAnimation The following example creates a bouncing effect: \code Rectangle { id: rect width: 120; height: 200; color: "white" Image { id: img source: "qt-logo.png" x: 60-img.width/2 y: 0 y: SequentialAnimation { running: true repeat: true NumberAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 } PauseAnimation { duration: 1000 } NumberAnimation { to: 0; easing: "easeOutQuad"; duration: 1000 } } } } \endcode \image propanim.gif \target states-transitions \section1 States and Transitions \section2 States QML states describe user interface configurations, including: \list \o What UI elements are present \o The properties of those elements (including how they behave) \o What actions are available \endlist A state can also be thought of as a set of batched changes from a default configuration. Examples of states in modern UI: \list \o A Contacts application has a 'View Contact' state and an 'Edit Contact' State. In the first state the information presented is static (using labels), and in the second it is editable (using editors). \o A button has a pressed and unpressed state. When pressed the text moves down and to the right, and the button has a slightly darker appearance. \endlist In QML: \list \o Any object can use states. \o There is a default state. The default state can be explicitly set. \o A state can affect other the properties of other objects, not just the object owning the state (and not just that object's children). \endlist The following example shows a simple use of states. In the default state \c myrect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. \code Item { Rectangle { id: myrect width: 100 height: 100 } states: [ State { name: "moved" PropertyChanges { target: myrect x: 50 y: 50 } } ] } \endcode \section2 Transitions QML transitions describe animations to perform when state changes occur. For the previous example, a transition could describe how \c myrect moved from its initial position to its new position: \code transitions: [ Transition { NumberAnimation { properties: "x,y" easing: "easeOutBounce" duration: 200 } } ] \endcode QML transitions can use selectors to determine which state changes a transition should apply to: \code Transition { from: "*" to: "details" ... } \endcode Transitions can happen in parallel, in sequence, or in any combination of the two: \code Transition { from: "*" to: "MyState" reversible: true SequentialAnimation { ColorAnimation { property: "color" duration: 1000 } PauseAnimation { duration: 1000 } ParallelAnimation { NumberAnimation { duration: 1000 easing: "easeOutBounce" target: box1 properties: "x,y" } NumberAnimation { duration: 1000 target: box2 properties: "x,y" } } } } \endcode \section1 Property Behaviors \note Property behaviors are currently experimental. */