]> git.sesse.net Git - kdenlive/blob - src/abstractclipitem.h
Fix keyframes corruption:
[kdenlive] / src / abstractclipitem.h
1 /***************************************************************************
2  *   Copyright (C) 2008 by Marco Gittler (g.marco@freenet.de)              *
3  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
19  ***************************************************************************/
20
21 #ifndef ABSTRACTCLIPITEM
22 #define ABSTRACTCLIPITEM
23
24 #include <QGraphicsRectItem>
25 #include <QGraphicsWidget>
26
27 #if QT_VERSION >= 0x040600
28 #include <QPropertyAnimation>
29 #endif
30
31 #include "definitions.h"
32 #include "gentime.h"
33
34 class CustomTrackScene;
35 class QGraphicsSceneMouseEvent;
36
37 class AbstractClipItem : public QObject, public QGraphicsRectItem
38 {
39     Q_OBJECT
40 #if QT_VERSION >= 0x040600
41     Q_PROPERTY(QRectF rect READ rect WRITE setRect)
42 #endif
43
44 public:
45     AbstractClipItem(const ItemInfo info, const QRectF& rect, double fps);
46     virtual ~ AbstractClipItem();
47     void updateSelectedKeyFrame();
48     void updateKeyFramePos(const GenTime pos, const double value);
49     int addKeyFrame(const GenTime pos, const double value);
50     bool hasKeyFrames() const;
51     int editedKeyFramePos() const;
52     int selectedKeyFramePos() const;
53     double selectedKeyFrameValue() const;
54     double editedKeyFrameValue() const;
55     double keyFrameFactor() const;
56     ItemInfo info() const;
57     CustomTrackScene* projectScene();
58     void updateRectGeometry();
59     void updateItem();
60     void setItemLocked(bool locked);
61     bool isItemLocked() const;
62     void closeAnimation();
63
64     virtual  OPERATIONTYPE operationMode(QPointF pos) = 0;
65     virtual GenTime startPos() const ;
66     virtual void setTrack(int track);
67     virtual GenTime endPos() const ;
68     virtual int defaultZValue() const ;
69     virtual int track() const ;
70     virtual GenTime cropStart() const ;
71     virtual GenTime cropDuration() const ;
72     virtual void resizeStart(int posx);
73     virtual void resizeEnd(int posx);
74     virtual double fps() const;
75     virtual void updateFps(double fps);
76     virtual GenTime maxDuration() const;
77     virtual void setCropStart(GenTime pos);
78
79 protected:
80     ItemInfo m_info;
81 //    int m_track;
82     /** The position of the current keyframe when it has moved */
83     int m_editedKeyframe;
84     /** The position of the current keyframe before it was moved */
85     int m_selectedKeyframe;
86     /*    GenTime m_cropStart;
87         GenTime m_cropDuration;
88         GenTime m_startPos;*/
89     GenTime m_maxDuration;
90     QMap <int, int> m_keyframes;
91     double m_keyframeFactor;
92     double m_keyframeDefault;
93     double m_fps;
94     //QRect visibleRect();
95     void drawKeyFrames(QPainter *painter, QRectF exposedRect);
96     int mouseOverKeyFrames(QPointF pos, double maxOffset);
97     virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
98
99 private:
100 #if QT_VERSION >= 0x040600
101     QPropertyAnimation *m_closeAnimation;
102 #endif
103 };
104
105 #endif