src/corelib/animation/qvariantanimation.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   102         \o \l{QMetaType::}{Double}
   102         \o \l{QMetaType::}{Double}
   103         \o \l{QMetaType::}{Float}
   103         \o \l{QMetaType::}{Float}
   104         \o \l{QMetaType::}{QLine}
   104         \o \l{QMetaType::}{QLine}
   105         \o \l{QMetaType::}{QLineF}
   105         \o \l{QMetaType::}{QLineF}
   106         \o \l{QMetaType::}{QPoint}
   106         \o \l{QMetaType::}{QPoint}
       
   107         \o \l{QMetaType::}{QPointF}
   107         \o \l{QMetaType::}{QSize}
   108         \o \l{QMetaType::}{QSize}
   108         \o \l{QMetaType::}{QSizeF}
   109         \o \l{QMetaType::}{QSizeF}
   109         \o \l{QMetaType::}{QRect}
   110         \o \l{QMetaType::}{QRect}
   110         \o \l{QMetaType::}{QRectF}
   111         \o \l{QMetaType::}{QRectF}
       
   112         \o \l{QMetaType::}{QColor}
   111     \endlist
   113     \endlist
   112 
   114 
   113     If you need to interpolate other variant types, including custom
   115     If you need to interpolate other variant types, including custom
   114     types, you have to implement interpolation for these yourself.
   116     types, you have to implement interpolation for these yourself.
   115     You do this by reimplementing interpolated(), which returns
   117     To do this, you can register an interpolator function for a given
       
   118     type. This function takes 3 parameters: the start value, the end value
       
   119     and the current progress.
       
   120 
       
   121     Example:
       
   122     \code
       
   123         QVariant myColorInterpolator(const QColor &start, const QColor &end, qreal progress)
       
   124         {
       
   125             ...
       
   126             return QColor(...);
       
   127         }
       
   128         ...
       
   129         qRegisterAnimationInterpolator<QColor>(myColorInterpolator);
       
   130     \endcode
       
   131 
       
   132     Another option is to reimplement interpolated(), which returns
   116     interpolation values for the value being interpolated.
   133     interpolation values for the value being interpolated.
   117 
   134 
   118     \omit We need some snippets around here. \endomit
   135     \omit We need some snippets around here. \endomit
   119 
   136 
   120     \sa QPropertyAnimation, QAbstractAnimation, {The Animation Framework}
   137     \sa QPropertyAnimation, QAbstractAnimation, {The Animation Framework}
   354     interpolation. Other curves are provided, for instance,
   371     interpolation. Other curves are provided, for instance,
   355     QEasingCurve::InCirc, which provides a circular entry curve.
   372     QEasingCurve::InCirc, which provides a circular entry curve.
   356     Another example is QEasingCurve::InOutElastic, which provides an
   373     Another example is QEasingCurve::InOutElastic, which provides an
   357     elastic effect on the values of the interpolated variant.
   374     elastic effect on the values of the interpolated variant.
   358 
   375 
       
   376     QVariantAnimation will use the QEasingCurve::valueForProgress() to
       
   377     transform the "normalized progress" (currentTime / totalDuration)
       
   378     of the animation into the effective progress actually
       
   379     used by the animation. It is this effective progress that will be
       
   380     the progress when interpolated() is called. Also, the steps in the
       
   381     keyValues are referring to this effective progress.
       
   382 
   359     The easing curve is used with the interpolator, the interpolated()
   383     The easing curve is used with the interpolator, the interpolated()
   360     virtual function, the animation's duration, and iterationCount, to
   384     virtual function, the animation's duration, and iterationCount, to
   361     control how the current value changes as the animation progresses.
   385     control how the current value changes as the animation progresses.
   362 */
   386 */
   363 QEasingCurve QVariantAnimation::easingCurve() const
   387 QEasingCurve QVariantAnimation::easingCurve() const
   619 }
   643 }
   620 
   644 
   621 /*!
   645 /*!
   622     \reimp
   646     \reimp
   623 */
   647 */
   624 void QVariantAnimation::updateState(QAbstractAnimation::State oldState,
   648 void QVariantAnimation::updateState(QAbstractAnimation::State newState,
   625                                     QAbstractAnimation::State newState)
   649                                     QAbstractAnimation::State oldState)
   626 {
   650 {
   627     Q_UNUSED(oldState);
   651     Q_UNUSED(oldState);
   628     Q_UNUSED(newState);
   652     Q_UNUSED(newState);
   629 }
   653 }
   630 
   654