summaryrefslogtreecommitdiffstats
path: root/src/graphs2d/animation/qgraphanimation.cpp
blob: 4419825faf7fa961297541848d5f8ae7d25f4d2d (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include "qgraphanimation_p.h"
#include <private/qgraphanimation_p.h>

QT_BEGIN_NAMESPACE

/*!
    \qmltype GraphAnimation
    \qmlabstract
    \inqmlmodule QtGraphs
    \ingroup graphs_qml_2D
    \brief The GraphAnimation type is the base type for all animations for 2D Qt Graphs series.

    GraphAnimation is based on VariantAnimation and provides an interface for interpolation for child animations.
    This type is an abstract type and doesn't have any default implementation for interpolation. Its derived types
    should be used for the respective animations, such as GraphPointAnimation, SplineControlAnimation.
*/

/*!
    \qmlproperty GraphAnimation::AnimationState GraphAnimation::animating

    Holds the animation state. One of \l {GraphAnimation::AnimationState}.
 */

/*!
    \qmlproperty enumeration GraphAnimation::AnimationState

    Animation states.

    \value Playing
        Animation is playing.
    \value Stopped
        Animation is stopped.
*/

/*!
    \qmlproperty enumeration GraphAnimation::GraphAnimationType

    Animation type.

    \value GraphPoint
        A GraphPointAnimation animation.
    \value ControlPoint
        A ControlPointAnimation animation.
*/

Q_LOGGING_CATEGORY(lcAnimation, "qt.graphs2d.animation")

QGraphAnimation::QGraphAnimation(QObject *parent)
    : QVariantAnimation(parent)
{
    connect(this, &QVariantAnimation::valueChanged, this, &QGraphAnimation::valueUpdated);
    connect(this, &QVariantAnimation::finished, this, &QGraphAnimation::end);
}

QGraphAnimation::~QGraphAnimation()
{
    stop();
}

QGraphAnimation::AnimationState QGraphAnimation::animating() const
{
    return m_animating;
}

void QGraphAnimation::setAnimating(AnimationState newAnimating)
{
    if (m_animating == newAnimating) {
        qCDebug(lcAnimation) << "QGraphAnimation::setAnimating. AnimationState is already set to: " << newAnimating;
        return;
    }
    m_animating = newAnimating;

    qCDebug(lcAnimation) << "animation state:" << m_animating;
    emit animatingChanged();
}

QT_END_NAMESPACE