8#include <private/qqmlproperty_p.h>
9#if QT_CONFIG(quick_path)
10#include <private/qquickpath_p.h>
12#include "private/qparallelanimationgroupjob_p.h"
13#include "private/qsequentialanimationgroupjob_p.h"
15#include <QtCore/qmath.h>
16#include <QtGui/qtransform.h>
17#include <QtQml/qqmlinfo.h>
196 bool hasExplicit =
false;
197 if (
d->target &&
d->newParent) {
198 data->reverse =
false;
208 viaData->reverse =
false;
213 myVAction.
event = vpc;
222 for (
int i = 0;
i < actions.
size(); ++
i) {
247 viaData->reverse =
false;
267 qmlWarning(
this) << QQuickParentAnimation::tr(
"Unable to preserve appearance under complex transform");
274 if (
ok && !isRotate) {
278 qmlWarning(
this) << QQuickParentAnimation::tr(
"Unable to preserve appearance under non-uniform scale");
281 }
else if (
ok && isRotate) {
285 qmlWarning(
this) << QQuickParentAnimation::tr(
"Unable to preserve appearance under non-uniform scale");
292 qmlWarning(
this) << QQuickParentAnimation::tr(
"Unable to preserve appearance under scale of 0");
308 =
d->computeTransformOrigin(
target->transformOrigin(),
w,
h);
309 qreal tempxt = transformOrigin.
x();
310 qreal tempyt = transformOrigin.
y();
312 t.translate(-tempxt, -tempyt);
315 t.translate(tempxt, tempyt);
332 if (
data->actions.size()) {
344 bool valid =
d->defaultProperty.isValid();
346 for (
int ii = 0; ii <
d->animations.size(); ++ii) {
348 d->animations.at(ii)->setDefaultTarget(
d->defaultProperty);
349 anim =
d->animations.at(ii)->transition(actions, modified,
direction, defaultTarget);
486 data->interpolator =
d->interpolator;
488 data->fromIsSourced =
false;
489 data->fromIsDefined =
false;
491 for (
int ii = 0; ii < actions.
size(); ++ii) {
500 if (
data->actions.size()) {
513#if QT_CONFIG(quick_path)
545QQuickPathAnimation::~QQuickPathAnimation()
549 Q_D(QQuickPathAnimation);
550 for (ActiveAnimationsIt
it =
d->activeAnimations.begin(),
end =
d->activeAnimations.end();
it !=
end; ++
it)
551 it.value()->clearTemplate();
560int QQuickPathAnimation::duration()
const
562 Q_D(
const QQuickPathAnimation);
566void QQuickPathAnimation::setDuration(
int duration)
573 Q_D(QQuickPathAnimation);
574 if (
d->duration == duration)
576 d->duration = duration;
577 emit durationChanged(duration);
597 Q_D(
const QQuickPathAnimation);
598 return d->easingCurve;
603 Q_D(QQuickPathAnimation);
604 if (
d->easingCurve ==
e)
608 emit easingChanged(
e);
619 Q_D(
const QQuickPathAnimation);
625 Q_D(QQuickPathAnimation);
637QQuickItem *QQuickPathAnimation::target()
const
639 Q_D(
const QQuickPathAnimation);
645 Q_D(QQuickPathAnimation);
650 emit targetChanged();
669QQuickPathAnimation::Orientation QQuickPathAnimation::orientation()
const
671 Q_D(
const QQuickPathAnimation);
672 return d->orientation;
675void QQuickPathAnimation::setOrientation(Orientation orientation)
677 Q_D(QQuickPathAnimation);
678 if (
d->orientation == orientation)
681 d->orientation = orientation;
682 emit orientationChanged(
d->orientation);
694QPointF QQuickPathAnimation::anchorPoint()
const
696 Q_D(
const QQuickPathAnimation);
697 return d->anchorPoint;
700void QQuickPathAnimation::setAnchorPoint(
const QPointF &point)
702 Q_D(QQuickPathAnimation);
703 if (
d->anchorPoint == point)
706 d->anchorPoint = point;
707 emit anchorPointChanged(point);
719int QQuickPathAnimation::orientationEntryDuration()
const
721 Q_D(
const QQuickPathAnimation);
722 return d->entryDuration;
725void QQuickPathAnimation::setOrientationEntryDuration(
int duration)
727 Q_D(QQuickPathAnimation);
728 if (
d->entryDuration == duration)
730 d->entryDuration = duration;
731 emit orientationEntryDurationChanged(duration);
742int QQuickPathAnimation::orientationExitDuration()
const
744 Q_D(
const QQuickPathAnimation);
745 return d->exitDuration;
748void QQuickPathAnimation::setOrientationExitDuration(
int duration)
750 Q_D(QQuickPathAnimation);
751 if (
d->exitDuration == duration)
753 d->exitDuration = duration;
754 emit orientationExitDurationChanged(duration);
770qreal QQuickPathAnimation::endRotation()
const
772 Q_D(
const QQuickPathAnimation);
773 return d->endRotation.isNull ?
qreal(0) :
d->endRotation.
value;
776void QQuickPathAnimation::setEndRotation(
qreal rotation)
778 Q_D(QQuickPathAnimation);
779 if (!
d->endRotation.isNull &&
d->endRotation == rotation)
782 d->endRotation = rotation;
783 emit endRotationChanged(
d->endRotation);
791 Q_D(QQuickPathAnimation);
795 QQuickPathAnimationUpdater prevData;
796 bool havePrevData =
false;
797 if (
d->activeAnimations.contains(
target)) {
799 prevData = *
d->activeAnimations[
target]->pathUpdater();
802 for (
auto it =
d->activeAnimations.begin();
it !=
d->activeAnimations.end();) {
803 QQuickPathAnimationAnimator *anim =
it.value();
805 anim->clearTemplate();
806 it =
d->activeAnimations.erase(
it);
812 QQuickPathAnimationUpdater *
data =
new QQuickPathAnimationUpdater();
813 QQuickPathAnimationAnimator *pa =
new QQuickPathAnimationAnimator(
d);
815 d->activeAnimations[
target] = pa;
817 data->orientation =
d->orientation;
818 data->anchorPoint =
d->anchorPoint;
819 data->entryInterval =
d->duration ?
qreal(
d->entryDuration) /
d->duration :
qreal(0);
820 data->exitInterval =
d->duration ?
qreal(
d->exitDuration) /
d->duration :
qreal(0);
821 data->endRotation =
d->endRotation;
823 data->fromIsSourced =
false;
824 data->fromIsDefined = (
d->path &&
d->path->hasStartX() &&
d->path->hasStartY()) ?
true :
false;
825 data->toIsDefined =
d->path ? true :
false;
826 int origModifiedSize = modified.
size();
828 for (
int i = 0;
i < actions.
size(); ++
i) {
844 if (
target &&
d->path && (modified.
size() > origModifiedSize ||
data->toIsDefined)) {
846 data->path =
d->path;
847 data->path->invalidateSequentialHistory();
851 data->startRotation = prevData.startRotation;
854 if ((
data->reverse || prevData.reverse) && prevData.currentV > 0 && prevData.currentV < 1) {
855 if (!
data->fromIsDefined && !
data->toIsDefined && !prevData.painterPath.isEmpty()) {
857 if (!prevData.anchorPoint.isNull())
858 pathPos -= prevData.anchorPoint;
859 if (pathPos ==
data->target->position()) {
860 data->painterPath = prevData.painterPath;
861 data->toIsDefined =
data->fromIsDefined =
data->fromIsSourced =
true;
862 data->prevBez.isValid =
false;
863 data->interruptStart = prevData.currentV;
864 data->startRotation = prevData.startRotation;
865 data->pathLength = prevData.pathLength;
866 data->attributePoints = prevData.attributePoints;
871 pa->setFromIsSourcedValue(&
data->fromIsSourced);
872 pa->setAnimValue(
data);
873 pa->setDuration(
d->duration);
874 pa->setEasingCurve(
d->easingCurve);
875 return initInstance(pa);
877 pa->setFromIsSourcedValue(
nullptr);
878 pa->setAnimValue(
nullptr);
885void QQuickPathAnimationUpdater::setValue(
qreal v)
889 if (interruptStart.isValid()) {
893 v = interruptStart +
v * (
end-interruptStart);
896 bool atStart = ((reverse &&
v == 1.0) || (!reverse &&
v == 0.0));
897 if (!fromIsSourced && (!fromIsDefined || !toIsDefined)) {
898 qreal startX = reverse ? toX + anchorPoint.x() :
target->x() + anchorPoint.x();
899 qreal startY = reverse ? toY + anchorPoint.y() :
target->y() + anchorPoint.y();
900 qreal endX = reverse ?
target->x() + anchorPoint.x() : toX + anchorPoint.x();
901 qreal endY = reverse ?
target->y() + anchorPoint.y() : toY + anchorPoint.y();
903 prevBez.isValid =
false;
905 fromIsSourced =
true;
909 bool fixed = orientation == QQuickPathAnimation::Fixed;
910 QPointF currentPos = !painterPath.isEmpty() ?
path->sequentialPointAt(painterPath, pathLength, attributePoints, prevBez,
v, fixed ?
nullptr : &
angle) :
path->sequentialPointAt(
v,
fixed ?
nullptr : &
angle);
913 if (!anchorPoint.isNull()) {
914 currentPos -= anchorPoint;
916 if (!anchorPoint.isNull() && !fixed)
917 target->setTransformOriginPoint(anchorPoint);
921 target->setPosition(currentPos);
925 switch (orientation) {
926 case QQuickPathAnimation::RightFirst:
929 case QQuickPathAnimation::TopFirst:
932 case QQuickPathAnimation::LeftFirst:
935 case QQuickPathAnimation::BottomFirst:
943 if (atStart && !reverse) {
944 startRotation =
target->rotation();
948 while (diff > 180.0) {
949 startRotation.value += 360.0;
952 while (diff < -180.0) {
953 startRotation.value -= 360.0;
960 if (startRotation.isValid()) {
961 if (reverse &&
v == 0.0)
962 angle = startRotation;
963 else if (
v < entryInterval)
964 angle =
angle *
v / entryInterval + startRotation * (entryInterval -
v) / entryInterval;
966 if (endRotation.isValid()) {
967 qreal exitStart = 1 - entryInterval;
968 if (!reverse &&
v == 1.0)
970 else if (
v > exitStart)
971 angle = endRotation * (
v - exitStart) / exitInterval +
angle * (exitInterval - (
v - exitStart)) / exitInterval;
982 if ((reverse &&
v == 0.0) || (!reverse &&
v == 1.0)) {
988QQuickPathAnimationAnimator::QQuickPathAnimationAnimator(QQuickPathAnimationPrivate *
priv)
989 : animationTemplate(
priv)
993QQuickPathAnimationAnimator::~QQuickPathAnimationAnimator()
995 if (animationTemplate && pathUpdater()) {
997 animationTemplate->activeAnimations.
find(pathUpdater()->
target);
998 if (
it != animationTemplate->activeAnimations.
end() &&
it.value() ==
this)
999 animationTemplate->activeAnimations.erase(
it);
1007#include "moc_qquickitemanimation_p.cpp"
void setAnimAction(QAbstractAnimationAction *action)
bool event(QEvent *) override
\reimp
void appendAnimation(QAbstractAnimationJob *animation)
qsizetype size() const noexcept
const_reference at(qsizetype i) const noexcept
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
The QQmlListProperty class allows applications to expose list-like properties of QObject-derived clas...
QAbstractAnimationJob * initInstance(QAbstractAnimationJob *animation)
void setEasing(const QEasingCurve &)
QQmlListProperty< QQuickItem > targets
\qmlproperty list<Item> QtQuick::AnchorAnimation::targets The items to reanchor.
void easingChanged(const QEasingCurve &)
void durationChanged(int)
QAbstractAnimationJob * transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, QObject *defaultTarget=nullptr) override
QQuickAnchorAnimation(QObject *parent=nullptr)
\qmltype AnchorAnimation \instantiates QQuickAnchorAnimation \inqmlmodule QtQuick\inherits Animation
QQuickItem * object() const
\qmlproperty Item QtQuick::AnchorChanges::target This property holds the \l Item for which the anchor...
void setAnimValue(QQuickBulkValueUpdater *value)
void setEasingCurve(const QEasingCurve &curve)
void setDuration(int msecs)
void setFromIsSourcedValue(bool *value)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
TransformOrigin
\variable QQuickItem::ItemChangeData::realValue The numeric value that has changed: \l {QQuickItem::o...
QTransform itemTransform(QQuickItem *, bool *) const
\qmlmethod point QtQuick::Item::mapFromItem(Item item, real x, real y) \qmlmethod point QtQuick::Item...
QPointF computeTransformOrigin(QQuickItem::TransformOrigin origin, qreal width, qreal height) const
void setTargetObject(QQuickItem *)
QQuickParentAnimation(QObject *parent=nullptr)
\qmltype ParentAnimation \instantiates QQuickParentAnimation \inqmlmodule QtQuick
void setVia(QQuickItem *)
QAbstractAnimationJob * transition(QQuickStateActions &actions, QQmlProperties &modified, TransitionDirection direction, QObject *defaultTarget=nullptr) override
void setNewParent(QQuickItem *)
void setObject(QQuickItem *)
ActionList actions() override
QQuickItem * object() const
\qmlproperty Item QtQuick::ParentChange::target This property holds the item to be reparented
bool rotationIsSet() const
void setParent(QQuickItem *)
QQuickItem * originalParent() const
QPointF sequentialPointAt(qreal p, qreal *angle=nullptr) const
virtual EventType type() const =0
QObject * specifiedObject
QQuickStateActionEvent * event
iterator find(const T &value)
qreal toReal(bool *ok=nullptr) const
Returns the variant as a qreal if the variant has userType() \l QMetaType::Double,...
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QTextStream & fixed(QTextStream &stream)
Calls QTextStream::setRealNumberNotation(QTextStream::FixedNotation) on stream and returns stream.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyIsNull(qfloat16 f) noexcept
qfloat16 qSqrt(qfloat16 f)
constexpr float qRadiansToDegrees(float radians)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h
GLuint GLenum GLenum transform
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum GLenum scale
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
QQuickItem * qobject_cast< QQuickItem * >(QObject *o)
QList< QQuickParentChange * > pc
QQuickStateActions actions
~QQuickParentAnimationData()
QQuickParentAnimationData()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent