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"
36 class AbstractClipItem;
39 class CustomTrackView : public QGraphicsView {
43 CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent = 0);
44 virtual ~ CustomTrackView();
45 virtual void mousePressEvent(QMouseEvent * event);
46 virtual void mouseReleaseEvent(QMouseEvent * event);
47 virtual void mouseMoveEvent(QMouseEvent * event);
48 virtual void mouseDoubleClickEvent(QMouseEvent *event);
49 void addTrack(TrackInfo type);
52 void checkAutoScroll();
53 void moveClip(const ItemInfo start, const ItemInfo end);
54 /** move transition, startPos = (old start, old end), endPos = (new start, new end) */
55 void moveTransition(const ItemInfo start, const ItemInfo end);
56 void resizeClip(const ItemInfo start, const ItemInfo end);
57 void addClip(QDomElement xml, int clipId, ItemInfo info);
58 void deleteClip(ItemInfo info);
59 void slotAddClipMarker();
60 void slotEditClipMarker();
61 void slotDeleteClipMarker();
62 void slotDeleteAllClipMarkers();
63 void addMarker(const int id, const GenTime &pos, const QString comment);
64 void setScale(double scaleFactor);
65 void deleteClip(int clipId);
66 void slotAddEffect(QDomElement effect, GenTime pos, int track);
67 void addEffect(int track, GenTime pos, QDomElement effect);
68 void deleteEffect(int track, GenTime pos, QDomElement effect);
69 void updateEffect(int track, GenTime pos, QDomElement effect, int ix);
70 void moveEffect(int track, GenTime pos, int oldPos, int newPos);
71 void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params);
72 void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params);
73 void updateTransition(int track, GenTime pos, QDomElement oldTransition, QDomElement transition);
74 void moveTransition(GenTime oldpos, GenTime newpos);
75 void activateMonitor();
77 void deleteSelectedClips();
78 void cutSelectedClips();
79 void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition);
80 void checkTrackHeight();
81 QList <TrackInfo> tracksList() const;
82 void setTool(PROJECTTOOL tool);
83 void cutClip(ItemInfo info, GenTime cutTime, bool cut);
84 void slotSeekToPreviousSnap();
85 void slotSeekToNextSnap();
86 double getSnapPointForPos(double pos);
87 QDomElement xmlInfo();
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);
124 virtual void drawBackground(QPainter * painter, const QRectF & rect);
125 //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
126 virtual void dragEnterEvent(QDragEnterEvent * event);
127 virtual void dragMoveEvent(QDragMoveEvent * event);
128 virtual void dragLeaveEvent(QDragLeaveEvent * event);
129 virtual void dropEvent(QDropEvent * event);
130 virtual void wheelEvent(QWheelEvent * e);
131 virtual QStringList mimeTypes() const;
132 virtual Qt::DropActions supportedDropActions() const;
133 virtual void resizeEvent(QResizeEvent * event);
137 int m_projectDuration;
139 ClipItem *m_dropItem;
140 KdenliveDoc *m_document;
141 void addItem(DocClipBase *clip, QPoint pos);
142 QGraphicsLineItem *m_cursorLine;
143 ItemInfo m_dragItemInfo;
144 OPERATIONTYPE m_operationMode;
145 OPERATIONTYPE m_moveOpMode;
146 AbstractClipItem *m_dragItem;
148 KUndoStack *m_commandStack;
149 QGraphicsItem *m_visualTip;
150 QGraphicsItemAnimation *m_animation;
151 QTimeLine *m_animationTimer;
157 QList <GenTime> m_snapPoints;
158 QList <CommentedTime> m_searchPoints;
159 QList <Guide *> m_guides;
160 void updateSnapPoints(AbstractClipItem *selected);
161 ClipItem *getClipItemAt(int pos, int track);
162 ClipItem *getClipItemAt(GenTime pos, int track);
163 Transition *getTransitionItemAt(int pos, int track);
164 Transition *getTransitionItemAt(GenTime pos, int track);
165 void checkScrolling();
166 /** Should we auto scroll while playing (keep in sync with KdenliveSettings::autoscroll() */
168 void displayContextMenu(QPoint pos, AbstractClipItem *clip = NULL);
169 QMenu *m_timelineContextMenu;
170 QMenu *m_timelineContextClipMenu;
171 QMenu *m_timelineContextTransitionMenu;
172 QList <TrackInfo> m_tracksList;
173 QList <CommentedTime> m_searchStrings;
176 QCursor m_razorCursor;
177 /** list containing items currently copied in the timeline */
178 QList<AbstractClipItem *> m_copiedItems;
179 QList<AbstractClipItem *> m_selectedClipList;
180 /** Used to get the point in timeline where a context menu was opened */
181 QPoint m_menuPosition;
183 /** Get the index of the video track that is just below current track */
184 int getPreviousVideoTrack(int track);
185 void updateClipFade(ClipItem * item, bool updateFadeOut = false);
186 bool canBePastedTo(ItemInfo info, int type) const;
187 bool canBePasted(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
188 bool canBeMoved(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
191 void slotRefreshGuides();
194 void cursorMoved(int, int);
197 void mousePosition(int);
198 void clipItemSelected(ClipItem*);
199 void transitionItemSelected(Transition*);
200 void activateDocumentMonitor();
201 void trackHeightChanged();
202 void displayMessage(const QString, MessageType);
203 void showClipFrame(DocClipBase *, const int);