42 #include "private/qdeclarativeanimation_p.h" 43 #include "private/qdeclarativeanimation_p_p.h" 45 #include "private/qdeclarativebehavior_p.h" 46 #include "private/qdeclarativestateoperations_p.h" 47 #include "private/qdeclarativecontext_p.h" 63 #include <QParallelAnimationGroup> 64 #include <QSequentialAnimationGroup> 65 #include <QtCore/qset.h> 66 #include <QtCore/qrect.h> 67 #include <QtCore/qpoint.h> 68 #include <QtCore/qsize.h> 69 #include <QtCore/qmath.h> 71 #include <private/qvariantanimation_p.h> 151 if (
d->disableUserControl &&
d->running != running) {
167 q->qtAnimation()->start();
193 d->avoidPropertyValueSourceStart =
true;
194 else if (!
d->registered) {
195 d->registered =
true;
205 if (
d->group ||
d->disableUserControl) {
206 qmlInfo(
this) <<
"setRunning() cannot be used on non-root animation nodes.";
212 bool supressStart =
false;
213 if (
d->alwaysRunToEnd &&
d->loopCount != 1
216 if (
d->loopCount == -1)
223 if (!
d->connectedTimeLine) {
226 d->connectedTimeLine =
true;
232 if (
d->alwaysRunToEnd) {
233 if (
d->loopCount != 1)
271 if (
d->group ||
d->disableUserControl) {
272 qmlInfo(
this) <<
"setPaused() cannot be used on non-root animation nodes.";
328 return d->alwaysRunToEnd;
334 if (
d->alwaysRunToEnd == f)
337 d->alwaysRunToEnd = f;
379 if (loops ==
d->loopCount)
414 if (
d->group && !static_cast<QDeclarativeAnimationGroupPrivate *>(
d->group->d_func())->animations.contains(
this))
415 static_cast<QDeclarativeAnimationGroupPrivate *>(
d->group->d_func())->animations.append(
this);
541 d->defaultProperty = p;
543 if (!
d->avoidPropertyValueSourceStart)
555 d->defaultProperty = p;
566 d->disableUserControl =
true;
582 if (
d->alwaysRunToEnd &&
d->loopCount != 1) {
642 return d->pa->duration();
648 qmlInfo(
this) <<
tr(
"Cannot set a duration of < 0");
655 d->pa->setDuration(duration);
703 d->defaultToInterpolatorType =
true;
742 return d->from.value<
QColor>();
874 if (hasRunScriptScript && reversing)
883 if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
884 expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
898 d->hasRunScriptScript =
false;
900 for (
int ii = 0; ii < actions.
count(); ++ii) {
906 d->hasRunScriptScript =
true;
1000 return d->propertyName;
1006 if (
d->propertyName == n)
1008 d->propertyName = n;
1033 return d->properties;
1039 if (
d->properties == p)
1087 if (
d->value.isNull ||
d->value != v) {
1109 virtual void doAction()
1111 for (
int ii = 0; ii < actions.
count(); ++ii) {
1119 for (
int ii = 0; ii < props.
count(); ++ii)
1121 if (!
d->propertyName.isEmpty())
1122 props <<
d->propertyName;
1128 bool hasSelectors = !props.
isEmpty() || !
targets.isEmpty() || !
d->exclude.isEmpty();
1130 if (
d->defaultProperty.isValid() && !hasSelectors) {
1131 props <<
d->defaultProperty.name();
1132 targets <<
d->defaultProperty.object();
1135 QDeclarativeSetPropertyAnimationAction *
data =
new QDeclarativeSetPropertyAnimationAction;
1137 bool hasExplicit =
false;
1139 if (
d->value.isValid()) {
1140 for (
int i = 0; i < props.
count(); ++i) {
1147 data->actions << myAction;
1149 for (
int ii = 0; ii < actions.
count(); ++ii) {
1163 for (
int ii = 0; ii < actions.
count(); ++ii) {
1170 bool same = (obj == sObj);
1173 (!
d->exclude.contains(obj)) && (same || (!
d->exclude.contains(sObj))) &&
1174 (props.
contains(propertyName) || (!same && props.
contains(sPropertyName)))) {
1177 if (
d->value.isValid())
1182 data->actions << myAction;
1187 if (data->actions.count()) {
1280 return d->from.toReal();
1305 return d->to.toReal();
1341 d->defaultToInterpolatorType =
true;
1447 while(diff > 180.0){
1451 while(diff < -180.0){
1455 return QVariant(f + (newt - f) * progress);
1466 return QVariant(f + (newt - f) * progress);
1477 return QVariant(f + (newt - f) * progress);
1525 return d->from.toReal();
1550 return d->to.toReal();
1579 return d->direction;
1585 if (
d->direction == direction)
1589 switch(
d->direction) {
1637 q->d_func()->ag->removeAnimation(firstAnim->
qtAnimation());
1720 from =
d->animations.count() - 1;
1723 bool valid =
d->defaultProperty.isValid();
1724 for (
int ii = from; ii <
d->animations.count() && ii >= 0; ii += inc) {
1726 d->animations.at(ii)->setDefaultTarget(
d->defaultProperty);
1727 d->animations.at(ii)->transition(actions, modified, direction);
1787 bool valid =
d->defaultProperty.isValid();
1788 for (
int ii = 0; ii <
d->animations.count(); ++ii) {
1790 d->animations.at(ii)->setDefaultTarget(
d->defaultProperty);
1791 d->animations.at(ii)->transition(actions, modified, direction);
1844 variant = converter(variant.
toString());
1952 return d->va->duration();
1958 qmlInfo(
this) <<
tr(
"Cannot set a duration of < 0");
1965 d->va->setDuration(duration);
1992 if (
d->fromIsDefined && f ==
d->from)
2022 if (
d->toIsDefined && t ==
d->to)
2234 return d->va->easingCurve();
2240 if (
d->va->easingCurve() == e)
2243 d->va->setEasingCurve(e);
2265 return d->propertyName;
2271 if (
d->propertyName == n)
2273 d->propertyName = n;
2280 return d->properties;
2286 if (
d->properties == prop)
2289 d->properties = prop;
2414 bool deleted =
false;
2415 wasDeleted = &deleted;
2418 for (
int ii = 0; ii < actions.count(); ++ii) {
2424 if (!fromSourced && !fromDefined) {
2426 if (interpolatorType)
2429 if (!interpolatorType) {
2431 if (!prevInterpolatorType || prevInterpolatorType != propType) {
2432 prevInterpolatorType = propType;
2453 for (
int ii = 0; ii < props.
count(); ++ii)
2455 if (!
d->propertyName.isEmpty())
2456 props <<
d->propertyName;
2462 bool hasSelectors = !props.
isEmpty() || !
targets.isEmpty() || !
d->exclude.isEmpty();
2463 bool useType = (props.
isEmpty() &&
d->defaultToInterpolatorType) ?
true :
false;
2465 if (
d->defaultProperty.isValid() && !hasSelectors) {
2466 props <<
d->defaultProperty.name();
2467 targets <<
d->defaultProperty.object();
2470 if (props.
isEmpty() && !
d->defaultProperties.isEmpty()) {
2481 bool hasExplicit =
false;
2483 if (
d->toIsDefined) {
2484 for (
int i = 0; i < props.
count(); ++i) {
2489 if (
d->fromIsDefined) {
2497 for (
int ii = 0; ii < actions.
count(); ++ii) {
2511 for (
int ii = 0; ii < actions.
count(); ++ii) {
2518 bool same = (obj == sObj);
2521 (!
d->exclude.contains(obj)) && (same || (!
d->exclude.contains(sObj))) &&
2526 if (
d->fromIsDefined)
2544 if (!
d->rangeIsSet) {
2545 d->va->setStartValue(
qreal(0));
2546 d->va->setEndValue(
qreal(1));
2547 d->rangeIsSet =
true;
2554 d->va->setFromSourcedValue(0);
2609 d->topLevelGroup->addAnimation(
d->startAction);
2613 d->topLevelGroup->addAnimation(
d->ag);
2617 d->topLevelGroup->addAnimation(
d->endAction);
2643 if (target ==
d->target)
2665 return d->newParent;
2671 if (newParent ==
d->newParent)
2718 return QPointF(width / 2., 0);
2722 return QPointF(0, height / 2.);
2724 return QPointF(width / 2., height / 2.);
2726 return QPointF(width, height / 2.);
2730 return QPointF(width / 2., height);
2732 return QPointF(width, height);
2744 QDeclarativeParentAnimationData() {}
2745 ~QDeclarativeParentAnimationData() {
qDeleteAll(pc); }
2751 virtual void doAction()
2753 for (
int ii = 0; ii < actions.
count(); ++ii) {
2763 QDeclarativeParentAnimationData *
data =
new QDeclarativeParentAnimationData;
2764 QDeclarativeParentAnimationData *viaData =
new QDeclarativeParentAnimationData;
2766 bool hasExplicit =
false;
2767 if (
d->target &&
d->newParent) {
2768 data->reverse =
false;
2773 myAction.
event = pc;
2775 data->actions << myAction;
2778 viaData->reverse =
false;
2783 myVAction.
event = vpc;
2785 viaData->actions << myVAction;
2792 for (
int i = 0; i < actions.
size(); ++i) {
2805 epc->
setObject(static_cast<QDeclarativeParentChange*>(action.
event)->object());
2807 myAction.
event = epc;
2809 data->actions << myAction;
2813 data->actions << myAction;
2817 viaData->reverse =
false;
2822 myAction.
event = vpc;
2824 viaData->actions << myAction;
2844 if (ok && !isRotate) {
2845 if (transform.
m11() == transform.
m22())
2846 scale = transform.
m11();
2851 }
else if (ok && isRotate) {
2852 if (transform.
m11() == transform.
m22())
2853 scale =
qSqrt(transform.
m11()*transform.
m11() + transform.
m12()*transform.
m12());
2860 rotation = atan2(transform.
m12()/scale, transform.
m11()/scale) * 180/
qreal(
M_PI);
2874 w = actions[++i].toValue.toReal();
2876 h = actions[++i].toValue.toReal();
2877 const QPointF &transformOrigin
2879 qreal tempxt = transformOrigin.
x();
2880 qreal tempyt = transformOrigin.
y();
2884 t.
scale(scale, scale);
2902 if (data->actions.count()) {
2918 bool valid =
d->defaultProperty.isValid();
2919 for (
int ii = 0; ii <
d->animations.count(); ++ii) {
2921 d->animations.at(ii)->setDefaultTarget(
d->defaultProperty);
2922 d->animations.at(ii)->transition(actions, modified, direction);
2930 return d->topLevelGroup;
3008 return d->va->duration();
3014 qmlInfo(
this) <<
tr(
"Cannot set a duration of < 0");
3021 d->va->setDuration(duration);
3050 return d->va->easingCurve();
3056 if (
d->va->easingCurve() == e)
3059 d->va->setEasingCurve(e);
3077 for (
int ii = 0; ii < actions.
count(); ++ii) {
3080 && (
d->targets.isEmpty() ||
d->targets.contains(static_cast<QDeclarativeAnchorChanges*>(action.
event)->object()))) {
3086 if (!
d->rangeIsSet) {
3087 d->va->setStartValue(
qreal(0));
3088 d->va->setEndValue(
qreal(1));
3089 d->rangeIsSet =
true;
The QVariant class acts like a union for the most common Qt data types.
The QColor class provides colors based on RGB, HSV or CMYK values.
virtual ~QDeclarativePropertyAnimation()
void durationChanged(int)
The QVector3D class represents a vector or vertex in 3D space.
static QDeclarativeData * get(const QObject *object, bool create=false)
QColor Q_DECLARATIVE_PRIVATE_EXPORT colorFromString(const QString &, bool *ok=0)
QDeclarativeProperty property
virtual ~QDeclarativeParentAnimation()
QDeclarativeParallelAnimation(QObject *parent=0)
QDeclarativeContext * context() const
Returns the context for the script.
#define QT_END_NAMESPACE
This macro expands to.
void setLoopCount(int loopCount)
void durationChanged(int)
QDeclarativeParserStatus ** d
void easingChanged(const QEasingCurve &)
The QEasingCurve class provides easing curves for controlling animation.
void runningChanged(bool)
QString properties() const
void setGroup(QDeclarativeAnimationGroup *)
QDeclarativeListProperty< QObject > exclude()
QTransform itemTransform(const QGraphicsItem *other, bool *ok=0) const
Returns a QTransform that maps coordinates from this item to other.
void alwaysRunToEndChanged(bool)
void setParent(QDeclarativeItem *)
QDeclarativeAbstractAnimation(QObject *parent=0)
The QSequentialAnimationGroup class provides a sequential group of animations.
virtual ~QDeclarativeScriptAction()
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
virtual ~QDeclarativeSequentialAnimation()
static C reverse(const C &l)
void setTo(const QColor &)
The QPointF class defines a point in the plane using floating point precision.
QVector3D Q_DECLARATIVE_PRIVATE_EXPORT vector3DFromString(const QString &, bool *ok=0)
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
The QPauseAnimation class provides a pause for QSequentialAnimationGroup.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
void setFrom(const QColor &)
void easingChanged(const QEasingCurve &)
void setScript(const QDeclarativeScriptString &)
TransformOrigin transformOrigin
Returns the current transform origin.
QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setTarget(QObject *)
virtual ~QDeclarativeAbstractAnimation()
QEasingCurve easing() const
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
static Q_CORE_EXPORT QVariantAnimation::Interpolator getInterpolator(int interpolationType)
void setDisableUserControl()
The QString class provides a Unicode character string.
void resume()
Resumes the animation after it was paused.
T * qobject_cast(QObject *object)
QString properties() const
virtual QAbstractAnimation * qtAnimation()
void setValue(const T &value)
Stores a copy of value.
The QObject class is the base class of all Qt objects.
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
void setNewParent(QDeclarativeItem *)
bool isValid() const
Returns true if the QDeclarativeProperty refers to a valid property, otherwise false.
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
virtual void setTarget(const QDeclarativeProperty &)
Set the target property for the value source.
QDeclarativeItem * via() const
QVariant(* Interpolator)(const void *from, const void *to, qreal progress)
void stop()
Stops the animation.
QRectF Q_DECLARATIVE_PRIVATE_EXPORT rectFFromString(const QString &, bool *ok=0)
void classBegin()
Invoked after class creation, but before any properties have been set.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
virtual ~QDeclarativeNumberAnimation()
qreal x() const
Returns the x-coordinate of this point.
void setParent(QObject *)
Makes the object a child of parent.
QDeclarativeListProperty< QObject > targets()
void setFrom(const QVariant &)
virtual void componentComplete()=0
Invoked after the root component that caused this instantiation has completed construction.
QDeclarativeAnchorAnimation(QObject *parent=0)
virtual void setDuration(int)
QObject * object() const
Returns the QDeclarativeProperty's QObject.
virtual ~QDeclarativeColorAnimation()
virtual QAbstractAnimation * qtAnimation()
void componentFinalized()
int currentLoopTime() const
Returns the current time inside the current loop.
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual QAbstractAnimation * qtAnimation()
QDeclarativeParentAnimation(QObject *parent=0)
void propertiesChanged(const QString &)
void fromChanged(QVariant)
The QDeclarativeScriptString class encapsulates a script and its context.
QEasingCurve easing() const
QDeclarativeItem * object() const
void setAlwaysRunToEnd(bool)
QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
QPointF Q_DECLARATIVE_PRIVATE_EXPORT pointFFromString(const QString &, bool *ok=0)
The QDeclarativeItem class provides the most basic of all visual items in QML.
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setEasing(const QEasingCurve &)
QDeclarativePauseAnimation(QObject *parent=0)
virtual ~QDeclarativePauseAnimation()
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
static const char * data(const QByteArray &arr)
void setProperties(const QString &)
void setTarget(QDeclarativeItem *)
virtual void execute(Reason reason=ActualChange)
Type
This enum type defines the types of variable that a QVariant can contain.
void setProperty(const QString &)
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
virtual QAbstractAnimation * qtAnimation()
RotationDirection direction() const
void setDirection(RotationDirection direction)
void registerFinalizedParserStatusObject(QObject *obj, int index)
The QAbstractAnimation class is the base of all animations.
void valueChanged(const QVariant &)
virtual ~QDeclarativeVector3dAnimation()
QDeclarativePropertyAction(QObject *parent=0)
virtual QString typeName() const
QString stateChangeScriptName() const
QDeclarativeListProperty< QObject > targets()
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
bool convert(Type t)
Casts the variant to the requested type, t.
void setDefaultTarget(const QDeclarativeProperty &)
QPointF computeTransformOrigin(QDeclarativeItem::TransformOrigin origin, qreal width, qreal height) const
static void append_animation(QDeclarativeListProperty< QDeclarativeAbstractAnimation > *list, QDeclarativeAbstractAnimation *role)
QDeclarativePropertyAnimation(QObject *parent=0)
void setTarget(QObject *)
void setValue(const QVariant &)
QVariantAnimation::Interpolator interpolator
void componentComplete()
Invoked after the root component that caused this instantiation has completed construction.
static QDeclarativeProperty createProperty(QObject *obj, const QString &str, QObject *infoObj)
QDeclarativeItem * newParent() const
virtual QAbstractAnimation * qtAnimation()
QSizeF Q_DECLARATIVE_PRIVATE_EXPORT sizeFFromString(const QString &, bool *ok=0)
QDeclarativeAnimationGroup(QObject *parent)
void durationChanged(int)
TransformOrigin
Controls the point about which simple transforms like scale apply.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
int userType() const
Returns the storage type of the value stored in the variant.
The QParallelAnimationGroup class provides a parallel group of animations.
void setProperty(const QString &)
virtual QAbstractAnimation * qtAnimation()=0
int propertyType() const
Returns the QVariant type of the property, or QVariant::Invalid if the property has no QVariant type...
QDeclarativeRotationAnimation(QObject *parent=0)
void loopCountChanged(int)
QDeclarativeAnimationGroup * group() const
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)
QDeclarativeListProperty< QObject > exclude()
void notifyRunningChanged(bool running)
static bool isValueType(int)
QDeclarativeListProperty< QDeclarativeItem > targets()
QDeclarativeScriptAction(QObject *parent=0)
QDeclarativeItem * target() const
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
void setVia(QDeclarativeItem *)
QObject * parent() const
Returns a pointer to the parent object.
const void * constData() const
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
void setObject(QDeclarativeItem *)
QDeclarativeNumberAnimation(QObject *parent=0)
QObject * specifiedObject
int size() const
Returns the number of items in the list.
void setStateChangeScriptName(const QString &)
virtual ~QDeclarativeAnchorAnimation()
if(void) toggleToolbarShown
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
void pause()
Pauses the animation.
bool isWritable() const
Returns true if the property is writable, otherwise false.
virtual int duration() const
QObject * scopeObject() const
Returns the scope object for the script.
void setTo(const QVariant &)
static const QCssKnownValue properties[NumProperties - 1]
bool alwaysRunToEnd() const
qreal y() const
Returns the y-coordinate of this point.
static void clear_animation(QDeclarativeListProperty< QDeclarativeAbstractAnimation > *list)
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
QString specifiedProperty
virtual QAbstractAnimation * qtAnimation()
QDeclarativeActionEvent * event
QDeclarativeListProperty< QDeclarativeAbstractAnimation > animations
QDeclarativeScriptActionPrivate()
void propertiesChanged(const QString &)
bool rotationIsSet() const
The QDeclarativeExpression class evaluates JavaScript in a QML context.
QDeclarativeInfo qmlInfo(const QObject *me)
virtual ~QDeclarativeRotationAnimation()
QDeclarativeColorAnimation(QObject *parent=0)
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
virtual void transition(QDeclarativeStateActions &actions, QDeclarativeProperties &modified, TransitionDirection direction)
QString name() const
Return the name of this QML property.
virtual QAbstractAnimation * qtAnimation()
virtual ~QDeclarativeParallelAnimation()
virtual ~QDeclarativePropertyAction()
static void convertVariant(QVariant &variant, int type)
QDeclarativeListProperty< QDeclarativeAbstractAnimation > animations()
virtual ~QDeclarativeAnimationGroup()
QDeclarativeItem * parent
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void setCurrentTime(int msecs)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
QDeclarativeScriptString script() const
virtual void reverse(Reason reason=ActualChange)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
virtual QAbstractAnimation * qtAnimation()
QDeclarativeSequentialAnimation(QObject *parent=0)
QDeclarativeVector3dAnimation(QObject *parent=0)
QString script() const
Returns the script text.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
qreal toReal(bool *ok=0) const
Returns the variant as a qreal if the variant has type() Double , QMetaType::Float ...
QDeclarativeItem * originalParent() const
void setProperties(const QString &)
QVariant read() const
Returns the property value.
QDeclarativeStateActions actions
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)
Qt::LayoutDirection direction
void setEasing(const QEasingCurve &)