]> git.sesse.net Git - kdenlive/blob - src/clipitem.h
Allow to do a rectangle selection (Shift + click) also when starting the rectangle...
[kdenlive] / src / clipitem.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef CLIPITEM_H
22 #define CLIPITEM_H
23
24 #include <QTimeLine>
25 #include <QGraphicsRectItem>
26 #include <QDomElement>
27 #include <QGraphicsSceneMouseEvent>
28 #include <QTimer>
29
30 #include "definitions.h"
31 #include "gentime.h"
32 #include "effectslist.h"
33 #include "abstractclipitem.h"
34
35 class DocClipBase;
36 class Transition;
37
38
39 class ClipItem : public AbstractClipItem
40 {
41     Q_OBJECT
42
43 public:
44     ClipItem(DocClipBase *clip, ItemInfo info, double fps, double speed, bool generateThumbs = true);
45     virtual ~ ClipItem();
46     virtual void paint(QPainter *painter,
47                        const QStyleOptionGraphicsItem *option,
48                        QWidget *);
49     virtual int type() const;
50     void resizeStart(int posx, double speed = 1.0);
51     void resizeEnd(int posx, double speed = 1.0, bool updateKeyFrames = true);
52     OPERATIONTYPE operationMode(QPointF pos);
53     const QString &clipProducer() const;
54     int clipType() const;
55     DocClipBase *baseClip() const;
56     QString clipName() const;
57     void setClipName(const QString &name);
58     QDomElement xml() const;
59     ClipItem *clone(ItemInfo info) const;
60     const EffectsList effectList();
61     void setFadeOut(int pos);
62     void setFadeIn(int pos);
63     /** Give a string list of the clip's effect names */
64     QStringList effectNames();
65     /** Add an effect to the clip and return the parameters that will be passed to Mlt */
66     EffectsParameterList addEffect(QDomElement effect, bool animate = true);
67     /** Get the effect parameters that will be passed to Mlt */
68     EffectsParameterList getEffectArgs(QDomElement effect);
69     /** Delete effect with id index */
70     void deleteEffect(QString index);
71     /** return the number of effects in that clip */
72     int effectsCount();
73     /** return a unique effect id */
74     int effectsCounter();
75     /** return the xml of effect at index ix in stack */
76     QDomElement effectAt(int ix);
77     /** Replace effect at pos ix with given value */
78     void setEffectAt(int ix, QDomElement effect);
79     void flashClip();
80     void addTransition(Transition*);
81     /** regenerate audio and video thumbnails */
82     void resetThumbs(bool clearExistingThumbs);
83     /** update clip properties from base clip */
84     void refreshClip(bool checkDuration);
85     /** Returns a list of times for this clip's markers */
86     QList <GenTime> snapMarkers() const;
87     QList <CommentedTime> commentedSnapMarkers() const;
88     int fadeIn() const;
89     int fadeOut() const;
90     void setSelectedEffect(const int ix);
91     void updateKeyframeEffect();
92     QDomElement selectedEffect();
93     int selectedEffectIndex() const;
94     void initEffect(QDomElement effect);
95     QString keyframes(const int index);
96     void setKeyframes(const int ix, const QString keyframes);
97     void setEffectList(const EffectsList effectList);
98     void setSpeed(const double speed);
99     double speed() const;
100     GenTime maxDuration() const;
101     GenTime cropStart() const;
102     GenTime endPos() const;
103     GenTime cropDuration() const;
104     int hasEffect(const QString &tag, const QString &id) const;
105     bool checkKeyFrames();
106     QPixmap startThumb() const;
107     QPixmap endThumb() const;
108     void setVideoOnly(bool force);
109     void setAudioOnly(bool force);
110     bool isVideoOnly() const;
111     bool isAudioOnly() const;
112
113 protected:
114     //virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
115     virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
116     virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
117     virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
118     //virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *);
119     //virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
120     virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
121
122 private:
123     DocClipBase *m_clip;
124     QString m_producer;
125     CLIPTYPE m_clipType;
126     QString m_clipName;
127     QString m_effectNames;
128     int m_startFade;
129     int m_endFade;
130     bool m_audioOnly;
131     bool m_videoOnly;
132
133     QPixmap m_startPix;
134     QPixmap m_endPix;
135     bool m_hasThumbs;
136     QTimer *m_startThumbTimer;
137     QTimer *m_endThumbTimer;
138
139     int m_selectedEffect;
140     QTimeLine *m_timeLine;
141     bool m_startThumbRequested;
142     bool m_endThumbRequested;
143     //bool m_hover;
144     double m_speed;
145
146     EffectsList m_effectList;
147     QList <Transition*> m_transitionsList;
148     QMap<int, QPixmap> m_audioThumbCachePic;
149     bool m_audioThumbReady;
150     double m_framePixelWidth;
151     /** Called when clip start is resized, adjust keyframes values */
152     void checkEffectsKeyframesPos(const int previous, const int current, bool fromStart);
153     QPixmap m_videoPix;
154     QPixmap m_audioPix;
155
156 private slots:
157     void slotGetStartThumb();
158     void slotGetEndThumb();
159     void slotGotAudioData();
160     void slotPrepareAudioThumb(double pixelForOneFrame, int startpixel, int endpixel, int channels);
161     void animate(qreal value);
162     void slotSetStartThumb(QImage img);
163     void slotSetEndThumb(QImage img);
164     void slotThumbReady(int frame, QPixmap pix);
165
166 public slots:
167     void slotFetchThumbs();
168     void slotSetStartThumb(const QPixmap pix);
169     void slotSetEndThumb(const QPixmap pix);
170
171 signals:
172     void getThumb(int, int);
173     void prepareAudioThumb(double, int, int, int);
174 };
175
176 #endif