src/declarative/util/qdeclarativeanimation.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   140 {
   140 {
   141     Q_D(const QDeclarativeAbstractAnimation);
   141     Q_D(const QDeclarativeAbstractAnimation);
   142     return d->running;
   142     return d->running;
   143 }
   143 }
   144 
   144 
       
   145 // the behavior calls this function
       
   146 void QDeclarativeAbstractAnimation::notifyRunningChanged(bool running)
       
   147 {
       
   148     Q_D(QDeclarativeAbstractAnimation);
       
   149     if (d->disableUserControl && d->running != running) {
       
   150         d->running = running;
       
   151         emit runningChanged(running);
       
   152     }
       
   153 }
       
   154 
   145 //commence is called to start an animation when it is used as a
   155 //commence is called to start an animation when it is used as a
   146 //simple animation, and not as part of a transition
   156 //simple animation, and not as part of a transition
   147 void QDeclarativeAbstractAnimationPrivate::commence()
   157 void QDeclarativeAbstractAnimationPrivate::commence()
   148 {
   158 {
   149     Q_Q(QDeclarativeAbstractAnimation);
   159     Q_Q(QDeclarativeAbstractAnimation);
   174 
   184 
   175 void QDeclarativeAbstractAnimation::setRunning(bool r)
   185 void QDeclarativeAbstractAnimation::setRunning(bool r)
   176 {
   186 {
   177     Q_D(QDeclarativeAbstractAnimation);
   187     Q_D(QDeclarativeAbstractAnimation);
   178     if (!d->componentComplete) {
   188     if (!d->componentComplete) {
       
   189         if (d->running && r == d->running)    //don't re-register
       
   190             return;
   179         d->running = r;
   191         d->running = r;
   180         if (r == false)
   192         if (r == false)
   181             d->avoidPropertyValueSourceStart = true;
   193             d->avoidPropertyValueSourceStart = true;
   182         else {
   194         else {
   183             QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
   195             QDeclarativeEnginePrivate *engPriv = QDeclarativeEnginePrivate::get(qmlEngine(this));
   555         NumberAnimation { ... duration: 200 }
   567         NumberAnimation { ... duration: 200 }
   556         PauseAnimation { duration: 100 }
   568         PauseAnimation { duration: 100 }
   557         NumberAnimation { ... duration: 200 }
   569         NumberAnimation { ... duration: 200 }
   558     }
   570     }
   559     \endcode
   571     \endcode
       
   572 
       
   573     \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
   560 */
   574 */
   561 /*!
   575 /*!
   562     \internal
   576     \internal
   563     \class QDeclarativePauseAnimation
   577     \class QDeclarativePauseAnimation
   564 */
   578 */
   616 
   630 
   617 /*!
   631 /*!
   618     \qmlclass ColorAnimation QDeclarativeColorAnimation
   632     \qmlclass ColorAnimation QDeclarativeColorAnimation
   619     \since 4.7
   633     \since 4.7
   620     \inherits PropertyAnimation
   634     \inherits PropertyAnimation
   621     \brief The ColorAnimation element allows you to animate color changes.
   635     \brief The ColorAnimation element animates changes in color values.
   622 
   636 
   623     \code
   637     ColorAnimation is a specialized PropertyAnimation that defines an 
   624     ColorAnimation { from: "white"; to: "#c0c0c0"; duration: 100 }
   638     animation to be applied when a color value changes.
   625     \endcode
   639 
       
   640     Here is a ColorAnimation applied to the \c color property of a \l Rectangle 
       
   641     as a property value source. It animates the \c color property's value from 
       
   642     its current value to a value of "red", over 1000 milliseconds:
       
   643 
       
   644     \snippet doc/src/snippets/declarative/coloranimation.qml 0
       
   645 
       
   646     Like any other animation element, a ColorAnimation can be applied in a
       
   647     number of ways, including transitions, behaviors and property value 
       
   648     sources. The \l PropertyAnimation documentation shows a variety of methods
       
   649     for creating animations.
   626 
   650 
   627     When used in a transition, ColorAnimation will by default animate
   651     When used in a transition, ColorAnimation will by default animate
   628     all properties of type color that are changing. If a property or properties
   652     all properties of type color that have changed. If a \l{PropertyAnimation::}{property} 
   629     are explicitly set for the animation, then those will be used instead.
   653     or \l{PropertyAnimation::}{properties} are explicitly set for the animation, 
       
   654     then those are used instead.
       
   655 
       
   656     \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
   630 */
   657 */
   631 /*!
   658 /*!
   632     \internal
   659     \internal
   633     \class QDeclarativeColorAnimation
   660     \class QDeclarativeColorAnimation
   634 */
   661 */
   646 {
   673 {
   647 }
   674 }
   648 
   675 
   649 /*!
   676 /*!
   650     \qmlproperty color ColorAnimation::from
   677     \qmlproperty color ColorAnimation::from
   651     This property holds the starting color.
   678     This property holds the color value at which the animation should begin.
       
   679 
       
   680     For example, the following animation is not applied until a color value
       
   681     has reached "#c0c0c0":
       
   682 
       
   683     \qml
       
   684     Item {
       
   685         states: [ ... ]
       
   686 
       
   687         transition: Transition {
       
   688             NumberAnimation { from: "#c0c0c0"; duration: 2000 }
       
   689         }
       
   690     }
       
   691     \endqml
       
   692 
       
   693     If this value is not set and the ColorAnimation is defined within
       
   694     a \l Transition, it defaults to the value defined in the starting 
       
   695     state of the \l Transition.
   652 */
   696 */
   653 QColor QDeclarativeColorAnimation::from() const
   697 QColor QDeclarativeColorAnimation::from() const
   654 {
   698 {
   655     Q_D(const QDeclarativePropertyAnimation);
   699     Q_D(const QDeclarativePropertyAnimation);
   656     return d->from.value<QColor>();
   700     return d->from.value<QColor>();
   661     QDeclarativePropertyAnimation::setFrom(f);
   705     QDeclarativePropertyAnimation::setFrom(f);
   662 }
   706 }
   663 
   707 
   664 /*!
   708 /*!
   665     \qmlproperty color ColorAnimation::to
   709     \qmlproperty color ColorAnimation::to
   666     This property holds the ending color.
   710 
       
   711     This property holds the color value at which the animation should end.
       
   712 
       
   713     If this value is not set and the ColorAnimation is defined within
       
   714     a \l Transition or \l Behavior, it defaults to the value defined in the end 
       
   715     state of the \l Transition or \l Behavior.
   667 */
   716 */
   668 QColor QDeclarativeColorAnimation::to() const
   717 QColor QDeclarativeColorAnimation::to() const
   669 {
   718 {
   670     Q_D(const QDeclarativePropertyAnimation);
   719     Q_D(const QDeclarativePropertyAnimation);
   671     return d->to.value<QColor>();
   720     return d->to.value<QColor>();
   830     \qmlclass PropertyAction QDeclarativePropertyAction
   879     \qmlclass PropertyAction QDeclarativePropertyAction
   831     \since 4.7
   880     \since 4.7
   832     \inherits Animation
   881     \inherits Animation
   833     \brief The PropertyAction element allows immediate property changes during animation.
   882     \brief The PropertyAction element allows immediate property changes during animation.
   834 
   883 
   835     Explicitly set \c theimage.smooth=true during a transition:
   884     PropertyAction is used to specify an immediate property change
       
   885     during an animation. The property change is not animated.
       
   886 
       
   887     For example, to explicitly set \c {theImage.smooth = true} during a \l Transition:
   836     \code
   888     \code
   837     PropertyAction { target: theimage; property: "smooth"; value: true }
   889     transitions: Transition {
       
   890         ...
       
   891         PropertyAction { target: theImage; property: "smooth"; value: true }
       
   892         ...
       
   893     }
   838     \endcode
   894     \endcode
   839 
   895 
   840     Set \c thewebview.url to the value set for the destination state:
   896     Or, to set \c theWebView.url to the value set for the destination state:
   841     \code
   897     \code
   842     PropertyAction { target: thewebview; property: "url" }
   898     transitions: Transition {
       
   899         ...
       
   900         PropertyAction { target: theWebView; property: "url" }
       
   901         ...
       
   902     }
   843     \endcode
   903     \endcode
   844 
   904 
   845     The PropertyAction is immediate -
       
   846     the target property is not animated to the selected value in any way.
       
   847 
   905 
   848     \sa QtDeclarative
   906     \sa QtDeclarative
   849 */
   907 */
   850 /*!
   908 /*!
   851     \internal
   909     \internal
   867     Q_Q(QDeclarativePropertyAction);
   925     Q_Q(QDeclarativePropertyAction);
   868     spa = new QActionAnimation;
   926     spa = new QActionAnimation;
   869     QDeclarative_setParent_noEvent(spa, q);
   927     QDeclarative_setParent_noEvent(spa, q);
   870 }
   928 }
   871 
   929 
   872 /*!
       
   873     \qmlproperty Object PropertyAction::target
       
   874     This property holds an explicit target object to animate.
       
   875 
       
   876     The exact effect of the \c target property depends on how the animation
       
   877     is being used.  Refer to the \l {QML Animation} documentation for details.
       
   878 */
       
   879 
       
   880 QObject *QDeclarativePropertyAction::target() const
   930 QObject *QDeclarativePropertyAction::target() const
   881 {
   931 {
   882     Q_D(const QDeclarativePropertyAction);
   932     Q_D(const QDeclarativePropertyAction);
   883     return d->target;
   933     return d->target;
   884 }
   934 }
   906     d->propertyName = n;
   956     d->propertyName = n;
   907     emit targetChanged(d->target, d->propertyName);
   957     emit targetChanged(d->target, d->propertyName);
   908 }
   958 }
   909 
   959 
   910 /*!
   960 /*!
       
   961     \qmlproperty Object PropertyAction::target
   911     \qmlproperty list<Object> PropertyAction::targets
   962     \qmlproperty list<Object> PropertyAction::targets
   912     \qmlproperty string PropertyAction::property
   963     \qmlproperty string PropertyAction::property
   913     \qmlproperty string PropertyAction::properties
   964     \qmlproperty string PropertyAction::properties
   914     \qmlproperty Object PropertyAction::target
   965 
   915 
   966     These properties determine the items and their properties that are
   916     These properties are used as a set to determine which properties should be
       
   917     affected by this action.
   967     affected by this action.
   918 
   968 
   919     The details of how these properties are interpreted in different situations
   969     The details of how these properties are interpreted in different situations
   920     is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
   970     is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation
   921     documentation.
   971     documentation.
   943     return QDeclarativeListProperty<QObject>(this, d->targets);
   993     return QDeclarativeListProperty<QObject>(this, d->targets);
   944 }
   994 }
   945 
   995 
   946 /*!
   996 /*!
   947     \qmlproperty list<Object> PropertyAction::exclude
   997     \qmlproperty list<Object> PropertyAction::exclude
   948     This property holds the objects not to be affected by this animation.
   998     This property holds the objects that should not be affected by this action.
   949 
   999 
   950     \sa targets
  1000     \sa targets
   951 */
  1001 */
   952 QDeclarativeListProperty<QObject> QDeclarativePropertyAction::exclude()
  1002 QDeclarativeListProperty<QObject> QDeclarativePropertyAction::exclude()
   953 {
  1003 {
  1078 
  1128 
  1079 /*!
  1129 /*!
  1080     \qmlclass NumberAnimation QDeclarativeNumberAnimation
  1130     \qmlclass NumberAnimation QDeclarativeNumberAnimation
  1081     \since 4.7
  1131     \since 4.7
  1082     \inherits PropertyAnimation
  1132     \inherits PropertyAnimation
  1083     \brief The NumberAnimation element allows you to animate changes in properties of type qreal.
  1133     \brief The NumberAnimation element animates changes in qreal-type values.
  1084 
  1134 
  1085     Animate a set of properties over 200ms, from their values in the start state to
  1135     NumberAnimation is a specialized PropertyAnimation that defines an 
  1086     their values in the end state of the transition:
  1136     animation to be applied when a numerical value changes.
  1087     \code
  1137 
  1088     NumberAnimation { properties: "x,y,scale"; duration: 200 }
  1138     Here is a NumberAnimation applied to the \c x property of a \l Rectangle 
  1089     \endcode
  1139     as a property value source. It animates the \c x value from its current 
       
  1140     value to a value of 50, over 1000 milliseconds:
       
  1141 
       
  1142     \snippet doc/src/snippets/declarative/numberanimation.qml 0
       
  1143 
       
  1144     Like any other animation element, a NumberAnimation can be applied in a
       
  1145     number of ways, including transitions, behaviors and property value 
       
  1146     sources. The \l PropertyAnimation documentation shows a variety of methods
       
  1147     for creating animations.
       
  1148 
       
  1149     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
       
  1151     SmoothedAnimation instead.
       
  1152 
       
  1153     \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
  1090 */
  1154 */
  1091 
  1155 
  1092 /*!
  1156 /*!
  1093     \internal
  1157     \internal
  1094     \class QDeclarativeNumberAnimation
  1158     \class QDeclarativeNumberAnimation
  1117     d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
  1181     d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
  1118 }
  1182 }
  1119 
  1183 
  1120 /*!
  1184 /*!
  1121     \qmlproperty real NumberAnimation::from
  1185     \qmlproperty real NumberAnimation::from
  1122     This property holds the starting value.
  1186     This property holds the starting number value.
  1123     If not set, then the value defined in the start state of the transition.
  1187 
  1124 */
  1188     For example, the following animation is not applied until the \c x value
       
  1189     has reached 100:
       
  1190 
       
  1191     \qml
       
  1192     Item {
       
  1193         states: [ ... ]
       
  1194 
       
  1195         transition: Transition {
       
  1196             NumberAnimation { properties: "x"; from: 100; duration: 200 }
       
  1197         }
       
  1198     }
       
  1199     \endqml
       
  1200 
       
  1201     If this value is not set and the NumberAnimation is defined within
       
  1202     a \l Transition, it defaults to the value defined in the start 
       
  1203     state of the \l Transition.
       
  1204 */
       
  1205 
  1125 qreal QDeclarativeNumberAnimation::from() const
  1206 qreal QDeclarativeNumberAnimation::from() const
  1126 {
  1207 {
  1127     Q_D(const QDeclarativePropertyAnimation);
  1208     Q_D(const QDeclarativePropertyAnimation);
  1128     return d->from.toReal();
  1209     return d->from.toReal();
  1129 }
  1210 }
  1133     QDeclarativePropertyAnimation::setFrom(f);
  1214     QDeclarativePropertyAnimation::setFrom(f);
  1134 }
  1215 }
  1135 
  1216 
  1136 /*!
  1217 /*!
  1137     \qmlproperty real NumberAnimation::to
  1218     \qmlproperty real NumberAnimation::to
  1138     This property holds the ending value.
  1219     This property holds the ending number value.
  1139     If not set, then the value defined in the end state of the transition or Behavior.
  1220 
       
  1221     If this value is not set and the NumberAnimation is defined within
       
  1222     a \l Transition or \l Behavior, it defaults to the value defined in the end 
       
  1223     state of the \l Transition or \l Behavior.
  1140 */
  1224 */
  1141 qreal QDeclarativeNumberAnimation::to() const
  1225 qreal QDeclarativeNumberAnimation::to() const
  1142 {
  1226 {
  1143     Q_D(const QDeclarativePropertyAnimation);
  1227     Q_D(const QDeclarativePropertyAnimation);
  1144     return d->to.toReal();
  1228     return d->to.toReal();
  1153 
  1237 
  1154 /*!
  1238 /*!
  1155     \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation
  1239     \qmlclass Vector3dAnimation QDeclarativeVector3dAnimation
  1156     \since 4.7
  1240     \since 4.7
  1157     \inherits PropertyAnimation
  1241     \inherits PropertyAnimation
  1158     \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
  1242     \brief The Vector3dAnimation element animates changes in QVector3d values.
       
  1243 
       
  1244     Vector3dAnimation is a specialized PropertyAnimation that defines an 
       
  1245     animation to be applied when a Vector3d value changes.
       
  1246 
       
  1247     \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
  1159 */
  1248 */
  1160 
  1249 
  1161 /*!
  1250 /*!
  1162     \internal
  1251     \internal
  1163     \class QDeclarativeVector3dAnimation
  1252     \class QDeclarativeVector3dAnimation
  1177 }
  1266 }
  1178 
  1267 
  1179 /*!
  1268 /*!
  1180     \qmlproperty real Vector3dAnimation::from
  1269     \qmlproperty real Vector3dAnimation::from
  1181     This property holds the starting value.
  1270     This property holds the starting value.
  1182     If not set, then the value defined in the start state of the transition.
  1271 
       
  1272     If this value is not set, it defaults to the value defined in the start 
       
  1273     state of the \l Transition.
  1183 */
  1274 */
  1184 QVector3D QDeclarativeVector3dAnimation::from() const
  1275 QVector3D QDeclarativeVector3dAnimation::from() const
  1185 {
  1276 {
  1186     Q_D(const QDeclarativePropertyAnimation);
  1277     Q_D(const QDeclarativePropertyAnimation);
  1187     return d->from.value<QVector3D>();
  1278     return d->from.value<QVector3D>();
  1193 }
  1284 }
  1194 
  1285 
  1195 /*!
  1286 /*!
  1196     \qmlproperty real Vector3dAnimation::to
  1287     \qmlproperty real Vector3dAnimation::to
  1197     This property holds the ending value.
  1288     This property holds the ending value.
  1198     If not set, then the value defined in the end state of the transition or Behavior.
  1289 
       
  1290     If this value is not set, it defaults to the value defined in the end 
       
  1291     state of the \l Transition or \l Behavior.
  1199 */
  1292 */
  1200 QVector3D QDeclarativeVector3dAnimation::to() const
  1293 QVector3D QDeclarativeVector3dAnimation::to() const
  1201 {
  1294 {
  1202     Q_D(const QDeclarativePropertyAnimation);
  1295     Q_D(const QDeclarativePropertyAnimation);
  1203     return d->to.value<QVector3D>();
  1296     return d->to.value<QVector3D>();
  1212 
  1305 
  1213 /*!
  1306 /*!
  1214     \qmlclass RotationAnimation QDeclarativeRotationAnimation
  1307     \qmlclass RotationAnimation QDeclarativeRotationAnimation
  1215     \since 4.7
  1308     \since 4.7
  1216     \inherits PropertyAnimation
  1309     \inherits PropertyAnimation
  1217     \brief The RotationAnimation element allows you to animate rotations.
  1310     \brief The RotationAnimation element animates changes in rotation values.
  1218 
  1311 
  1219     RotationAnimation is a specialized PropertyAnimation that gives control
  1312     RotationAnimation is a specialized PropertyAnimation that gives control
  1220     over the direction of rotation. By default, it will rotate in the direction
  1313     over the direction of rotation during an animation. 
       
  1314 
       
  1315     By default, it rotates in the direction
  1221     of the numerical change; a rotation from 0 to 240 will rotate 220 degrees
  1316     of the numerical change; a rotation from 0 to 240 will rotate 220 degrees
  1222     clockwise, while a rotation from 240 to 0 will rotate 220 degrees
  1317     clockwise, while a rotation from 240 to 0 will rotate 220 degrees
  1223     counterclockwise.
  1318     counterclockwise. The \l direction property can be set to specify the
  1224 
  1319     direction in which the rotation should occur.
  1225     When used in a transition RotationAnimation will rotate all
  1320 
       
  1321     In the following example we use RotationAnimation to animate the rotation
       
  1322     between states via the shortest path:
       
  1323 
       
  1324     \snippet doc/src/snippets/declarative/rotationanimation.qml 0
       
  1325     
       
  1326     Notice the RotationAnimation did not need to set a \l {RotationAnimation::}{target}
       
  1327     value. As a convenience, when used in a transition, RotationAnimation will rotate all
  1226     properties named "rotation" or "angle". You can override this by providing
  1328     properties named "rotation" or "angle". You can override this by providing
  1227     your own properties via \c properties or \c property.
  1329     your own properties via \l {PropertyAnimation::properties}{properties} or 
  1228 
  1330     \l {PropertyAnimation::property}{property}.
  1229     In the following example we use RotationAnimation to animate the rotation
  1331 
  1230     between states via the shortest path.
  1332     Like any other animation element, a RotationAnimation can be applied in a
  1231     \qml
  1333     number of ways, including transitions, behaviors and property value 
  1232     states: {
  1334     sources. The \l PropertyAnimation documentation shows a variety of methods
  1233         State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } }
  1335     for creating animations.
  1234         State { name: "90"; PropertyChanges { target: myItem; rotation: 90 } }
  1336 
  1235         State { name: "-90"; PropertyChanges { target: myItem; rotation: -90 } }
  1337     \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
  1236     }
       
  1237     transition: Transition {
       
  1238         RotationAnimation { direction: RotationAnimation.Shortest }
       
  1239     }
       
  1240     \endqml
       
  1241 */
  1338 */
  1242 
  1339 
  1243 /*!
  1340 /*!
  1244     \internal
  1341     \internal
  1245     \class QDeclarativeRotationAnimation
  1342     \class QDeclarativeRotationAnimation
  1295 {
  1392 {
  1296 }
  1393 }
  1297 
  1394 
  1298 /*!
  1395 /*!
  1299     \qmlproperty real RotationAnimation::from
  1396     \qmlproperty real RotationAnimation::from
  1300     This property holds the starting value.
  1397     This property holds the starting number value.
  1301     If not set, then the value defined in the start state of the transition.
  1398 
       
  1399     For example, the following animation is not applied until the \c angle value
       
  1400     has reached 100:
       
  1401 
       
  1402     \qml
       
  1403     Item {
       
  1404         states: [ ... ]
       
  1405 
       
  1406         transition: Transition {
       
  1407             RotationAnimation { properties: "angle"; from: 100; duration: 2000 }
       
  1408         }
       
  1409     }
       
  1410     \endqml
       
  1411 
       
  1412     If this value is not set, it defaults to the value defined in the start 
       
  1413     state of the \l Transition.
  1302 */
  1414 */
  1303 qreal QDeclarativeRotationAnimation::from() const
  1415 qreal QDeclarativeRotationAnimation::from() const
  1304 {
  1416 {
  1305     Q_D(const QDeclarativeRotationAnimation);
  1417     Q_D(const QDeclarativeRotationAnimation);
  1306     return d->from.toReal();
  1418     return d->from.toReal();
  1312 }
  1424 }
  1313 
  1425 
  1314 /*!
  1426 /*!
  1315     \qmlproperty real RotationAnimation::to
  1427     \qmlproperty real RotationAnimation::to
  1316     This property holds the ending value.
  1428     This property holds the ending value.
  1317     If not set, then the value defined in the end state of the transition or Behavior.
  1429 
       
  1430     If this value is not set, it defaults to the value defined in the end 
       
  1431     state of the \l Transition or \l Behavior.
  1318 */
  1432 */
  1319 qreal QDeclarativeRotationAnimation::to() const
  1433 qreal QDeclarativeRotationAnimation::to() const
  1320 {
  1434 {
  1321     Q_D(const QDeclarativeRotationAnimation);
  1435     Q_D(const QDeclarativeRotationAnimation);
  1322     return d->to.toReal();
  1436     return d->to.toReal();
  1327     QDeclarativePropertyAnimation::setTo(t);
  1441     QDeclarativePropertyAnimation::setTo(t);
  1328 }
  1442 }
  1329 
  1443 
  1330 /*!
  1444 /*!
  1331     \qmlproperty enumeration RotationAnimation::direction
  1445     \qmlproperty enumeration RotationAnimation::direction
  1332     The direction in which to rotate.
  1446     This property holds the direction of the rotation.
  1333 
  1447 
  1334     Possible values are:
  1448     Possible values are:
  1335 
  1449 
  1336     \table
  1450     \list
  1337     \row
  1451     \o RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers.
  1338         \o RotationAnimation.Numerical
       
  1339         \o Rotate by linearly interpolating between the two numbers.
       
  1340            A rotation from 10 to 350 will rotate 340 degrees clockwise.
  1452            A rotation from 10 to 350 will rotate 340 degrees clockwise.
  1341     \row
  1453     \o RotationAnimation.Clockwise - Rotate clockwise between the two values
  1342         \o RotationAnimation.Clockwise
  1454     \o RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values
  1343         \o Rotate clockwise between the two values
  1455     \o RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path.
  1344     \row
       
  1345         \o RotationAnimation.Counterclockwise
       
  1346         \o Rotate counterclockwise between the two values
       
  1347     \row
       
  1348         \o RotationAnimation.Shortest
       
  1349         \o Rotate in the direction that produces the shortest animation path.
       
  1350            A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
  1456            A rotation from 10 to 350 will rotate 20 degrees counterclockwise.
  1351     \endtable
  1457     \endlist
  1352 
       
  1353     The default direction is RotationAnimation.Numerical.
       
  1354 */
  1458 */
  1355 QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const
  1459 QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const
  1356 {
  1460 {
  1357     Q_D(const QDeclarativeRotationAnimation);
  1461     Q_D(const QDeclarativeRotationAnimation);
  1358     return d->direction;
  1462     return d->direction;
  1430 
  1534 
  1431 /*!
  1535 /*!
  1432     \qmlclass SequentialAnimation QDeclarativeSequentialAnimation
  1536     \qmlclass SequentialAnimation QDeclarativeSequentialAnimation
  1433     \since 4.7
  1537     \since 4.7
  1434     \inherits Animation
  1538     \inherits Animation
  1435     \brief The SequentialAnimation element allows you to run animations sequentially.
  1539     \brief The SequentialAnimation element allows animations to be run sequentially.
  1436 
  1540 
  1437     Animations controlled in SequentialAnimation will be run one after the other.
  1541     The SequentialAnimation and ParallelAnimation elements allow multiple
  1438 
  1542     animations to be run together. Animations defined in a SequentialAnimation
  1439     The following example chains two numeric animations together.  The \c MyItem
  1543     are run one after the other, while animations defined in a ParallelAnimation
  1440     object will animate from its current x position to 100, and then back to 0.
  1544     are run at the same time.
  1441 
  1545 
  1442     \code
  1546     The following example runs two number animations in a sequence.  The \l Rectangle
  1443     SequentialAnimation {
  1547     animates to a \c x position of 50, then to a \c y position of 50.
  1444         NumberAnimation { target: MyItem; property: "x"; to: 100 }
  1548 
  1445         NumberAnimation { target: MyItem; property: "x"; to: 0 }
  1549     \snippet doc/src/snippets/declarative/sequentialanimation.qml 0
  1446     }
  1550 
  1447     \endcode
  1551     Animations defined within a \l Transition are automatically run in parallel,
  1448 
  1552     so SequentialAnimation can be used to enclose the animations in a \l Transition
  1449     \sa ParallelAnimation
  1553     if this is the preferred behavior.
       
  1554 
       
  1555     Like any other animation element, a SequentialAnimation can be applied in a
       
  1556     number of ways, including transitions, behaviors and property value 
       
  1557     sources. The \l PropertyAnimation documentation shows a variety of methods
       
  1558     for creating animations.
       
  1559 
       
  1560     \sa ParallelAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}
  1450 */
  1561 */
  1451 
  1562 
  1452 QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent) :
  1563 QDeclarativeSequentialAnimation::QDeclarativeSequentialAnimation(QObject *parent) :
  1453     QDeclarativeAnimationGroup(parent)
  1564     QDeclarativeAnimationGroup(parent)
  1454 {
  1565 {
  1492 
  1603 
  1493 /*!
  1604 /*!
  1494     \qmlclass ParallelAnimation QDeclarativeParallelAnimation
  1605     \qmlclass ParallelAnimation QDeclarativeParallelAnimation
  1495     \since 4.7
  1606     \since 4.7
  1496     \inherits Animation
  1607     \inherits Animation
  1497     \brief The ParallelAnimation element allows you to run animations in parallel.
  1608     \brief The ParallelAnimation element allows animations to be run in parallel.
  1498 
  1609 
  1499     Animations contained in ParallelAnimation will be run at the same time.
  1610     The SequentialAnimation and ParallelAnimation elements allow multiple
  1500 
  1611     animations to be run together. Animations defined in a SequentialAnimation
  1501     The following animation demonstrates animating the \c MyItem item
  1612     are run one after the other, while animations defined in a ParallelAnimation
  1502     to (100,100) by animating the x and y properties in parallel.
  1613     are run at the same time.
  1503 
  1614 
  1504     \code
  1615     The following animation runs two number animations in parallel. The \l Rectangle
  1505     ParallelAnimation {
  1616     moves to (50,50) by animating its \c x and \c y properties at the same time.
  1506         NumberAnimation { target: MyItem; property: "x"; to: 100 }
  1617 
  1507         NumberAnimation { target: MyItem; property: "y"; to: 100 }
  1618     \snippet doc/src/snippets/declarative/parallelanimation.qml 0
  1508     }
  1619 
  1509     \endcode
  1620     Like any other animation element, a ParallelAnimation can be applied in a
  1510 
  1621     number of ways, including transitions, behaviors and property value 
  1511     \sa SequentialAnimation
  1622     sources. The \l PropertyAnimation documentation shows a variety of methods
       
  1623     for creating animations.
       
  1624 
       
  1625     \sa SequentialAnimation, {QML Animation}, {declarative/animation/basics}{Animation basics example}
  1512 */
  1626 */
  1513 /*!
  1627 /*!
  1514     \internal
  1628     \internal
  1515     \class QDeclarativeParallelAnimation
  1629     \class QDeclarativeParallelAnimation
  1516 */
  1630 */
  1603 
  1717 
  1604 /*!
  1718 /*!
  1605     \qmlclass PropertyAnimation QDeclarativePropertyAnimation
  1719     \qmlclass PropertyAnimation QDeclarativePropertyAnimation
  1606     \since 4.7
  1720     \since 4.7
  1607     \inherits Animation
  1721     \inherits Animation
  1608     \brief The PropertyAnimation element allows you to animate property changes.
  1722     \brief The PropertyAnimation element animates changes in property values.
  1609 
  1723 
  1610     PropertyAnimation provides a way to animate changes to a property's value. It can
  1724     PropertyAnimation provides a way to animate changes to a property's value. 
  1611     be used in many different situations:
  1725 
       
  1726     It can be used to define animations in a number of ways:
       
  1727    
  1612     \list
  1728     \list
  1613     \o In a Transition
  1729     \o In a \l Transition
  1614 
  1730 
  1615     Animate any objects that have changed their x or y properties in the target state using
  1731     For example, to animate any objects that have changed their \c x or \c y properties 
  1616     an InOutQuad easing curve:
  1732     as a result of a state change, using an \c InOutQuad easing curve:
  1617     \qml
  1733 
  1618     Transition { PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad } }
  1734     \snippet doc/src/snippets/declarative/propertyanimation.qml transition
  1619     \endqml
  1735 
  1620     \o In a Behavior
  1736 
  1621 
  1737     \o In a \l Behavior
  1622     Animate all changes to a rectangle's x property.
  1738 
  1623     \qml
  1739     For example, to animate all changes to a rectangle's \c x property:
  1624     Rectangle {
  1740 
  1625         Behavior on x { PropertyAnimation {} }
  1741     \snippet doc/src/snippets/declarative/propertyanimation.qml behavior
  1626     }
  1742 
  1627     \endqml
  1743 
  1628     \o As a property value source
  1744     \o As a property value source
  1629 
  1745 
  1630     Repeatedly animate the rectangle's x property.
  1746     For example, to repeatedly animate the rectangle's \c x property:
  1631     \qml
  1747 
  1632     Rectangle {
  1748     \snippet doc/src/snippets/declarative/propertyanimation.qml propertyvaluesource
  1633         SequentialAnimation on x {
  1749 
  1634             loops: Animation.Infinite
  1750 
  1635             PropertyAnimation { to: 50 }
       
  1636             PropertyAnimation { to: 0 }
       
  1637         }
       
  1638     }
       
  1639     \endqml
       
  1640     \o In a signal handler
  1751     \o In a signal handler
  1641 
  1752 
  1642     Fade out \c theObject when clicked:
  1753     For example, to fade out \c theObject when clicked:
  1643     \qml
  1754     \qml
  1644     MouseArea {
  1755     MouseArea {
  1645         anchors.fill: theObject
  1756         anchors.fill: theObject
  1646         onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
  1757         onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 }
  1647     }
  1758     }
  1648     \endqml
  1759     \endqml
       
  1760 
  1649     \o Standalone
  1761     \o Standalone
  1650 
  1762 
  1651     Animate \c theObject's size property over 200ms, from its current size to 20-by-20:
  1763     For example, to animate \c rect's \c width property over 500ms, from its current width to 30:
  1652     \qml
  1764 
  1653     PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 }
  1765     \snippet doc/src/snippets/declarative/propertyanimation.qml standalone
  1654     \endqml
  1766 
  1655     \endlist
  1767     \endlist
  1656 
  1768 
  1657     Depending on how the animation is used, the set of properties normally used will be
  1769     Depending on how the animation is used, the set of properties normally used will be
  1658     different. For more information see the individual property documentation, as well
  1770     different. For more information see the individual property documentation, as well
  1659     as the \l{QML Animation} introduction.
  1771     as the \l{QML Animation} introduction.
       
  1772 
       
  1773     Note that PropertyAnimation inherits the abstract \l Animation element.
       
  1774     This includes additional properties and methods for controlling the animation.
       
  1775 
       
  1776     \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
  1660 */
  1777 */
  1661 
  1778 
  1662 QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QObject *parent)
  1779 QDeclarativePropertyAnimation::QDeclarativePropertyAnimation(QObject *parent)
  1663 : QDeclarativeAbstractAnimation(*(new QDeclarativePropertyAnimationPrivate), parent)
  1780 : QDeclarativeAbstractAnimation(*(new QDeclarativePropertyAnimationPrivate), parent)
  1664 {
  1781 {
  1732 }
  1849 }
  1733 
  1850 
  1734 /*!
  1851 /*!
  1735     \qmlproperty real PropertyAnimation::to
  1852     \qmlproperty real PropertyAnimation::to
  1736     This property holds the ending value.
  1853     This property holds the ending value.
  1737     If not set, then the value defined in the end state of the transition or Behavior.
  1854     If not set, then the value defined in the end state of the transition or \l Behavior.
  1738 */
  1855 */
  1739 QVariant QDeclarativePropertyAnimation::to() const
  1856 QVariant QDeclarativePropertyAnimation::to() const
  1740 {
  1857 {
  1741     Q_D(const QDeclarativePropertyAnimation);
  1858     Q_D(const QDeclarativePropertyAnimation);
  1742     return d->to;
  1859     return d->to;
  1759     \qmlproperty real PropertyAnimation::easing.period
  1876     \qmlproperty real PropertyAnimation::easing.period
  1760     \brief the easing curve used for the animation.
  1877     \brief the easing curve used for the animation.
  1761 
  1878 
  1762     To specify an easing curve you need to specify at least the type. For some curves you can also specify
  1879     To specify an easing curve you need to specify at least the type. For some curves you can also specify
  1763     amplitude, period and/or overshoot (more details provided after the table). The default easing curve is
  1880     amplitude, period and/or overshoot (more details provided after the table). The default easing curve is
  1764     Linear.
  1881     \c Easing.Linear.
  1765 
  1882 
  1766     \qml
  1883     \qml
  1767     PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 }
  1884     PropertyAnimation { properties: "y"; easing.type: Easing.InOutElastic; easing.amplitude: 2.0; easing.period: 1.5 }
  1768     \endqml
  1885     \endqml
  1769 
  1886 
  1936         \o \c Easing.OutInBounce
  2053         \o \c Easing.OutInBounce
  1937         \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
  2054         \o Easing curve for a bounce (exponentially decaying parabolic bounce) function easing out/in: deceleration until halfway, then acceleration.
  1938         \o \inlineimage qeasingcurve-outinbounce.png
  2055         \o \inlineimage qeasingcurve-outinbounce.png
  1939     \endtable
  2056     \endtable
  1940 
  2057 
  1941     easing.amplitude is only applicable for bounce and elastic curves (curves of type
  2058     \c easing.amplitude is only applicable for bounce and elastic curves (curves of type
  1942     Easing.InBounce, Easing.OutBounce, Easing.InOutBounce, Easing.OutInBounce, Easing.InElastic,
  2059     \c Easing.InBounce, \c Easing.OutBounce, \c Easing.InOutBounce, \c Easing.OutInBounce, \c Easing.InElastic,
  1943     Easing.OutElastic, Easing.InOutElastic or Easing.OutInElastic).
  2060     \c Easing.OutElastic, \c Easing.InOutElastic or \c Easing.OutInElastic).
  1944 
  2061 
  1945     easing.overshoot is only applicable if type is: Easing.InBack, Easing.OutBack,
  2062     \c easing.overshoot is only applicable if \c easing.type is: \c Easing.InBack, \c Easing.OutBack,
  1946     Easing.InOutBack or Easing.OutInBack.
  2063     \c Easing.InOutBack or \c Easing.OutInBack.
  1947 
  2064 
  1948     easing.period is only applicable if type is: Easing.InElastic, Easing.OutElastic,
  2065     \c easing.period is only applicable if easing.type is: \c Easing.InElastic, \c Easing.OutElastic,
  1949     Easing.InOutElastic or Easing.OutInElastic.
  2066     \c Easing.InOutElastic or \c Easing.OutInElastic.
  1950 
  2067 
  1951     See the \l {declarative/animation/easing}{easing} example for a demonstration of
  2068     See the \l {declarative/animation/easing}{easing} example for a demonstration of
  1952     the different easing settings.
  2069     the different easing settings.
  1953 */
  2070 */
  1954 QEasingCurve QDeclarativePropertyAnimation::easing() const
  2071 QEasingCurve QDeclarativePropertyAnimation::easing() const
  1955 {
  2072 {
  1956     Q_D(const QDeclarativePropertyAnimation);
  2073     Q_D(const QDeclarativePropertyAnimation);
  1957     return d->easing;
  2074     return d->va->easingCurve();
  1958 }
  2075 }
  1959 
  2076 
  1960 void QDeclarativePropertyAnimation::setEasing(const QEasingCurve &e)
  2077 void QDeclarativePropertyAnimation::setEasing(const QEasingCurve &e)
  1961 {
  2078 {
  1962     Q_D(QDeclarativePropertyAnimation);
  2079     Q_D(QDeclarativePropertyAnimation);
  1963     if (d->easing == e)
  2080     if (d->va->easingCurve() == e)
  1964         return;
  2081         return;
  1965 
  2082 
  1966     d->easing = e;
  2083     d->va->setEasingCurve(e);
  1967     d->va->setEasingCurve(d->easing);
       
  1968     emit easingChanged(e);
  2084     emit easingChanged(e);
  1969 }
  2085 }
  1970 
  2086 
  1971 QObject *QDeclarativePropertyAnimation::target() const
  2087 QObject *QDeclarativePropertyAnimation::target() const
  1972 {
  2088 {
  2030     NumberAnimation { targets: theItem; properties: "x"; to: 500 }
  2146     NumberAnimation { targets: theItem; properties: "x"; to: 500 }
  2031     \endqml
  2147     \endqml
  2032     The singular forms are slightly optimized, so if you do have only a single target/property
  2148     The singular forms are slightly optimized, so if you do have only a single target/property
  2033     to animate you should try to use them.
  2149     to animate you should try to use them.
  2034 
  2150 
  2035     In many cases these properties do not need to be explicitly specified -- they can be
  2151     In many cases these properties do not need to be explicitly specified, as they can be
  2036     inferred from the animation framework.
  2152     inferred from the animation framework:
       
  2153 
  2037     \table 80%
  2154     \table 80%
  2038     \row
  2155     \row
  2039     \o Value Source / Behavior
  2156     \o Value Source / Behavior
  2040     \o When an animation is used as a value source or in a Behavior, the default target and property
  2157     \o When an animation is used as a value source or in a Behavior, the default target and property
  2041        name to be animated can both be inferred.
  2158        name to be animated can both be inferred.
  2117 {
  2234 {
  2118     Q_D(QDeclarativePropertyAnimation);
  2235     Q_D(QDeclarativePropertyAnimation);
  2119     return d->va;
  2236     return d->va;
  2120 }
  2237 }
  2121 
  2238 
  2122 struct PropertyUpdater : public QDeclarativeBulkValueUpdater
  2239 void QDeclarativeAnimationPropertyUpdater::setValue(qreal v)
  2123 {
  2240 {
  2124     QDeclarativeStateActions actions;
  2241     bool deleted = false;
  2125     int interpolatorType;       //for Number/ColorAnimation
  2242     wasDeleted = &deleted;
  2126     int prevInterpolatorType;   //for generic
  2243     if (reverse)    //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
  2127     QVariantAnimation::Interpolator interpolator;
  2244         v = 1 - v;
  2128     bool reverse;
  2245     for (int ii = 0; ii < actions.count(); ++ii) {
  2129     bool fromSourced;
  2246         QDeclarativeAction &action = actions[ii];
  2130     bool fromDefined;
  2247 
  2131     bool *wasDeleted;
  2248         if (v == 1.)
  2132     PropertyUpdater() : prevInterpolatorType(0), wasDeleted(0) {}
  2249             QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
  2133     ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; }
  2250         else {
  2134     void setValue(qreal v)
  2251             if (!fromSourced && !fromDefined) {
  2135     {
  2252                 action.fromValue = action.property.read();
  2136         bool deleted = false;
  2253                 if (interpolatorType)
  2137         wasDeleted = &deleted;
  2254                     QDeclarativePropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
  2138         if (reverse)    //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1
  2255             }
  2139             v = 1 - v;
  2256             if (!interpolatorType) {
  2140         for (int ii = 0; ii < actions.count(); ++ii) {
  2257                 int propType = action.property.propertyType();
  2141             QDeclarativeAction &action = actions[ii];
  2258                 if (!prevInterpolatorType || prevInterpolatorType != propType) {
  2142 
  2259                     prevInterpolatorType = propType;
  2143             if (v == 1.)
  2260                     interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
  2144                 QDeclarativePropertyPrivate::write(action.property, action.toValue, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
       
  2145             else {
       
  2146                 if (!fromSourced && !fromDefined) {
       
  2147                     action.fromValue = action.property.read();
       
  2148                     if (interpolatorType)
       
  2149                         QDeclarativePropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType);
       
  2150                 }
  2261                 }
  2151                 if (!interpolatorType) {
       
  2152                     int propType = action.property.propertyType();
       
  2153                     if (!prevInterpolatorType || prevInterpolatorType != propType) {
       
  2154                         prevInterpolatorType = propType;
       
  2155                         interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType);
       
  2156                     }
       
  2157                 }
       
  2158                 if (interpolator)
       
  2159                     QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
       
  2160             }
  2262             }
  2161             if (deleted)
  2263             if (interpolator)
  2162                 return;
  2264                 QDeclarativePropertyPrivate::write(action.property, interpolator(action.fromValue.constData(), action.toValue.constData(), v), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
  2163         }
  2265         }
  2164         wasDeleted = 0;
  2266         if (deleted)
  2165         fromSourced = true;
  2267             return;
  2166     }
  2268     }
  2167 };
  2269     wasDeleted = 0;
       
  2270     fromSourced = true;
       
  2271 }
  2168 
  2272 
  2169 void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions,
  2273 void QDeclarativePropertyAnimation::transition(QDeclarativeStateActions &actions,
  2170                                      QDeclarativeProperties &modified,
  2274                                      QDeclarativeProperties &modified,
  2171                                      TransitionDirection direction)
  2275                                      TransitionDirection direction)
  2172 {
  2276 {
  2192 
  2296 
  2193     if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
  2297     if (props.isEmpty() && !d->defaultProperties.isEmpty()) {
  2194         props << d->defaultProperties.split(QLatin1Char(','));
  2298         props << d->defaultProperties.split(QLatin1Char(','));
  2195     }
  2299     }
  2196 
  2300 
  2197     PropertyUpdater *data = new PropertyUpdater;
  2301     QDeclarativeAnimationPropertyUpdater *data = new QDeclarativeAnimationPropertyUpdater;
  2198     data->interpolatorType = d->interpolatorType;
  2302     data->interpolatorType = d->interpolatorType;
  2199     data->interpolator = d->interpolator;
  2303     data->interpolator = d->interpolator;
  2200     data->reverse = direction == Backward ? true : false;
  2304     data->reverse = direction == Backward ? true : false;
  2201     data->fromSourced = false;
  2305     data->fromSourced = false;
  2202     data->fromDefined = d->fromIsDefined;
  2306     data->fromDefined = d->fromIsDefined;
  2280 
  2384 
  2281 /*!
  2385 /*!
  2282     \qmlclass ParentAnimation QDeclarativeParentAnimation
  2386     \qmlclass ParentAnimation QDeclarativeParentAnimation
  2283     \since 4.7
  2387     \since 4.7
  2284     \inherits Animation
  2388     \inherits Animation
  2285     \brief The ParentAnimation element allows you to animate parent changes.
  2389     \brief The ParentAnimation element animates changes in parent values.
  2286 
  2390 
  2287     ParentAnimation is used in conjunction with NumberAnimation to smoothly
  2391     ParentAnimation defines an animation to applied when a ParentChange
  2288     animate changing an item's parent. In the following example,
  2392     occurs. This allows parent changes to be smoothly animated.
  2289     ParentAnimation wraps a NumberAnimation which animates from the
  2393 
  2290     current position in the old parent to the new position in the new
  2394     For example, the following ParentChange changes \c blueRect to become
  2291     parent.
  2395     a child of \c redRect when it is clicked. The inclusion of the 
  2292 
  2396     ParentAnimation, which defines a NumberAnimation to be applied during
  2293     \qml
  2397     the transition, ensures the item animates smoothly as it moves to
  2294     ...
  2398     its new parent:
  2295     State {
  2399 
  2296         //reparent myItem to newParent. myItem's final location
  2400     \snippet doc/src/snippets/declarative/parentanimation.qml 0
  2297         //should be 10,10 in newParent.
  2401 
  2298         ParentChange {
  2402     A ParentAnimation can contain any number of animations. These animations will
  2299             target: myItem
  2403     be run in parallel; to run them sequentially, define them within a
  2300             parent: newParent
  2404     SequentialAnimation.
  2301             x: 10; y: 10
  2405 
  2302         }
  2406     In some cases, such as when reparenting between items with clipping enabled, it is useful
  2303     }
  2407     to animate the parent change via another item that does not have clipping
  2304     ...
  2408     enabled. Such an item can be set using the \l via property.
  2305     Transition {
  2409 
  2306         //smoothly reparent myItem and move into new position
  2410     By default, when used in a transition, ParentAnimation animates all parent 
  2307         ParentAnimation {
  2411     changes. This can be overriden by setting a specific target item using the
  2308             target: theItem
  2412     \l target property.
  2309             NumberAnimation { properties: "x,y" }
  2413 
  2310         }
  2414     \sa {QML Animation}, {declarative/animation/basics}{Animation basics example}
  2311     }
       
  2312     \endqml
       
  2313 
       
  2314     ParentAnimation can wrap any number of animations -- those animations will
       
  2315     be run in parallel (like those in a ParallelAnimation group).
       
  2316 
       
  2317     In some cases, such as reparenting between items with clipping, it's useful
       
  2318     to animate the parent change via another item with no clipping.
       
  2319 
       
  2320     When used in a transition, ParentAnimation will by default animate
       
  2321     all ParentChanges.
       
  2322 */
  2415 */
  2323 
  2416 
  2324 /*!
  2417 /*!
  2325     \internal
  2418     \internal
  2326     \class QDeclarativeParentAnimation
  2419     \class QDeclarativeParentAnimation
  2351 
  2444 
  2352 /*!
  2445 /*!
  2353     \qmlproperty Item ParentAnimation::target
  2446     \qmlproperty Item ParentAnimation::target
  2354     The item to reparent.
  2447     The item to reparent.
  2355 
  2448 
  2356     When used in a transition, if no target is specified all
  2449     When used in a transition, if no target is specified, all
  2357     ParentChanges will be animated by the ParentAnimation.
  2450     ParentChange occurrences are animated by the ParentAnimation.
  2358 */
  2451 */
  2359 QDeclarativeItem *QDeclarativeParentAnimation::target() const
  2452 QDeclarativeItem *QDeclarativeParentAnimation::target() const
  2360 {
  2453 {
  2361     Q_D(const QDeclarativeParentAnimation);
  2454     Q_D(const QDeclarativeParentAnimation);
  2362     return d->target;
  2455     return d->target;
  2395 }
  2488 }
  2396 
  2489 
  2397 /*!
  2490 /*!
  2398     \qmlproperty Item ParentAnimation::via
  2491     \qmlproperty Item ParentAnimation::via
  2399     The item to reparent via. This provides a way to do an unclipped animation
  2492     The item to reparent via. This provides a way to do an unclipped animation
  2400     when both the old parent and new parent are clipped
  2493     when both the old parent and new parent are clipped.
  2401 
  2494 
  2402     \qml
  2495     \qml
  2403     ParentAnimation {
  2496     ParentAnimation {
  2404         target: myItem
  2497         target: myItem
  2405         via: topLevelItem
  2498         via: topLevelItem
  2645 
  2738 
  2646 /*!
  2739 /*!
  2647     \qmlclass AnchorAnimation QDeclarativeAnchorAnimation
  2740     \qmlclass AnchorAnimation QDeclarativeAnchorAnimation
  2648     \since 4.7
  2741     \since 4.7
  2649     \inherits Animation
  2742     \inherits Animation
  2650     \brief The AnchorAnimation element allows you to animate anchor changes.
  2743     \brief The AnchorAnimation element animates changes in anchor values.
  2651 
  2744 
  2652     AnchorAnimation will animated any changes specified by a state's AnchorChanges.
  2745     AnchorAnimation is used to animate an AnchorChange. It will anchor all
  2653     In the following snippet we animate the addition of a right anchor to our item.
  2746     anchor changes specified in a \l State.
  2654     \qml
  2747 
  2655     Item {
  2748     In the following snippet we animate the addition of a right anchor to a \l Rectangle:
  2656         id: myItem
  2749 
  2657         width: 100
  2750     \snippet doc/src/snippets/declarative/anchoranimation.qml 0
  2658     }
       
  2659     ...
       
  2660     State {
       
  2661         AnchorChanges {
       
  2662             target: myItem
       
  2663             anchors.right: container.right
       
  2664         }
       
  2665     }
       
  2666     ...
       
  2667     Transition {
       
  2668         //smoothly reanchor myItem and move into new position
       
  2669         AnchorAnimation {}
       
  2670     }
       
  2671     \endqml
       
  2672 
  2751 
  2673     \sa AnchorChanges
  2752     \sa AnchorChanges
  2674 */
  2753 */
  2675 
  2754 
  2676 QDeclarativeAnchorAnimation::QDeclarativeAnchorAnimation(QObject *parent)
  2755 QDeclarativeAnchorAnimation::QDeclarativeAnchorAnimation(QObject *parent)
  2769                         QDeclarativeProperties &modified,
  2848                         QDeclarativeProperties &modified,
  2770                         TransitionDirection direction)
  2849                         TransitionDirection direction)
  2771 {
  2850 {
  2772     Q_UNUSED(modified);
  2851     Q_UNUSED(modified);
  2773     Q_D(QDeclarativeAnchorAnimation);
  2852     Q_D(QDeclarativeAnchorAnimation);
  2774     PropertyUpdater *data = new PropertyUpdater;
  2853     QDeclarativeAnimationPropertyUpdater *data = new QDeclarativeAnimationPropertyUpdater;
  2775     data->interpolatorType = QMetaType::QReal;
  2854     data->interpolatorType = QMetaType::QReal;
  2776     data->interpolator = d->interpolator;
  2855     data->interpolator = d->interpolator;
  2777 
  2856 
  2778     data->reverse = direction == Backward ? true : false;
  2857     data->reverse = direction == Backward ? true : false;
  2779     data->fromSourced = false;
  2858     data->fromSourced = false;