]> git.sesse.net Git - kdenlive/blob - src/abstractclipitem.h
For now use previous and next keyframe as border when moving keyframe in timeline...
[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
49     /** @brief Move the selected keyframe (does not influence the effect, only the display in timeline).
50     * @param pos new Position
51     * @param value new Value */
52     void updateKeyFramePos(const GenTime pos, const double value);
53     int addKeyFrame(const GenTime pos, const double value);
54     bool hasKeyFrames() const;
55     int editedKeyFramePos() const;
56     int selectedKeyFramePos() const;
57     double selectedKeyFrameValue() const;
58     double editedKeyFrameValue() const;
59     double keyFrameFactor() const;
60     ItemInfo info() const;
61     CustomTrackScene* projectScene();
62     void updateRectGeometry();
63     void updateItem();
64     void setItemLocked(bool locked);
65     bool isItemLocked() const;
66     void closeAnimation();
67
68     virtual  OPERATIONTYPE operationMode(QPointF pos) = 0;
69     virtual GenTime startPos() const ;
70     virtual void setTrack(int track);
71     virtual GenTime endPos() const ;
72     virtual int defaultZValue() const ;
73     virtual int track() const ;
74     virtual GenTime cropStart() const ;
75     virtual GenTime cropDuration() const ;
76
77     /** @brief Resizes the clip from the start.
78     * @param posx Absolute position of new in point
79     * @param hasSizeLimit (optional) Whether the clip has a maximum size */
80     virtual void resizeStart(int posx, bool hasSizeLimit = true);
81
82     /** @brief Resizes the clip from the end.
83     * @param posx Absolute position of new out point */
84     virtual void resizeEnd(int posx);
85     virtual double fps() const;
86     virtual void updateFps(double fps);
87     virtual GenTime maxDuration() const;
88     virtual void setCropStart(GenTime pos);
89
90 protected:
91     ItemInfo m_info;
92 //    int m_track;
93     /** The position of the current keyframe when it has moved */
94     int m_editedKeyframe;
95     /** The position of the current keyframe before it was moved */
96     int m_selectedKeyframe;
97     /*    GenTime m_cropStart;
98         GenTime m_cropDuration;
99         GenTime m_startPos;*/
100     GenTime m_maxDuration;
101     QMap <int, int> m_keyframes;
102     double m_keyframeFactor;
103     double m_keyframeDefault;
104     double m_fps;
105     //QRect visibleRect();
106     void drawKeyFrames(QPainter *painter, QRectF exposedRect);
107     int mouseOverKeyFrames(QPointF pos, double maxOffset);
108     virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
109
110 private:
111 #if QT_VERSION >= 0x040600
112     QPropertyAnimation *m_closeAnimation;
113 #endif
114 };
115
116 #endif