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"
36 class CustomTrackView : public QGraphicsView {
40 CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent = 0);
41 virtual void mousePressEvent(QMouseEvent * event);
42 virtual void mouseReleaseEvent(QMouseEvent * event);
43 virtual void mouseMoveEvent(QMouseEvent * event);
44 void addTrack(TRACKTYPE type);
47 void checkAutoScroll();
48 void moveClip(const QPointF &startPos, const QPointF &endPos);
49 void resizeClip(const QPointF &startPos, const QPointF &endPos, bool resizeClipStart);
50 void addClip(QDomElement xml, int clipId, int track, GenTime startpos, const QRectF &rect, GenTime duration);
51 void deleteClip(int track, GenTime startpos, const QRectF &rect);
52 void setScale(double scaleFactor);
53 void deleteClip(int clipId);
54 void slotAddEffect(QDomElement effect, GenTime pos, int track);
55 void addEffect(int track, GenTime pos, QDomElement effect);
56 void deleteEffect(int track, GenTime pos, QDomElement effect);
57 void updateEffect(int track, GenTime pos, QDomElement effect);
58 void addTransition(int track, GenTime pos, QDomElement transition);
59 void deleteTransition(int track, GenTime pos, QDomElement transition);
60 void activateMonitor();
62 void deleteSelectedClips();
63 void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition);
64 void checkTrackHeight();
65 QList <TRACKTYPE> tracksList() const;
68 void setCursorPos(int pos, bool seek = true);
69 void updateCursorPos();
70 void slotDeleteEffect(ClipItem *clip, QDomElement effect);
71 void slotChangeEffectState(ClipItem *clip, QDomElement effect, bool disable);
72 void slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect);
73 void slotRefreshEffects(ClipItem *clip);
74 void setDuration(int duration);
75 void slotAddTransition(ClipItem* clip , QDomElement transition, GenTime startTime , int startTrack);
78 virtual void drawBackground(QPainter * painter, const QRectF & rect);
79 //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
80 virtual void dragEnterEvent(QDragEnterEvent * event);
81 virtual void dragMoveEvent(QDragMoveEvent * event);
82 virtual void dragLeaveEvent(QDragLeaveEvent * event);
83 virtual void dropEvent(QDropEvent * event);
84 virtual void wheelEvent(QWheelEvent * e);
85 virtual QStringList mimeTypes() const;
86 virtual Qt::DropActions supportedDropActions() const;
87 virtual void resizeEvent(QResizeEvent * event);
91 int m_projectDuration;
94 KdenliveDoc *m_document;
95 void addItem(DocClipBase *clip, QPoint pos);
96 QGraphicsLineItem *m_cursorLine;
98 OPERATIONTYPE m_operationMode;
99 OPERATIONTYPE m_moveOpMode;
100 AbstractClipItem *m_dragItem;
101 KUndoStack *m_commandStack;
102 QGraphicsItem *m_visualTip;
103 QGraphicsItemAnimation *m_animation;
104 QTimeLine *m_animationTimer;
109 QList <GenTime> m_snapPoints;
110 void updateSnapPoints(AbstractClipItem *selected);
111 double getSnapPointForPos(double pos);
112 ClipItem *getClipItemAt(int pos, int track);
113 ClipItem *getClipItemAt(GenTime pos, int track);
114 void checkScrolling();
115 /** Should we auto scroll while playing (keep in sync with KdenliveSettings::autoscroll() */
117 void displayContextMenu(QPoint pos, ClipItem *clip = NULL);
118 QMenu *m_timelineContextMenu;
119 QMenu *m_timelineContextClipMenu;
120 QMenu *m_timelineContextTransitionMenu;
121 QList <TRACKTYPE> m_tracksList;
125 void cursorMoved(int, int);
128 void mousePosition(int);
129 void clipItemSelected(ClipItem*);
130 void transitionItemSelected(Transition*);
131 void activateDocumentMonitor();
132 void trackHeightChanged();