keyframeview.hpp 4.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/***************************************************************************
 *   Copyright (C) 2011 by Till Theato (root@ttill.de)                     *
 *   Copyright (C) 2017 by Nicolas Carion                                  *
 *   This file is part of Kdenlive (www.kdenlive.org).                     *
 *                                                                         *
 *   Kdenlive is free software: you can redistribute it and/or modify      *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation, either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   Kdenlive is distributed in the hope that it will be useful,           *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with Kdenlive.  If not, see <http://www.gnu.org/licenses/>.     *
 ***************************************************************************/

20
21
#ifndef KEYFRAMEVIEW2_H
#define KEYFRAMEVIEW2_H
22

23
24
#include "assets/keyframes/model/keyframemodel.hpp"
#include "assets/keyframes/model/keyframemodellist.hpp"
25
26
27
#include <QWidget>
#include <memory>

28
29
class KeyframeModelList;

30
31
32
33
34
class KeyframeView : public QWidget
{
    Q_OBJECT

public:
35
    explicit KeyframeView(std::shared_ptr<KeyframeModelList> model, int duration, QWidget *parent = nullptr);
36
    void setDuration(int dur);
37
    const QString getAssetId();
38
39
40

public slots:
    /* @brief moves the current position*/
41
    void slotSetPosition(int pos, bool isInRange);
42
43
44
45
46
47
48
    /* @brief remove the keyframe at given position
       If pos is negative, we remove keyframe at current position
     */
    void slotRemoveKeyframe(int pos);
    /* @brief Add a keyframe with given parameter value at given pos.
       If pos is negative, then keyframe is added at current position
    */
49
    void slotAddKeyframe(int pos = -1);
50
51
52
    /* @brief If there is a keyframe at current position, it is removed.
       Otherwise, we add a new one with given value.
    */
53
    void slotAddRemove();
54
55
    void slotGoToNext();
    void slotGoToPrev();
56
    void slotModelChanged();
57
    void slotEditType(int type, const QPersistentModelIndex &index);
58
59
    /* @brief Emit initial info for monitor. */
    void initKeyframePos();
60
61
    /** @brief Move selected keyframe to cursor position. */
    void slotCenterKeyframe();
62
63
64
65
66
67
68
69
70
71

protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;
    void mouseDoubleClickEvent(QMouseEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;

private:
72
    std::shared_ptr<KeyframeModelList> m_model;
73
74
75
76
77
78
    int m_duration;
    int m_position;
    int m_currentKeyframe;
    int m_currentKeyframeOriginal;
    int m_hoverKeyframe;
    int m_lineHeight;
79
    int m_zoomHeight;
80
    int m_offset;
81
    double m_scale;
82
83
    double m_zoomFactor;
    double m_zoomStart;
84
    bool m_moveKeyframeMode;
85
86
87
88
89
90
91
92
93
94
95
    /** @brief The zoom factor (start, end - between 0 and 1) */
    QPointF m_zoomHandle;
    QPointF m_lastZoomHandle;
    /** @brief Mouse is the zoom left handle */
    bool m_hoverZoomIn;
    /** @brief Mouse is the zoom right handle */
    bool m_hoverZoomOut;
    /** @brief Mouse is over the zoom bar */
    bool m_hoverZoom;
    /** @brief the x click position offset for moving zoom */
    double m_clickOffset;
96
97
98
99
100
101
102
    int m_size;

    QColor m_colSelected;
    QColor m_colKeyframe;
    QColor m_colKeyframeBg;

signals:
103
    void seekToPos(int pos);
104
    void atKeyframe(bool isKeyframe, bool singleKeyframe);
105
    void modified();
106
    void activateEffect();
107
108
109
};

#endif