72 |
72 |
73 QT_BEGIN_NAMESPACE |
73 QT_BEGIN_NAMESPACE |
74 |
74 |
75 /*! |
75 /*! |
76 \qmlclass Animation QDeclarativeAbstractAnimation |
76 \qmlclass Animation QDeclarativeAbstractAnimation |
|
77 \ingroup qml-animation-transition |
77 \since 4.7 |
78 \since 4.7 |
78 \brief The Animation element is the base of all QML animations. |
79 \brief The Animation element is the base of all QML animations. |
79 |
80 |
80 The Animation element cannot be used directly in a QML file. It exists |
81 The Animation element cannot be used directly in a QML file. It exists |
81 to provide a set of common properties and methods, available across all the |
82 to provide a set of common properties and methods, available across all the |
82 other animation types that inherit from it. Attempting to use the Animation |
83 other animation types that inherit from it. Attempting to use the Animation |
83 element directly will result in an error. |
84 element directly will result in an error. |
84 */ |
|
85 |
|
86 /*! |
|
87 \class QDeclarativeAbstractAnimation |
|
88 \internal |
|
89 */ |
85 */ |
90 |
86 |
91 QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QObject *parent) |
87 QDeclarativeAbstractAnimation::QDeclarativeAbstractAnimation(QObject *parent) |
92 : QObject(*(new QDeclarativeAbstractAnimationPrivate), parent) |
88 : QObject(*(new QDeclarativeAbstractAnimationPrivate), parent) |
93 { |
89 { |
334 |
330 |
335 If set to Animation.Infinite, the animation will continuously repeat until it is explicitly |
331 If set to Animation.Infinite, the animation will continuously repeat until it is explicitly |
336 stopped - either by setting the \c running property to false, or by calling |
332 stopped - either by setting the \c running property to false, or by calling |
337 the \c stop() method. |
333 the \c stop() method. |
338 |
334 |
339 In the following example, the rectangle will spin indefinately. |
335 In the following example, the rectangle will spin indefinitely. |
340 |
336 |
341 \code |
337 \code |
342 Rectangle { |
338 Rectangle { |
343 width: 100; height: 100; color: "green" |
339 width: 100; height: 100; color: "green" |
344 RotationAnimation on rotation { |
340 RotationAnimation on rotation { |
643 |
635 |
644 \snippet doc/src/snippets/declarative/coloranimation.qml 0 |
636 \snippet doc/src/snippets/declarative/coloranimation.qml 0 |
645 |
637 |
646 Like any other animation element, a ColorAnimation can be applied in a |
638 Like any other animation element, a ColorAnimation can be applied in a |
647 number of ways, including transitions, behaviors and property value |
639 number of ways, including transitions, behaviors and property value |
648 sources. The \l PropertyAnimation documentation shows a variety of methods |
640 sources. The \l {QML Animation} documentation shows a variety of methods |
649 for creating animations. |
641 for creating animations. |
650 |
642 |
651 When used in a transition, ColorAnimation will by default animate |
643 For convenience, when a ColorAnimation is used in a \l Transition, it will |
652 all properties of type color that have changed. If a \l{PropertyAnimation::}{property} |
644 animate any \c color properties that have been modified during the state |
653 or \l{PropertyAnimation::}{properties} are explicitly set for the animation, |
645 change. If a \l{PropertyAnimation::}{property} or |
|
646 \l{PropertyAnimation::}{properties} are explicitly set for the animation, |
654 then those are used instead. |
647 then those are used instead. |
655 |
648 |
656 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
649 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
657 */ |
650 */ |
658 /*! |
|
659 \internal |
|
660 \class QDeclarativeColorAnimation |
|
661 */ |
|
662 |
|
663 QDeclarativeColorAnimation::QDeclarativeColorAnimation(QObject *parent) |
651 QDeclarativeColorAnimation::QDeclarativeColorAnimation(QObject *parent) |
664 : QDeclarativePropertyAnimation(parent) |
652 : QDeclarativePropertyAnimation(parent) |
665 { |
653 { |
666 Q_D(QDeclarativePropertyAnimation); |
654 Q_D(QDeclarativePropertyAnimation); |
667 d->interpolatorType = QMetaType::QColor; |
655 d->interpolatorType = QMetaType::QColor; |
688 NumberAnimation { from: "#c0c0c0"; duration: 2000 } |
676 NumberAnimation { from: "#c0c0c0"; duration: 2000 } |
689 } |
677 } |
690 } |
678 } |
691 \endqml |
679 \endqml |
692 |
680 |
693 If this value is not set and the ColorAnimation is defined within |
681 If the ColorAnimation is defined within a \l Transition or \l Behavior, |
694 a \l Transition, it defaults to the value defined in the starting |
682 this value defaults to the value defined in the starting state of the |
695 state of the \l Transition. |
683 \l Transition, or the current value of the property at the moment the |
|
684 \l Behavior is triggered. |
|
685 |
|
686 \sa {QML Animation} |
696 */ |
687 */ |
697 QColor QDeclarativeColorAnimation::from() const |
688 QColor QDeclarativeColorAnimation::from() const |
698 { |
689 { |
699 Q_D(const QDeclarativePropertyAnimation); |
690 Q_D(const QDeclarativePropertyAnimation); |
700 return d->from.value<QColor>(); |
691 return d->from.value<QColor>(); |
708 /*! |
699 /*! |
709 \qmlproperty color ColorAnimation::to |
700 \qmlproperty color ColorAnimation::to |
710 |
701 |
711 This property holds the color value at which the animation should end. |
702 This property holds the color value at which the animation should end. |
712 |
703 |
713 If this value is not set and the ColorAnimation is defined within |
704 If the ColorAnimation is defined within a \l Transition or \l Behavior, |
714 a \l Transition or \l Behavior, it defaults to the value defined in the end |
705 this value defaults to the value defined in the end state of the |
715 state of the \l Transition or \l Behavior. |
706 \l Transition, or the value of the property change that triggered the |
|
707 \l Behavior. |
|
708 |
|
709 \sa {QML Animation} |
716 */ |
710 */ |
717 QColor QDeclarativeColorAnimation::to() const |
711 QColor QDeclarativeColorAnimation::to() const |
718 { |
712 { |
719 Q_D(const QDeclarativePropertyAnimation); |
713 Q_D(const QDeclarativePropertyAnimation); |
720 return d->to.value<QColor>(); |
714 return d->to.value<QColor>(); |
875 |
866 |
876 |
867 |
877 |
868 |
878 /*! |
869 /*! |
879 \qmlclass PropertyAction QDeclarativePropertyAction |
870 \qmlclass PropertyAction QDeclarativePropertyAction |
|
871 \ingroup qml-animation-transition |
880 \since 4.7 |
872 \since 4.7 |
881 \inherits Animation |
873 \inherits Animation |
882 \brief The PropertyAction element allows immediate property changes during animation. |
874 \brief The PropertyAction element allows immediate property changes during animation. |
883 |
875 |
884 PropertyAction is used to specify an immediate property change |
876 PropertyAction is used to specify an immediate property change during an |
885 during an animation. The property change is not animated. |
877 animation. The property change is not animated. |
886 |
878 |
887 For example, to explicitly set \c {theImage.smooth = true} during a \l Transition: |
879 It is useful for setting non-animated property values during an animation. |
888 \code |
880 |
|
881 For example, here is a SequentialAnimation that sets the image's |
|
882 \l {Image::}{smooth} property to \c true, animates the width of the image, |
|
883 then sets \l {Image::}{smooth} back to \c false: |
|
884 |
|
885 \snippet doc/src/snippets/declarative/propertyaction.qml standalone |
|
886 |
|
887 PropertyAction is also useful for setting the exact point at which a property |
|
888 change should occur during a \l Transition. For example, if PropertyChanges |
|
889 was used in a \l State to rotate an item around a particular |
|
890 \l {Item::}{transformOrigin}, it might be implemented like this: |
|
891 |
|
892 \snippet doc/src/snippets/declarative/propertyaction.qml transition |
|
893 |
|
894 However, with this code, the \c transformOrigin is not set until \e after |
|
895 the animation, as a \l State is taken to define the values at the \e end of |
|
896 a transition. The animation would rotate at the default \c transformOrigin, |
|
897 then jump to \c Item.BottomRight. To fix this, insert a PropertyChanges |
|
898 before the RotationAnimation begins: |
|
899 |
|
900 \qml |
889 transitions: Transition { |
901 transitions: Transition { |
890 ... |
902 SequentialAnimation { |
891 PropertyAction { target: theImage; property: "smooth"; value: true } |
903 PropertyAction { target: rect; property: "transformOrigin" } |
892 ... |
904 RotationAnimation { ... } |
893 } |
905 } |
894 \endcode |
906 } |
895 |
907 \endqml |
896 Or, to set \c theWebView.url to the value set for the destination state: |
908 |
897 \code |
909 This immediately sets the \c transformOrigin property to the value defined |
898 transitions: Transition { |
910 in the end state of the \l Transition (i.e. the value defined in the |
899 ... |
911 PropertyChanges object) so that the rotation animation begins with the |
900 PropertyAction { target: theWebView; property: "url" } |
912 correct transform origin. |
901 ... |
913 |
902 } |
914 \sa {QML Animation}, QtDeclarative |
903 \endcode |
|
904 |
|
905 |
|
906 \sa QtDeclarative |
|
907 */ |
|
908 /*! |
|
909 \internal |
|
910 \class QDeclarativePropertyAction |
|
911 */ |
915 */ |
912 QDeclarativePropertyAction::QDeclarativePropertyAction(QObject *parent) |
916 QDeclarativePropertyAction::QDeclarativePropertyAction(QObject *parent) |
913 : QDeclarativeAbstractAnimation(*(new QDeclarativePropertyActionPrivate), parent) |
917 : QDeclarativeAbstractAnimation(*(new QDeclarativePropertyActionPrivate), parent) |
914 { |
918 { |
915 Q_D(QDeclarativePropertyAction); |
919 Q_D(QDeclarativePropertyAction); |
1006 } |
1010 } |
1007 |
1011 |
1008 /*! |
1012 /*! |
1009 \qmlproperty any PropertyAction::value |
1013 \qmlproperty any PropertyAction::value |
1010 This property holds the value to be set on the property. |
1014 This property holds the value to be set on the property. |
1011 If not set, then the value defined for the end state of the transition. |
1015 |
|
1016 If the PropertyAction is defined within a \l Transition or \l Behavior, |
|
1017 this value defaults to the value defined in the end state of the |
|
1018 \l Transition, or the value of the property change that triggered the |
|
1019 \l Behavior. |
1012 */ |
1020 */ |
1013 QVariant QDeclarativePropertyAction::value() const |
1021 QVariant QDeclarativePropertyAction::value() const |
1014 { |
1022 { |
1015 Q_D(const QDeclarativePropertyAction); |
1023 Q_D(const QDeclarativePropertyAction); |
1016 return d->value; |
1024 return d->value; |
1141 |
1150 |
1142 \snippet doc/src/snippets/declarative/numberanimation.qml 0 |
1151 \snippet doc/src/snippets/declarative/numberanimation.qml 0 |
1143 |
1152 |
1144 Like any other animation element, a NumberAnimation can be applied in a |
1153 Like any other animation element, a NumberAnimation can be applied in a |
1145 number of ways, including transitions, behaviors and property value |
1154 number of ways, including transitions, behaviors and property value |
1146 sources. The \l PropertyAnimation documentation shows a variety of methods |
1155 sources. The \l {QML Animation} documentation shows a variety of methods |
1147 for creating animations. |
1156 for creating animations. |
1148 |
1157 |
1149 Note that NumberAnimation may not animate smoothly if there are irregular |
1158 Note that NumberAnimation may not animate smoothly if there are irregular |
1150 changes in the number value that it is tracking. If this is the case, use |
1159 changes in the number value that it is tracking. If this is the case, use |
1151 SmoothedAnimation instead. |
1160 SmoothedAnimation instead. |
1152 |
1161 |
1153 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1162 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1154 */ |
1163 */ |
1155 |
|
1156 /*! |
|
1157 \internal |
|
1158 \class QDeclarativeNumberAnimation |
|
1159 */ |
|
1160 |
|
1161 QDeclarativeNumberAnimation::QDeclarativeNumberAnimation(QObject *parent) |
1164 QDeclarativeNumberAnimation::QDeclarativeNumberAnimation(QObject *parent) |
1162 : QDeclarativePropertyAnimation(parent) |
1165 : QDeclarativePropertyAnimation(parent) |
1163 { |
1166 { |
1164 init(); |
1167 init(); |
1165 } |
1168 } |
1196 NumberAnimation { properties: "x"; from: 100; duration: 200 } |
1199 NumberAnimation { properties: "x"; from: 100; duration: 200 } |
1197 } |
1200 } |
1198 } |
1201 } |
1199 \endqml |
1202 \endqml |
1200 |
1203 |
1201 If this value is not set and the NumberAnimation is defined within |
1204 If the NumberAnimation is defined within a \l Transition or \l Behavior, |
1202 a \l Transition, it defaults to the value defined in the start |
1205 this value defaults to the value defined in the starting state of the |
1203 state of the \l Transition. |
1206 \l Transition, or the current value of the property at the moment the |
|
1207 \l Behavior is triggered. |
|
1208 |
|
1209 \sa {QML Animation} |
1204 */ |
1210 */ |
1205 |
1211 |
1206 qreal QDeclarativeNumberAnimation::from() const |
1212 qreal QDeclarativeNumberAnimation::from() const |
1207 { |
1213 { |
1208 Q_D(const QDeclarativePropertyAnimation); |
1214 Q_D(const QDeclarativePropertyAnimation); |
1214 QDeclarativePropertyAnimation::setFrom(f); |
1220 QDeclarativePropertyAnimation::setFrom(f); |
1215 } |
1221 } |
1216 |
1222 |
1217 /*! |
1223 /*! |
1218 \qmlproperty real NumberAnimation::to |
1224 \qmlproperty real NumberAnimation::to |
1219 This property holds the ending number value. |
1225 This property holds the end value for the animation. |
1220 |
1226 |
1221 If this value is not set and the NumberAnimation is defined within |
1227 If the NumberAnimation is defined within a \l Transition or \l Behavior, |
1222 a \l Transition or \l Behavior, it defaults to the value defined in the end |
1228 this value defaults to the value defined in the end state of the |
1223 state of the \l Transition or \l Behavior. |
1229 \l Transition, or the value of the property change that triggered the |
|
1230 \l Behavior. |
|
1231 |
|
1232 \sa {QML Animation} |
1224 */ |
1233 */ |
1225 qreal QDeclarativeNumberAnimation::to() const |
1234 qreal QDeclarativeNumberAnimation::to() const |
1226 { |
1235 { |
1227 Q_D(const QDeclarativePropertyAnimation); |
1236 Q_D(const QDeclarativePropertyAnimation); |
1228 return d->to.toReal(); |
1237 return d->to.toReal(); |
1235 |
1244 |
1236 |
1245 |
1237 |
1246 |
1238 /*! |
1247 /*! |
1239 \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation |
1248 \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation |
|
1249 \ingroup qml-animation-transition |
1240 \since 4.7 |
1250 \since 4.7 |
1241 \inherits PropertyAnimation |
1251 \inherits PropertyAnimation |
1242 \brief The Vector3dAnimation element animates changes in QVector3d values. |
1252 \brief The Vector3dAnimation element animates changes in QVector3d values. |
1243 |
1253 |
1244 Vector3dAnimation is a specialized PropertyAnimation that defines an |
1254 Vector3dAnimation is a specialized PropertyAnimation that defines an |
1245 animation to be applied when a Vector3d value changes. |
1255 animation to be applied when a Vector3d value changes. |
1246 |
1256 |
|
1257 Like any other animation element, a Vector3dAnimation can be applied in a |
|
1258 number of ways, including transitions, behaviors and property value |
|
1259 sources. The \l {QML Animation} documentation shows a variety of methods |
|
1260 for creating animations. |
|
1261 |
1247 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1262 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1248 */ |
1263 */ |
1249 |
|
1250 /*! |
|
1251 \internal |
|
1252 \class QDeclarativeVector3dAnimation |
|
1253 */ |
|
1254 |
|
1255 QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent) |
1264 QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(QObject *parent) |
1256 : QDeclarativePropertyAnimation(parent) |
1265 : QDeclarativePropertyAnimation(parent) |
1257 { |
1266 { |
1258 Q_D(QDeclarativePropertyAnimation); |
1267 Q_D(QDeclarativePropertyAnimation); |
1259 d->interpolatorType = QMetaType::QVector3D; |
1268 d->interpolatorType = QMetaType::QVector3D; |
1265 { |
1274 { |
1266 } |
1275 } |
1267 |
1276 |
1268 /*! |
1277 /*! |
1269 \qmlproperty real Vector3dAnimation::from |
1278 \qmlproperty real Vector3dAnimation::from |
1270 This property holds the starting value. |
1279 This property holds the starting value for the animation. |
1271 |
1280 |
1272 If this value is not set, it defaults to the value defined in the start |
1281 If the Vector3dAnimation is defined within a \l Transition or \l Behavior, |
1273 state of the \l Transition. |
1282 this value defaults to the value defined in the starting state of the |
|
1283 \l Transition, or the current value of the property at the moment the |
|
1284 \l Behavior is triggered. |
|
1285 |
|
1286 \sa {QML Animation} |
1274 */ |
1287 */ |
1275 QVector3D QDeclarativeVector3dAnimation::from() const |
1288 QVector3D QDeclarativeVector3dAnimation::from() const |
1276 { |
1289 { |
1277 Q_D(const QDeclarativePropertyAnimation); |
1290 Q_D(const QDeclarativePropertyAnimation); |
1278 return d->from.value<QVector3D>(); |
1291 return d->from.value<QVector3D>(); |
1283 QDeclarativePropertyAnimation::setFrom(f); |
1296 QDeclarativePropertyAnimation::setFrom(f); |
1284 } |
1297 } |
1285 |
1298 |
1286 /*! |
1299 /*! |
1287 \qmlproperty real Vector3dAnimation::to |
1300 \qmlproperty real Vector3dAnimation::to |
1288 This property holds the ending value. |
1301 This property holds the end value for the animation. |
1289 |
1302 |
1290 If this value is not set, it defaults to the value defined in the end |
1303 If the Vector3dAnimation is defined within a \l Transition or \l Behavior, |
1291 state of the \l Transition or \l Behavior. |
1304 this value defaults to the value defined in the end state of the |
|
1305 \l Transition, or the value of the property change that triggered the |
|
1306 \l Behavior. |
|
1307 |
|
1308 \sa {QML Animation} |
1292 */ |
1309 */ |
1293 QVector3D QDeclarativeVector3dAnimation::to() const |
1310 QVector3D QDeclarativeVector3dAnimation::to() const |
1294 { |
1311 { |
1295 Q_D(const QDeclarativePropertyAnimation); |
1312 Q_D(const QDeclarativePropertyAnimation); |
1296 return d->to.value<QVector3D>(); |
1313 return d->to.value<QVector3D>(); |
1321 In the following example we use RotationAnimation to animate the rotation |
1339 In the following example we use RotationAnimation to animate the rotation |
1322 between states via the shortest path: |
1340 between states via the shortest path: |
1323 |
1341 |
1324 \snippet doc/src/snippets/declarative/rotationanimation.qml 0 |
1342 \snippet doc/src/snippets/declarative/rotationanimation.qml 0 |
1325 |
1343 |
1326 Notice the RotationAnimation did not need to set a \l {RotationAnimation::}{target} |
1344 Notice the RotationAnimation did not need to set a \l target |
1327 value. As a convenience, when used in a transition, RotationAnimation will rotate all |
1345 value. As a convenience, when used in a transition, RotationAnimation will rotate all |
1328 properties named "rotation" or "angle". You can override this by providing |
1346 properties named "rotation" or "angle". You can override this by providing |
1329 your own properties via \l {PropertyAnimation::properties}{properties} or |
1347 your own properties via \l {PropertyAnimation::properties}{properties} or |
1330 \l {PropertyAnimation::property}{property}. |
1348 \l {PropertyAnimation::property}{property}. |
1331 |
1349 |
|
1350 Also, note the \l Rectangle will be rotated around its default |
|
1351 \l {Item::}{transformOrigin} (which is \c Item.Center). To use a different |
|
1352 transform origin, set the origin in the PropertyChanges object and apply |
|
1353 the change at the start of the animation using PropertyAction. See the |
|
1354 PropertyAction documentation for more details. |
|
1355 |
1332 Like any other animation element, a RotationAnimation can be applied in a |
1356 Like any other animation element, a RotationAnimation can be applied in a |
1333 number of ways, including transitions, behaviors and property value |
1357 number of ways, including transitions, behaviors and property value |
1334 sources. The \l PropertyAnimation documentation shows a variety of methods |
1358 sources. The \l {QML Animation} documentation shows a variety of methods |
1335 for creating animations. |
1359 for creating animations. |
1336 |
1360 |
1337 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1361 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1338 */ |
1362 */ |
1339 |
|
1340 /*! |
|
1341 \internal |
|
1342 \class QDeclarativeRotationAnimation |
|
1343 */ |
|
1344 |
|
1345 QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress) |
1363 QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress) |
1346 { |
1364 { |
1347 qreal newt = t; |
1365 qreal newt = t; |
1348 qreal diff = t-f; |
1366 qreal diff = t-f; |
1349 while(diff > 180.0){ |
1367 while(diff > 180.0){ |
1407 RotationAnimation { properties: "angle"; from: 100; duration: 2000 } |
1425 RotationAnimation { properties: "angle"; from: 100; duration: 2000 } |
1408 } |
1426 } |
1409 } |
1427 } |
1410 \endqml |
1428 \endqml |
1411 |
1429 |
1412 If this value is not set, it defaults to the value defined in the start |
1430 If the RotationAnimation is defined within a \l Transition or \l Behavior, |
1413 state of the \l Transition. |
1431 this value defaults to the value defined in the starting state of the |
|
1432 \l Transition, or the current value of the property at the moment the |
|
1433 \l Behavior is triggered. |
|
1434 |
|
1435 \sa {QML Animation} |
1414 */ |
1436 */ |
1415 qreal QDeclarativeRotationAnimation::from() const |
1437 qreal QDeclarativeRotationAnimation::from() const |
1416 { |
1438 { |
1417 Q_D(const QDeclarativeRotationAnimation); |
1439 Q_D(const QDeclarativeRotationAnimation); |
1418 return d->from.toReal(); |
1440 return d->from.toReal(); |
1423 QDeclarativePropertyAnimation::setFrom(f); |
1445 QDeclarativePropertyAnimation::setFrom(f); |
1424 } |
1446 } |
1425 |
1447 |
1426 /*! |
1448 /*! |
1427 \qmlproperty real RotationAnimation::to |
1449 \qmlproperty real RotationAnimation::to |
1428 This property holds the ending value. |
1450 This property holds the end value for the animation.. |
1429 |
1451 |
1430 If this value is not set, it defaults to the value defined in the end |
1452 If the RotationAnimation is defined within a \l Transition or \l Behavior, |
1431 state of the \l Transition or \l Behavior. |
1453 this value defaults to the value defined in the end state of the |
|
1454 \l Transition, or the value of the property change that triggered the |
|
1455 \l Behavior. |
|
1456 |
|
1457 \sa {QML Animation} |
1432 */ |
1458 */ |
1433 qreal QDeclarativeRotationAnimation::to() const |
1459 qreal QDeclarativeRotationAnimation::to() const |
1434 { |
1460 { |
1435 Q_D(const QDeclarativeRotationAnimation); |
1461 Q_D(const QDeclarativeRotationAnimation); |
1436 return d->to.toReal(); |
1462 return d->to.toReal(); |
1552 so SequentialAnimation can be used to enclose the animations in a \l Transition |
1579 so SequentialAnimation can be used to enclose the animations in a \l Transition |
1553 if this is the preferred behavior. |
1580 if this is the preferred behavior. |
1554 |
1581 |
1555 Like any other animation element, a SequentialAnimation can be applied in a |
1582 Like any other animation element, a SequentialAnimation can be applied in a |
1556 number of ways, including transitions, behaviors and property value |
1583 number of ways, including transitions, behaviors and property value |
1557 sources. The \l PropertyAnimation documentation shows a variety of methods |
1584 sources. The \l {QML Animation} documentation shows a variety of methods |
1558 for creating animations. |
1585 for creating animations. |
1559 |
1586 |
|
1587 \note Once an animation has been grouped into a SequentialAnimation or |
|
1588 ParallelAnimation, it cannot be individually started and stopped; the |
|
1589 SequentialAnimation or ParallelAnimation must be started and stopped as a group. |
|
1590 |
1560 \sa ParallelAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1591 \sa ParallelAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1561 */ |
1592 */ |
1562 |
1593 |
1563 QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent) : |
1594 QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent) : |
1564 QDeclarativeAnimationGroup(parent) |
1595 QDeclarativeAnimationGroup(parent) |
1617 |
1649 |
1618 \snippet doc/src/snippets/declarative/parallelanimation.qml 0 |
1650 \snippet doc/src/snippets/declarative/parallelanimation.qml 0 |
1619 |
1651 |
1620 Like any other animation element, a ParallelAnimation can be applied in a |
1652 Like any other animation element, a ParallelAnimation can be applied in a |
1621 number of ways, including transitions, behaviors and property value |
1653 number of ways, including transitions, behaviors and property value |
1622 sources. The \l PropertyAnimation documentation shows a variety of methods |
1654 sources. The \l {QML Animation} documentation shows a variety of methods |
1623 for creating animations. |
1655 for creating animations. |
1624 |
1656 |
|
1657 \note Once an animation has been grouped into a SequentialAnimation or |
|
1658 ParallelAnimation, it cannot be individually started and stopped; the |
|
1659 SequentialAnimation or ParallelAnimation must be started and stopped as a group. |
|
1660 |
1625 \sa SequentialAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1661 \sa SequentialAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example} |
1626 */ |
1662 */ |
1627 /*! |
|
1628 \internal |
|
1629 \class QDeclarativeParallelAnimation |
|
1630 */ |
|
1631 |
|
1632 QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) : |
1663 QDeclarativeParallelAnimation::QDeclarativeParallelAnimation(QObject *parent) : |
1633 QDeclarativeAnimationGroup(parent) |
1664 QDeclarativeAnimationGroup(parent) |
1634 { |
1665 { |
1635 Q_D(QDeclarativeAnimationGroup); |
1666 Q_D(QDeclarativeAnimationGroup); |
1636 d->ag = new QParallelAnimationGroup; |
1667 d->ag = new QParallelAnimationGroup; |
1827 emit durationChanged(duration); |
1859 emit durationChanged(duration); |
1828 } |
1860 } |
1829 |
1861 |
1830 /*! |
1862 /*! |
1831 \qmlproperty real PropertyAnimation::from |
1863 \qmlproperty real PropertyAnimation::from |
1832 This property holds the starting value. |
1864 This property holds the starting value for the animation. |
1833 If not set, then the value defined in the start state of the transition. |
1865 |
|
1866 If the PropertyAnimation is defined within a \l Transition or \l Behavior, |
|
1867 this value defaults to the value defined in the starting state of the |
|
1868 \l Transition, or the current value of the property at the moment the |
|
1869 \l Behavior is triggered. |
|
1870 |
|
1871 \sa {QML Animation} |
1834 */ |
1872 */ |
1835 QVariant QDeclarativePropertyAnimation::from() const |
1873 QVariant QDeclarativePropertyAnimation::from() const |
1836 { |
1874 { |
1837 Q_D(const QDeclarativePropertyAnimation); |
1875 Q_D(const QDeclarativePropertyAnimation); |
1838 return d->from; |
1876 return d->from; |
1848 emit fromChanged(f); |
1886 emit fromChanged(f); |
1849 } |
1887 } |
1850 |
1888 |
1851 /*! |
1889 /*! |
1852 \qmlproperty real PropertyAnimation::to |
1890 \qmlproperty real PropertyAnimation::to |
1853 This property holds the ending value. |
1891 This property holds the end value for the animation. |
1854 If not set, then the value defined in the end state of the transition or \l Behavior. |
1892 |
|
1893 If the PropertyAnimation is defined within a \l Transition or \l Behavior, |
|
1894 this value defaults to the value defined in the end state of the |
|
1895 \l Transition, or the value of the property change that triggered the |
|
1896 \l Behavior. |
|
1897 |
|
1898 \sa {QML Animation} |
1855 */ |
1899 */ |
1856 QVariant QDeclarativePropertyAnimation::to() const |
1900 QVariant QDeclarativePropertyAnimation::to() const |
1857 { |
1901 { |
1858 Q_D(const QDeclarativePropertyAnimation); |
1902 Q_D(const QDeclarativePropertyAnimation); |
1859 return d->to; |
1903 return d->to; |
1927 \o \c Easing.InQuart |
1971 \o \c Easing.InQuart |
1928 \o Easing curve for a quartic (t^4) function: accelerating from zero velocity. |
1972 \o Easing curve for a quartic (t^4) function: accelerating from zero velocity. |
1929 \o \inlineimage qeasingcurve-inquart.png |
1973 \o \inlineimage qeasingcurve-inquart.png |
1930 \row |
1974 \row |
1931 \o \c Easing.OutQuart |
1975 \o \c Easing.OutQuart |
1932 \o Easing curve for a cubic (t^4) function: decelerating from zero velocity. |
1976 \o Easing curve for a quartic (t^4) function: decelerating from zero velocity. |
1933 \o \inlineimage qeasingcurve-outquart.png |
1977 \o \inlineimage qeasingcurve-outquart.png |
1934 \row |
1978 \row |
1935 \o \c Easing.InOutQuart |
1979 \o \c Easing.InOutQuart |
1936 \o Easing curve for a cubic (t^4) function: acceleration until halfway, then deceleration. |
1980 \o Easing curve for a quartic (t^4) function: acceleration until halfway, then deceleration. |
1937 \o \inlineimage qeasingcurve-inoutquart.png |
1981 \o \inlineimage qeasingcurve-inoutquart.png |
1938 \row |
1982 \row |
1939 \o \c Easing.OutInQuart |
1983 \o \c Easing.OutInQuart |
1940 \o Easing curve for a cubic (t^4) function: deceleration until halfway, then acceleration. |
1984 \o Easing curve for a quartic (t^4) function: deceleration until halfway, then acceleration. |
1941 \o \inlineimage qeasingcurve-outinquart.png |
1985 \o \inlineimage qeasingcurve-outinquart.png |
1942 \row |
1986 \row |
1943 \o \c Easing.InQuint |
1987 \o \c Easing.InQuint |
1944 \o Easing curve for a quintic (t^5) function: accelerating from zero velocity. |
1988 \o Easing curve for a quintic (t^5) function: accelerating from zero velocity. |
1945 \o \inlineimage qeasingcurve-inquint.png |
1989 \o \inlineimage qeasingcurve-inquint.png |
1946 \row |
1990 \row |
1947 \o \c Easing.OutQuint |
1991 \o \c Easing.OutQuint |
1948 \o Easing curve for a cubic (t^5) function: decelerating from zero velocity. |
1992 \o Easing curve for a quintic (t^5) function: decelerating from zero velocity. |
1949 \o \inlineimage qeasingcurve-outquint.png |
1993 \o \inlineimage qeasingcurve-outquint.png |
1950 \row |
1994 \row |
1951 \o \c Easing.InOutQuint |
1995 \o \c Easing.InOutQuint |
1952 \o Easing curve for a cubic (t^5) function: acceleration until halfway, then deceleration. |
1996 \o Easing curve for a quintic (t^5) function: acceleration until halfway, then deceleration. |
1953 \o \inlineimage qeasingcurve-inoutquint.png |
1997 \o \inlineimage qeasingcurve-inoutquint.png |
1954 \row |
1998 \row |
1955 \o \c Easing.OutInQuint |
1999 \o \c Easing.OutInQuint |
1956 \o Easing curve for a cubic (t^5) function: deceleration until halfway, then acceleration. |
2000 \o Easing curve for a quintic (t^5) function: deceleration until halfway, then acceleration. |
1957 \o \inlineimage qeasingcurve-outinquint.png |
2001 \o \inlineimage qeasingcurve-outinquint.png |
1958 \row |
2002 \row |
1959 \o \c Easing.InSine |
2003 \o \c Easing.InSine |
1960 \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity. |
2004 \o Easing curve for a sinusoidal (sin(t)) function: accelerating from zero velocity. |
1961 \o \inlineimage qeasingcurve-insine.png |
2005 \o \inlineimage qeasingcurve-insine.png |
2376 d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); |
2420 d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); |
2377 d->va->setFromSourcedValue(&data->fromSourced); |
2421 d->va->setFromSourcedValue(&data->fromSourced); |
2378 d->actions = &data->actions; |
2422 d->actions = &data->actions; |
2379 } else { |
2423 } else { |
2380 delete data; |
2424 delete data; |
|
2425 d->va->setFromSourcedValue(0); //clear previous data |
|
2426 d->va->setAnimValue(0, QAbstractAnimation::DeleteWhenStopped); //clear previous data |
2381 d->actions = 0; |
2427 d->actions = 0; |
2382 } |
2428 } |
2383 } |
2429 } |
2384 |
2430 |
2385 /*! |
2431 /*! |
2386 \qmlclass ParentAnimation QDeclarativeParentAnimation |
2432 \qmlclass ParentAnimation QDeclarativeParentAnimation |
|
2433 \ingroup qml-animation-transition |
2387 \since 4.7 |
2434 \since 4.7 |
2388 \inherits Animation |
2435 \inherits Animation |
2389 \brief The ParentAnimation element animates changes in parent values. |
2436 \brief The ParentAnimation element animates changes in parent values. |
2390 |
2437 |
2391 ParentAnimation defines an animation to applied when a ParentChange |
2438 ParentAnimation is used to animate a parent change for an \l Item. |
2392 occurs. This allows parent changes to be smoothly animated. |
|
2393 |
2439 |
2394 For example, the following ParentChange changes \c blueRect to become |
2440 For example, the following ParentChange changes \c blueRect to become |
2395 a child of \c redRect when it is clicked. The inclusion of the |
2441 a child of \c redRect when it is clicked. The inclusion of the |
2396 ParentAnimation, which defines a NumberAnimation to be applied during |
2442 ParentAnimation, which defines a NumberAnimation to be applied during |
2397 the transition, ensures the item animates smoothly as it moves to |
2443 the transition, ensures the item animates smoothly as it moves to |
2405 |
2451 |
2406 In some cases, such as when reparenting between items with clipping enabled, it is useful |
2452 In some cases, such as when reparenting between items with clipping enabled, it is useful |
2407 to animate the parent change via another item that does not have clipping |
2453 to animate the parent change via another item that does not have clipping |
2408 enabled. Such an item can be set using the \l via property. |
2454 enabled. Such an item can be set using the \l via property. |
2409 |
2455 |
2410 By default, when used in a transition, ParentAnimation animates all parent |
2456 For convenience, when a ParentAnimation is used in a \l Transition, it will |
2411 changes. This can be overriden by setting a specific target item using the |
2457 animate any ParentChange that has occurred during the state change. |
|
2458 This can be overridden by setting a specific target item using the |
2412 \l target property. |
2459 \l target property. |
2413 |
2460 |
|
2461 Like any other animation element, a ParentAnimation can be applied in a |
|
2462 number of ways, including transitions, behaviors and property value |
|
2463 sources. The \l {QML Animation} documentation shows a variety of methods |
|
2464 for creating animations. |
|
2465 |
2414 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
2466 \sa {QML Animation}, {declarative/animation/basics}{Animation basics example} |
2415 */ |
|
2416 |
|
2417 /*! |
|
2418 \internal |
|
2419 \class QDeclarativeParentAnimation |
|
2420 */ |
2467 */ |
2421 QDeclarativeParentAnimation::QDeclarativeParentAnimation(QObject *parent) |
2468 QDeclarativeParentAnimation::QDeclarativeParentAnimation(QObject *parent) |
2422 : QDeclarativeAnimationGroup(*(new QDeclarativeParentAnimationPrivate), parent) |
2469 : QDeclarativeAnimationGroup(*(new QDeclarativeParentAnimationPrivate), parent) |
2423 { |
2470 { |
2424 Q_D(QDeclarativeParentAnimation); |
2471 Q_D(QDeclarativeParentAnimation); |
2467 |
2514 |
2468 /*! |
2515 /*! |
2469 \qmlproperty Item ParentAnimation::newParent |
2516 \qmlproperty Item ParentAnimation::newParent |
2470 The new parent to animate to. |
2517 The new parent to animate to. |
2471 |
2518 |
2472 If not set, then the parent defined in the end state of the transition. |
2519 If the ParentAnimation is defined within a \l Transition or \l Behavior, |
|
2520 this value defaults to the value defined in the end state of the |
|
2521 \l Transition, or the value of the property change that triggered the |
|
2522 \l Behavior. |
2473 */ |
2523 */ |
2474 QDeclarativeItem *QDeclarativeParentAnimation::newParent() const |
2524 QDeclarativeItem *QDeclarativeParentAnimation::newParent() const |
2475 { |
2525 { |
2476 Q_D(const QDeclarativeParentAnimation); |
2526 Q_D(const QDeclarativeParentAnimation); |
2477 return d->newParent; |
2527 return d->newParent; |
2736 return d->topLevelGroup; |
2786 return d->topLevelGroup; |
2737 } |
2787 } |
2738 |
2788 |
2739 /*! |
2789 /*! |
2740 \qmlclass AnchorAnimation QDeclarativeAnchorAnimation |
2790 \qmlclass AnchorAnimation QDeclarativeAnchorAnimation |
|
2791 \ingroup qml-animation-transition |
2741 \since 4.7 |
2792 \since 4.7 |
2742 \inherits Animation |
2793 \inherits Animation |
2743 \brief The AnchorAnimation element animates changes in anchor values. |
2794 \brief The AnchorAnimation element animates changes in anchor values. |
2744 |
2795 |
2745 AnchorAnimation is used to animate an AnchorChange. It will anchor all |
2796 AnchorAnimation is used to animate an anchor change. |
2746 anchor changes specified in a \l State. |
|
2747 |
2797 |
2748 In the following snippet we animate the addition of a right anchor to a \l Rectangle: |
2798 In the following snippet we animate the addition of a right anchor to a \l Rectangle: |
2749 |
2799 |
2750 \snippet doc/src/snippets/declarative/anchoranimation.qml 0 |
2800 \snippet doc/src/snippets/declarative/anchoranimation.qml 0 |
2751 |
2801 |
2752 \sa AnchorChanges |
2802 For convenience, when an AnchorAnimation is used in a \l Transition, it will |
|
2803 animate any AnchorChanges that have occurred during the state change. |
|
2804 This can be overridden by setting a specific target item using the |
|
2805 \l target property. |
|
2806 |
|
2807 Like any other animation element, an AnchorAnimation can be applied in a |
|
2808 number of ways, including transitions, behaviors and property value |
|
2809 sources. The \l {QML Animation} documentation shows a variety of methods |
|
2810 for creating animations. |
|
2811 |
|
2812 \sa {QML Animation}, AnchorChanges |
2753 */ |
2813 */ |
2754 |
2814 |
2755 QDeclarativeAnchorAnimation::QDeclarativeAnchorAnimation(QObject *parent) |
2815 QDeclarativeAnchorAnimation::QDeclarativeAnchorAnimation(QObject *parent) |
2756 : QDeclarativeAbstractAnimation(*(new QDeclarativeAnchorAnimationPrivate), parent) |
2816 : QDeclarativeAbstractAnimation(*(new QDeclarativeAnchorAnimationPrivate), parent) |
2757 { |
2817 { |