1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
21 #ifndef CUSTOMTRACKVIEW_H
22 #define CUSTOMTRACKVIEW_H
24 #include <QGraphicsView>
25 #include <QGraphicsItemAnimation>
31 #include "kdenlivedoc.h"
32 #include "docclipbase.h"
34 #include "effectslist.h"
37 class AbstractClipItem;
40 class CustomTrackView : public QGraphicsView {
44 CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent = 0);
45 virtual ~ CustomTrackView();
46 virtual void mousePressEvent(QMouseEvent * event);
47 virtual void mouseReleaseEvent(QMouseEvent * event);
48 virtual void mouseMoveEvent(QMouseEvent * event);
49 virtual void mouseDoubleClickEvent(QMouseEvent *event);
50 void addTrack(TrackInfo type);
53 void checkAutoScroll();
54 void moveClip(const ItemInfo start, const ItemInfo end);
55 /** move transition, startPos = (old start, old end), endPos = (new start, new end) */
56 void moveTransition(const ItemInfo start, const ItemInfo end);
57 void resizeClip(const ItemInfo start, const ItemInfo end);
58 void addClip(QDomElement xml, int clipId, ItemInfo info, EffectsList list = EffectsList());
59 void deleteClip(ItemInfo info);
60 void slotAddClipMarker();
61 void slotEditClipMarker();
62 void slotDeleteClipMarker();
63 void slotDeleteAllClipMarkers();
64 void addMarker(const int id, const GenTime &pos, const QString comment);
65 void setScale(double scaleFactor);
66 void deleteClip(int clipId);
67 void slotAddEffect(QDomElement effect, GenTime pos, int track);
68 void addEffect(int track, GenTime pos, QDomElement effect);
69 void deleteEffect(int track, GenTime pos, QDomElement effect);
70 void updateEffect(int track, GenTime pos, QDomElement effect, int ix);
71 void moveEffect(int track, GenTime pos, int oldPos, int newPos);
72 void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params);
73 void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params);
74 void updateTransition(int track, GenTime pos, QDomElement oldTransition, QDomElement transition);
75 void moveTransition(GenTime oldpos, GenTime newpos);
76 void activateMonitor();
78 void deleteSelectedClips();
79 void cutSelectedClips();
80 void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition);
81 void checkTrackHeight();
82 QList <TrackInfo> tracksList() const;
83 void setTool(PROJECTTOOL tool);
84 void cutClip(ItemInfo info, GenTime cutTime, bool cut);
85 void slotSeekToPreviousSnap();
86 void slotSeekToNextSnap();
87 double getSnapPointForPos(double pos);
88 void editKeyFrame(const GenTime pos, const int track, const int index, const QString keyframes);
89 bool findString(const QString &text);
90 bool findNextString(const QString &text);
91 void initSearchStrings();
92 void clearSearchStrings();
97 void setCursorPos(int pos, bool seek = true);
98 void moveCursorPos(int delta);
99 void updateCursorPos();
100 void slotDeleteEffect(ClipItem *clip, QDomElement effect);
101 void slotChangeEffectState(ClipItem *clip, int effectPos, bool disable);
102 void slotChangeEffectPosition(ClipItem *clip, int currentPos, int newPos);
103 void slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect, int ix);
104 void slotRefreshEffects(ClipItem *clip);
105 void setDuration(int duration);
106 void slotAddTransition(ClipItem* clip, ItemInfo transitionInfo, int endTrack, QDomElement transition = QDomElement());
107 void slotAddTransitionToSelectedClips(QDomElement transition);
108 void slotTransitionUpdated(Transition *, QDomElement);
109 void slotSwitchTrackAudio(int ix);
110 void slotSwitchTrackVideo(int ix);
111 void slotUpdateClip(int clipId);
112 void slotAddClipMarker(int id, GenTime t, QString c);
113 bool addGuide(const GenTime pos, const QString &comment);
115 void slotEditGuide(CommentedTime guide);
116 void slotEditGuide();
117 void slotDeleteGuide();
118 void slotDeleteAllGuides();
119 void editGuide(const GenTime oldPos, const GenTime pos, const QString &comment);
122 void pasteClipEffects();
125 virtual void drawBackground(QPainter * painter, const QRectF & rect);
126 //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
127 virtual void dragEnterEvent(QDragEnterEvent * event);
128 virtual void dragMoveEvent(QDragMoveEvent * event);
129 virtual void dragLeaveEvent(QDragLeaveEvent * event);
130 virtual void dropEvent(QDropEvent * event);
131 virtual void wheelEvent(QWheelEvent * e);
132 virtual QStringList mimeTypes() const;
133 virtual Qt::DropActions supportedDropActions() const;
134 virtual void resizeEvent(QResizeEvent * event);
138 int m_projectDuration;
140 ClipItem *m_dropItem;
141 KdenliveDoc *m_document;
142 void addItem(DocClipBase *clip, QPoint pos);
143 QGraphicsLineItem *m_cursorLine;
144 ItemInfo m_dragItemInfo;
145 OPERATIONTYPE m_operationMode;
146 OPERATIONTYPE m_moveOpMode;
147 AbstractClipItem *m_dragItem;
149 KUndoStack *m_commandStack;
150 QGraphicsItem *m_visualTip;
151 QGraphicsItemAnimation *m_animation;
152 QTimeLine *m_animationTimer;
158 QList <GenTime> m_snapPoints;
159 QList <CommentedTime> m_searchPoints;
160 QList <Guide *> m_guides;
161 void updateSnapPoints(AbstractClipItem *selected);
162 ClipItem *getClipItemAt(int pos, int track);
163 ClipItem *getClipItemAt(GenTime pos, int track);
164 Transition *getTransitionItemAt(int pos, int track);
165 Transition *getTransitionItemAt(GenTime pos, int track);
166 void checkScrolling();
167 /** Should we auto scroll while playing (keep in sync with KdenliveSettings::autoscroll() */
169 void displayContextMenu(QPoint pos, AbstractClipItem *clip = NULL);
170 QMenu *m_timelineContextMenu;
171 QMenu *m_timelineContextClipMenu;
172 QMenu *m_timelineContextTransitionMenu;
173 QList <TrackInfo> m_tracksList;
174 QList <CommentedTime> m_searchStrings;
177 QCursor m_razorCursor;
178 /** list containing items currently copied in the timeline */
179 QList<AbstractClipItem *> m_copiedItems;
180 QList<AbstractClipItem *> m_selectedClipList;
181 /** Used to get the point in timeline where a context menu was opened */
182 QPoint m_menuPosition;
184 /** Get the index of the video track that is just below current track */
185 int getPreviousVideoTrack(int track);
186 void updateClipFade(ClipItem * item, bool updateFadeOut = false);
187 bool canBePastedTo(ItemInfo info, int type) const;
188 bool canBePasted(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
189 bool canBeMoved(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
192 void slotRefreshGuides();
195 void cursorMoved(int, int);
198 void mousePosition(int);
199 void clipItemSelected(ClipItem*);
200 void transitionItemSelected(Transition*);
201 void activateDocumentMonitor();
202 void trackHeightChanged();
203 void displayMessage(const QString, MessageType);
204 void showClipFrame(DocClipBase *, const int);