1 /***************************************************************************
2 * Copyright (C) 2008 by Marco Gittler (g.marco@freenet.de) *
3 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
21 #ifndef ABSTRACTCLIPITEM
22 #define ABSTRACTCLIPITEM
24 #include <QGraphicsRectItem>
25 #include <QGraphicsWidget>
27 #if QT_VERSION >= 0x040600
28 #include <QPropertyAnimation>
31 #include "definitions.h"
34 class CustomTrackScene;
35 class QGraphicsSceneMouseEvent;
37 class AbstractClipItem : public QObject, public QGraphicsRectItem
40 #if QT_VERSION >= 0x040600
41 Q_PROPERTY(QRectF rect READ rect WRITE setRect)
45 AbstractClipItem(const ItemInfo info, const QRectF& rect, double fps);
46 virtual ~ AbstractClipItem();
47 void updateSelectedKeyFrame();
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 /** @brief Returns the number of keyframes the selected effect has. */
61 int keyFrameNumber() const;
62 ItemInfo info() const;
63 CustomTrackScene* projectScene();
64 void updateRectGeometry();
66 void setItemLocked(bool locked);
67 bool isItemLocked() const;
68 void closeAnimation();
70 virtual OPERATIONTYPE operationMode(QPointF pos) = 0;
71 virtual GenTime startPos() const ;
72 virtual void setTrack(int track);
73 virtual GenTime endPos() const ;
74 virtual int defaultZValue() const ;
75 virtual int track() const ;
76 virtual GenTime cropStart() const ;
77 virtual GenTime cropDuration() const ;
79 /** @brief Resizes the clip from the start.
80 * @param posx Absolute position of new in point
81 * @param hasSizeLimit (optional) Whether the clip has a maximum size */
82 virtual void resizeStart(int posx, bool hasSizeLimit = true);
84 /** @brief Resizes the clip from the end.
85 * @param posx Absolute position of new out point */
86 virtual void resizeEnd(int posx);
87 virtual double fps() const;
88 virtual void updateFps(double fps);
89 virtual GenTime maxDuration() const;
90 virtual void setCropStart(GenTime pos);
95 /** The position of the current keyframe when it has moved */
97 /** The position of the current keyframe before it was moved */
98 int m_selectedKeyframe;
99 /* GenTime m_cropStart;
100 GenTime m_cropDuration;
101 GenTime m_startPos;*/
102 GenTime m_maxDuration;
103 QMap <int, int> m_keyframes;
104 /** @brief Strech factor so that keyframes display on the full clip height. */
105 double m_keyframeFactor;
106 /** @brief Offset factor so that keyframes minimum value are displaed at the bottom of the clip. */
107 double m_keyframeOffset;
108 /** @brief Default reset value for keyframe. */
109 double m_keyframeDefault;
110 /** The (keyframe) parameter that is visible and editable in timeline (on the clip) */
113 //QRect visibleRect();
114 void drawKeyFrames(QPainter *painter, QRectF exposedRect);
115 int mouseOverKeyFrames(QPointF pos, double maxOffset);
116 virtual void mousePressEvent(QGraphicsSceneMouseEvent * event);
119 #if QT_VERSION >= 0x040600
120 QPropertyAnimation *m_closeAnimation;