aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesigner/components/curveeditor/curveeditormodel.h
blob: 6cd5365e6c85a76d72927efdfc43d0bf5a6177c6 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "detail/treemodel.h"

#include <qmltimelinekeyframegroup.h>

#include <vector>

QT_BEGIN_NAMESPACE
class QPointF;
QT_END_NAMESPACE

namespace QmlDesigner {

struct CurveEditorStyle;

class AnimationCurve;
class PropertyTreeItem;
class TreeItem;

inline constexpr AuxiliaryDataKeyView pinnedProperty{AuxiliaryDataType::Document, "pinned"};
inline constexpr AuxiliaryDataKeyView unifiedProperty{AuxiliaryDataType::Document, "unified"};

class CurveEditorModel : public TreeModel
{
    Q_OBJECT

signals:
    void setStatusLineMsg(const QString& msg);

    void commitCurrentFrame(int frame);

    void commitStartFrame(int frame);

    void commitEndFrame(int frame);

    void timelineChanged(bool valid);

    void curveChanged(TreeItem *item);

public:
    CurveEditorModel(QObject *parent = nullptr);

    ~CurveEditorModel() override;

    int currentFrame() const;

    double minimumTime() const;

    double maximumTime() const;

    CurveEditorStyle style() const;

public:
    void setTimeline(const QmlDesigner::QmlTimeline &timeline);

    void setCurrentFrame(int frame);

    void setMinimumTime(double time);

    void setMaximumTime(double time);

    void setCurve(unsigned int id, const AnimationCurve &curve);

    void setLocked(TreeItem *item, bool val);

    void setPinned(TreeItem *item, bool val);

    void reset(const std::vector<TreeItem *> &items);

private:
    TreeItem *createTopLevelItem(const QmlDesigner::QmlTimeline &timeline,
                                 const QmlDesigner::ModelNode &node);

    AnimationCurve createAnimationCurve(const QmlDesigner::QmlTimelineKeyframeGroup &group);

    AnimationCurve createBooleanCurve(const QmlDesigner::QmlTimelineKeyframeGroup &group);

    AnimationCurve createDoubleCurve(const QmlDesigner::QmlTimelineKeyframeGroup &group);

    bool m_hasTimeline = false;

    int m_currentFrame = 0;

    double m_minTime = 0.;

    double m_maxTime = 0.;
};

} // End namespace QmlDesigner.