summaryrefslogtreecommitdiffstats
path: root/src/graphs2d/animation/qgraphanimation_p.h
blob: e75cfafcef0b89712629d9edbd9509efbc38da98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

//  W A R N I N G
//  -------------
//
// This file is not part of the QtGraphs API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.

#ifndef QGRAPHANIMATION_H
#define QGRAPHANIMATION_H

#include <QtCore/QVariantAnimation>
#include <QtCore/qloggingcategory.h>

QT_BEGIN_NAMESPACE

Q_DECLARE_LOGGING_CATEGORY(lcAnimation)

class QGraphAnimation : public QVariantAnimation
{
    Q_OBJECT
    Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")

    Q_PROPERTY(
        AnimationState animating READ animating WRITE setAnimating NOTIFY animatingChanged FINAL)

public:
    enum class AnimationState {
        Playing,
        Stopped,
    };
    Q_ENUM(AnimationState);

    enum class GraphAnimationType { GraphPoint, ControlPoint };
    Q_ENUM(GraphAnimationType);

    explicit QGraphAnimation(QObject *parent = nullptr);
    ~QGraphAnimation() override;

    virtual GraphAnimationType animationType() = 0;
    virtual void setAnimatingValue(const QVariant &start, const QVariant &end) = 0;
    virtual void animate() = 0;
    virtual void end() = 0;
    QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const override
        = 0;

    AnimationState animating() const;
    void setAnimating(AnimationState newAnimating);

public Q_SLOTS:
    virtual void valueUpdated(const QVariant &value) = 0;

signals:
    void animatingChanged();

private:
    AnimationState m_animating = AnimationState::Stopped;
};

QT_END_NAMESPACE

#endif // QGRAPHANIMATION_H