1// Copyright (C) 2017 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 QQUICKANIMATEDNODE_P_H
5#define QQUICKANIMATEDNODE_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 <QtCore/qobject.h>
19#include <QtQuick/qsgnode.h>
20#include <QtCore/qelapsedtimer.h>
21#include <QtQuickControls2Impl/private/qtquickcontrols2implglobal_p.h>
22
23QT_BEGIN_NAMESPACE
24
25class QQuickItem;
26class QQuickWindow;
27
28class Q_QUICKCONTROLS2IMPL_PRIVATE_EXPORT QQuickAnimatedNode : public QObject, public QSGTransformNode
29{
30 Q_OBJECT
31
32public:
33 explicit QQuickAnimatedNode(QQuickItem *target);
34
35 bool isRunning() const;
36
37 int currentTime() const;
38 void setCurrentTime(int time);
39
40 int duration() const;
41 void setDuration(int duration);
42
43 enum LoopCount { Infinite = -1 };
44
45 int loopCount() const;
46 void setLoopCount(int count);
47
48 virtual void sync(QQuickItem *target);
49
50 QQuickWindow *window() const;
51
52 // must be called from sync() or updatePaintNode()
53 void start(int duration = 0);
54 void restart();
55 void stop();
56
57Q_SIGNALS:
58 void started();
59 void stopped();
60
61protected:
62 virtual void updateCurrentTime(int time);
63
64private Q_SLOTS:
65 void advance();
66 void update();
67
68private:
69 bool m_running = false;
70 int m_duration = 0;
71 int m_loopCount = 1;
72 int m_currentTime = 0;
73 int m_currentLoop = 0;
74 QElapsedTimer m_timer;
75 QQuickWindow *m_window = nullptr;
76};
77
78QT_END_NAMESPACE
79
80#endif // QQUICKANIMATEDNODE_P_H
81

source code of qtdeclarative/src/quickcontrolsimpl/qquickanimatednode_p.h