1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4// W A R N I N G
5// -------------
6//
7// This file is not part of the QtGraphs API. It exists purely as an
8// implementation detail. This header file may change from version to
9// version without notice, or even be removed.
10//
11// We mean it.
12
13#ifndef QGRAPHANIMATION_H
14#define QGRAPHANIMATION_H
15
16#include <QtCore/QVariantAnimation>
17#include <QtCore/qloggingcategory.h>
18
19QT_BEGIN_NAMESPACE
20
21Q_DECLARE_LOGGING_CATEGORY(lcAnimation)
22
23class QGraphAnimation : public QVariantAnimation
24{
25 Q_OBJECT
26 Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
27
28 Q_PROPERTY(
29 AnimationState animating READ animating WRITE setAnimating NOTIFY animatingChanged FINAL)
30
31public:
32 enum class AnimationState {
33 Playing,
34 Stopped,
35 };
36 Q_ENUM(AnimationState);
37
38 enum class GraphAnimationType { GraphPoint, ControlPoint };
39 Q_ENUM(GraphAnimationType);
40
41 explicit QGraphAnimation(QObject *parent = nullptr);
42 ~QGraphAnimation() override;
43
44 virtual GraphAnimationType animationType() = 0;
45 virtual void setAnimatingValue(const QVariant &start, const QVariant &end) = 0;
46 virtual void animate() = 0;
47 virtual void end() = 0;
48 QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const override
49 = 0;
50
51 AnimationState animating() const;
52 void setAnimating(AnimationState newAnimating);
53
54public Q_SLOTS:
55 virtual void valueUpdated(const QVariant &value) = 0;
56
57signals:
58 void animatingChanged();
59
60private:
61 AnimationState m_animating = AnimationState::Stopped;
62};
63
64QT_END_NAMESPACE
65
66#endif // QGRAPHANIMATION_H
67

source code of qtgraphs/src/graphs2d/animation/qgraphanimation_p.h