1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQUICKANIMATION_P_H
5#define QQUICKANIMATION_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qquickitemanimation_p.h"
19
20#if QT_CONFIG(quick_path)
21#include <private/qquickpath_p.h>
22#endif
23#include <private/qquickanimation_p_p.h>
24
25QT_BEGIN_NAMESPACE
26
27class QQuickParentAnimationPrivate : public QQuickAnimationGroupPrivate
28{
29 Q_DECLARE_PUBLIC(QQuickParentAnimation)
30public:
31 QQuickParentAnimationPrivate()
32 : QQuickAnimationGroupPrivate(), target(nullptr), newParent(nullptr), via(nullptr) {}
33
34 QQuickItem *target;
35 QQuickItem *newParent;
36 QQuickItem *via;
37
38 QPointF computeTransformOrigin(QQuickItem::TransformOrigin origin, qreal width, qreal height) const;
39};
40
41class QQuickAnchorAnimationPrivate : public QQuickAbstractAnimationPrivate
42{
43 Q_DECLARE_PUBLIC(QQuickAnchorAnimation)
44public:
45 QQuickAnchorAnimationPrivate() : interpolator(QVariantAnimationPrivate::getInterpolator(interpolationType: QMetaType::QReal)), duration(250) {}
46
47 QVariantAnimation::Interpolator interpolator;
48 int duration;
49 QEasingCurve easing;
50 QList<QQuickItem*> targets;
51};
52
53#if QT_CONFIG(quick_path)
54
55class QQuickPathAnimationUpdater : public QQuickBulkValueUpdater
56{
57public:
58 QQuickPathAnimationUpdater() : path(nullptr), pathLength(0), target(nullptr), reverse(false),
59 fromIsSourced(false), fromIsDefined(false), toIsDefined(false),
60 toX(0), toY(0), currentV(0), orientation(QQuickPathAnimation::Fixed),
61 entryInterval(0), exitInterval(0) {}
62 ~QQuickPathAnimationUpdater() {}
63
64 void setValue(qreal v) override;
65
66 QQuickPath *path;
67
68 QPainterPath painterPath;
69 QQuickCachedBezier prevBez;
70 qreal pathLength;
71 QList<QQuickPath::AttributePoint> attributePoints;
72
73 QQuickItem *target;
74 bool reverse;
75 bool fromIsSourced;
76 bool fromIsDefined;
77 bool toIsDefined;
78 qreal toX;
79 qreal toY;
80 qreal currentV;
81 QQmlNullableValue<qreal> interruptStart;
82 //TODO: bundle below into common struct
83 QQuickPathAnimation::Orientation orientation;
84 QPointF anchorPoint;
85 qreal entryInterval;
86 qreal exitInterval;
87 QQmlNullableValue<qreal> endRotation;
88 QQmlNullableValue<qreal> startRotation;
89};
90
91class QQuickPathAnimationPrivate;
92class QQuickPathAnimationAnimator : public QQuickBulkValueAnimator
93{
94public:
95 QQuickPathAnimationAnimator(QQuickPathAnimationPrivate * = nullptr);
96 ~QQuickPathAnimationAnimator();
97
98 void clearTemplate() { animationTemplate = nullptr; }
99
100 QQuickPathAnimationUpdater *pathUpdater() const { return static_cast<QQuickPathAnimationUpdater*>(getAnimValue()); }
101private:
102 QQuickPathAnimationPrivate *animationTemplate;
103};
104
105class QQuickPathAnimationPrivate : public QQuickAbstractAnimationPrivate
106{
107 Q_DECLARE_PUBLIC(QQuickPathAnimation)
108public:
109 QQuickPathAnimationPrivate() : path(nullptr), target(nullptr),
110 orientation(QQuickPathAnimation::Fixed), entryDuration(0), exitDuration(0), duration(250) {}
111
112 QQuickPath *path;
113 QQuickItem *target;
114 QQuickPathAnimation::Orientation orientation;
115 QPointF anchorPoint;
116 qreal entryDuration;
117 qreal exitDuration;
118 QQmlNullableValue<qreal> endRotation;
119 int duration;
120 QEasingCurve easingCurve;
121 QHash<QQuickItem*, QQuickPathAnimationAnimator* > activeAnimations;
122};
123
124#endif
125
126QT_END_NAMESPACE
127
128#endif // QQUICKANIMATION_P_H
129

source code of qtdeclarative/src/quick/items/qquickitemanimation_p_p.h