Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickanimation_p_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKANIMATION2_P_H
6#define QQUICKANIMATION2_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
20
21#include <private/qqmlnullablevalue_p.h>
22
23#include <qqml.h>
24#include <qqmlcontext.h>
25
26#include <private/qvariantanimation_p.h>
27#include "private/qpauseanimationjob_p.h"
28#include <QDebug>
29
30#include <private/qobject_p.h>
31#include "private/qanimationgroupjob_p.h"
32#include <QDebug>
33
34#include <private/qobject_p.h>
35#include <QtCore/qpointer.h>
36
38
39//interface for classes that provide animation actions for QActionAnimation
41{
42public:
44 virtual void doAction() = 0;
45 virtual void debugAction(QDebug, int) const {}
46};
47
48//templated animation action
49//allows us to specify an action that calls a function of a class.
50//(so that class doesn't have to inherit QQuickAbstractAnimationAction)
51template<class T, void (T::*method)(), void (T::*debugMethod)(QDebug, int) const>
53{
54public:
55 QAnimationActionProxy(T *instance) : m_instance(instance) {}
56 void doAction() override { (m_instance->*method)(); }
57 void debugAction(QDebug d, int indentLevel) const override { (m_instance->*debugMethod)(d, indentLevel); }
58private:
59 T *m_instance;
60};
61
62//performs an action of type QAbstractAnimationAction
63class Q_AUTOTEST_EXPORT QActionAnimation : public QAbstractAnimationJob
64{
65 Q_DISABLE_COPY(QActionAnimation)
66public:
67 QActionAnimation();
68
69 QActionAnimation(QAbstractAnimationAction *action);
70 ~QActionAnimation() override;
71
72 int duration() const override;
73 void setAnimAction(QAbstractAnimationAction *action);
74
75protected:
76 void updateCurrentTime(int) override;
77 void updateState(State newState, State oldState) override;
78 void debugAnimation(QDebug d) const override;
79
80private:
81 QAbstractAnimationAction *animAction;
82};
83
85{
86public:
88 virtual void setValue(qreal value) = 0;
89 virtual void debugUpdater(QDebug, int) const {}
90};
91
92//animates QQuickBulkValueUpdater (assumes start and end values will be reals or compatible)
93class Q_QUICK_AUTOTEST_EXPORT QQuickBulkValueAnimator : public QAbstractAnimationJob
94{
95 Q_DISABLE_COPY(QQuickBulkValueAnimator)
96public:
97 QQuickBulkValueAnimator();
98 ~QQuickBulkValueAnimator() override;
99
100 void setAnimValue(QQuickBulkValueUpdater *value);
101 QQuickBulkValueUpdater *getAnimValue() const { return animValue; }
102
103 void setFromIsSourcedValue(bool *value) { fromIsSourced = value; }
104
105 int duration() const override { return m_duration; }
106 void setDuration(int msecs) { m_duration = msecs; }
107
108 QEasingCurve easingCurve() const { return easing; }
109 void setEasingCurve(const QEasingCurve &curve) { easing = curve; }
110
111protected:
112 void updateCurrentTime(int currentTime) override;
113 void topLevelAnimationLoopChanged() override;
114 void debugAnimation(QDebug d) const override;
115
116private:
117 QQuickBulkValueUpdater *animValue;
118 bool *fromIsSourced;
119 int m_duration;
120 QEasingCurve easing;
121};
122
123//an animation that just gives a tick
124template<class T, void (T::*method)(int)>
126{
128public:
130 int duration() const override { return -1; }
131protected:
133
134private:
135 T *m_instance;
136};
137
138class Q_QUICK_EXPORT QQuickAbstractAnimationPrivate : public QObjectPrivate, public QAnimationJobChangeListener
139{
140 Q_DECLARE_PUBLIC(QQuickAbstractAnimation)
141public:
142 QQuickAbstractAnimationPrivate()
143 : running(false), paused(false), alwaysRunToEnd(false),
144 /*connectedTimeLine(false), */componentComplete(true),
145 avoidPropertyValueSourceStart(false), disableUserControl(false),
146 needsDeferredSetRunning(false), loopCount(1), group(nullptr), animationInstance(nullptr) {}
147
148 bool running:1;
149 bool paused:1;
150 bool alwaysRunToEnd:1;
151 //bool connectedTimeLine:1;
152 bool componentComplete:1;
153 bool avoidPropertyValueSourceStart:1;
154 bool disableUserControl:1;
155 bool needsDeferredSetRunning:1;
156
157 int loopCount;
158
159 void commence();
160 void animationFinished(QAbstractAnimationJob *) override;
161
162 QQmlProperty defaultProperty;
163
164 QQuickAnimationGroup *group;
165 QAbstractAnimationJob* animationInstance;
166
167 static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj, QString *errorMessage = nullptr);
168 void animationGroupDirty();
169};
170
172{
173 Q_DECLARE_PUBLIC(QQuickPauseAnimation)
174public:
177
179};
180
200
216
218{
219 Q_DECLARE_PUBLIC(QQuickAnimationGroup)
220public:
223
225 static QQuickAbstractAnimation *at_animation(QQmlListProperty<QQuickAbstractAnimation> *list, qsizetype index);
226 static qsizetype count_animation(QQmlListProperty<QQuickAbstractAnimation> *list);
227 static void clear_animation(QQmlListProperty<QQuickAbstractAnimation> *list);
228 static void replace_animation(QQmlListProperty<QQuickAbstractAnimation> *list, qsizetype index,
229 QQuickAbstractAnimation *role);
230 static void removeLast_animation(QQmlListProperty<QQuickAbstractAnimation> *list);
232
234 void animationCurrentLoopChanged(QAbstractAnimationJob *job) override;
236};
237
238class Q_QUICK_EXPORT QQuickPropertyAnimationPrivate : public QQuickAbstractAnimationPrivate
239{
240 Q_DECLARE_PUBLIC(QQuickPropertyAnimation)
241public:
242 QQuickPropertyAnimationPrivate()
243 : QQuickAbstractAnimationPrivate(), target(nullptr), fromIsDefined(false), toIsDefined(false), ourPropertiesDirty(false),
244 defaultToInterpolatorType(0), interpolatorType(0), interpolator(nullptr), extendedInterpolator(nullptr), duration(250), actions(nullptr) {}
245
246 void animationCurrentLoopChanged(QAbstractAnimationJob *job) override;
247
248 QVariant from;
249 QVariant to;
250
251 QObject *target;
252 QString propertyName;
253 QString properties;
254 QList<QPointer<QObject>> targets;
255 QList<QObject *> exclude;
256 QString defaultProperties;
257
258 bool fromIsDefined:1;
259 bool toIsDefined:1;
260 bool ourPropertiesDirty : 1;
261 bool defaultToInterpolatorType:1;
262 int interpolatorType;
263 QVariantAnimation::Interpolator interpolator;
264 typedef QVariant (*ExtendedInterpolator)(const void *from, const void *to, const QVariant &currentValue, qreal progress);
265 ExtendedInterpolator extendedInterpolator;
266 int duration;
267 QEasingCurve easing;
268
269 // for animations that don't use the QQuickBulkValueAnimator
270 QQuickStateActions *actions;
271
272 static void convertVariant(QVariant &variant, QMetaType type);
273};
274
283
284class Q_AUTOTEST_EXPORT QQuickAnimationPropertyUpdater : public QQuickBulkValueUpdater
285{
286public:
287 QQuickAnimationPropertyUpdater() : interpolatorType(0), interpolator(nullptr), extendedInterpolator(nullptr), prevInterpolatorType(0), reverse(false), fromIsSourced(false), fromIsDefined(false), wasDeleted(nullptr) {}
288 ~QQuickAnimationPropertyUpdater() override;
289
290 void setValue(qreal v) override;
291
292 void debugUpdater(QDebug d, int indentLevel) const override;
293
294 QQuickStateActions actions;
295 int interpolatorType; //for Number/ColorAnimation
296 QVariantAnimation::Interpolator interpolator;
297 QQuickPropertyAnimationPrivate::ExtendedInterpolator extendedInterpolator;
298 int prevInterpolatorType; //for generic
299 bool reverse;
300 bool fromIsSourced;
301 bool fromIsDefined;
302 bool *wasDeleted;
303};
304
305QT_END_NAMESPACE
306
307#endif // QQUICKANIMATION2_P_H
virtual void debugAction(QDebug, int) const
virtual void doAction()=0
void debugAction(QDebug d, int indentLevel) const override
The QQmlScriptString class encapsulates a script and its context.
static qsizetype count_animation(QQmlListProperty< QQuickAbstractAnimation > *list)
QList< QQuickAbstractAnimation * > animations
void animationCurrentLoopChanged(QAbstractAnimationJob *job) override
static void replace_animation(QQmlListProperty< QQuickAbstractAnimation > *list, qsizetype index, QQuickAbstractAnimation *role)
static void removeLast_animation(QQmlListProperty< QQuickAbstractAnimation > *list)
static QQuickAbstractAnimation * at_animation(QQmlListProperty< QQuickAbstractAnimation > *list, qsizetype index)
static void clear_animation(QQmlListProperty< QQuickAbstractAnimation > *list)
virtual void debugUpdater(QDebug, int) const
virtual void setValue(qreal value)=0
QQmlNullableValue< QVariant > value
QAbstractAnimationAction * createAction()
QAnimationActionProxy< QQuickScriptActionPrivate, &QQuickScriptActionPrivate::execute, &QQuickScriptActionPrivate::debugAction > Proxy
void debugAction(QDebug d, int indentLevel) const
QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress)
QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress)
\qmltype RotationAnimation \nativetype QQuickRotationAnimation \inqmlmodule QtQuick\inherits Property...
QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress)
QQuickStateOperation::ActionList QQuickStateActions