| 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 |  | 
| 18 | QT_BEGIN_NAMESPACE | 
| 19 |  | 
| 20 | class QGraphAnimation : public QVariantAnimation | 
| 21 | { | 
| 22 |     Q_OBJECT | 
| 23 |     Q_CLASSINFO("RegisterEnumClassesUnscoped" , "false" ) | 
| 24 |  | 
| 25 |     Q_PROPERTY( | 
| 26 |         AnimationState animating READ animating WRITE setAnimating NOTIFY animatingChanged FINAL) | 
| 27 |  | 
| 28 | public: | 
| 29 |     enum class AnimationState { | 
| 30 |         Playing, | 
| 31 |         Stopped, | 
| 32 |     }; | 
| 33 |     Q_ENUM(AnimationState); | 
| 34 |  | 
| 35 |     enum class GraphAnimationType { GraphPoint, ControlPoint }; | 
| 36 |     Q_ENUM(GraphAnimationType); | 
| 37 |  | 
| 38 |     explicit QGraphAnimation(QObject *parent = nullptr); | 
| 39 |     ~QGraphAnimation() override; | 
| 40 |  | 
| 41 |     virtual GraphAnimationType animationType() = 0; | 
| 42 |     virtual void setAnimatingValue(const QVariant &start, const QVariant &end) = 0; | 
| 43 |     virtual void animate() = 0; | 
| 44 |     virtual void end() = 0; | 
| 45 |     QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const override | 
| 46 |         = 0; | 
| 47 |  | 
| 48 |     AnimationState animating() const; | 
| 49 |     void setAnimating(AnimationState newAnimating); | 
| 50 |  | 
| 51 | public Q_SLOTS: | 
| 52 |     virtual void valueUpdated(const QVariant &value) = 0; | 
| 53 |  | 
| 54 | signals: | 
| 55 |     void animatingChanged(); | 
| 56 |  | 
| 57 | private: | 
| 58 |     AnimationState m_animating = AnimationState::Stopped; | 
| 59 | }; | 
| 60 |  | 
| 61 | QT_END_NAMESPACE | 
| 62 |  | 
| 63 | #endif // QGRAPHANIMATION_H | 
| 64 |  |