]> git.sesse.net Git - kdenlive/blob - src/customtrackview.h
use more forward decl. to have no unneeded recompiling
[kdenlive] / src / customtrackview.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 CUSTOMTRACKVIEW_H
22 #define CUSTOMTRACKVIEW_H
23
24 #include <QGraphicsView>
25 #include <QGraphicsItemAnimation>
26 #include <QTimeLine>
27 #include <QMenu>
28
29 #include <KUndoStack>
30
31 #include "kdenlivedoc.h"
32
33 class ClipItem;
34 class AbstractClipItem;
35 class Transition;
36
37 class CustomTrackView : public QGraphicsView {
38     Q_OBJECT
39
40 public:
41     CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent = 0);
42     virtual void mousePressEvent(QMouseEvent * event);
43     virtual void mouseReleaseEvent(QMouseEvent * event);
44     virtual void mouseMoveEvent(QMouseEvent * event);
45     void addTrack(TrackInfo type);
46     void removeTrack();
47     int cursorPos();
48     void checkAutoScroll();
49     void moveClip(const QPointF &startPos, const QPointF &endPos);
50     void resizeClip(const QPointF &startPos, const QPointF &endPos, bool resizeClipStart);
51     void addClip(QDomElement xml, int clipId, int track, GenTime startpos, const QRectF &rect, GenTime duration);
52     void deleteClip(int track, GenTime startpos, const QRectF &rect);
53     void setScale(double scaleFactor);
54     void deleteClip(int clipId);
55     void slotAddEffect(QDomElement effect, GenTime pos, int track);
56     void addEffect(int track, GenTime pos, QDomElement effect);
57     void deleteEffect(int track, GenTime pos, QDomElement effect);
58     void updateEffect(int track, GenTime pos, QDomElement effect);
59     void addTransition(int track, GenTime pos, QDomElement transition);
60     void deleteTransition(int track, GenTime pos, QDomElement transition);
61     void updateTransition(int track, GenTime pos,  QDomElement oldTransition, QDomElement transition);
62     void activateMonitor();
63     int duration() const;
64     void deleteSelectedClips();
65     void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition);
66     void checkTrackHeight();
67     QList <TrackInfo> tracksList() const;
68
69 public slots:
70     void setCursorPos(int pos, bool seek = true);
71     void updateCursorPos();
72     void slotDeleteEffect(ClipItem *clip, QDomElement effect);
73     void slotChangeEffectState(ClipItem *clip, QDomElement effect, bool disable);
74     void slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect);
75     void slotRefreshEffects(ClipItem *clip);
76     void setDuration(int duration);
77     void slotAddTransition(ClipItem* clip , QDomElement transition, GenTime startTime , int startTrack);
78     void slotTransitionUpdated(QDomElement, QDomElement);
79     void slotSwitchTrackAudio(int ix);
80     void slotSwitchTrackVideo(int ix);
81
82 protected:
83     virtual void drawBackground(QPainter * painter, const QRectF & rect);
84     //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
85     virtual void dragEnterEvent(QDragEnterEvent * event);
86     virtual void dragMoveEvent(QDragMoveEvent * event);
87     virtual void dragLeaveEvent(QDragLeaveEvent * event);
88     virtual void dropEvent(QDropEvent * event);
89     virtual void wheelEvent(QWheelEvent * e);
90     virtual QStringList mimeTypes() const;
91     virtual Qt::DropActions supportedDropActions() const;
92     virtual void resizeEvent(QResizeEvent * event);
93
94 private:
95     uint m_tracksHeight;
96     int m_projectDuration;
97     int m_cursorPos;
98     ClipItem *m_dropItem;
99     KdenliveDoc *m_document;
100     void addItem(DocClipBase *clip, QPoint pos);
101     QGraphicsLineItem *m_cursorLine;
102     QPointF m_startPos;
103     OPERATIONTYPE m_operationMode;
104     OPERATIONTYPE m_moveOpMode;
105     AbstractClipItem *m_dragItem;
106     KUndoStack *m_commandStack;
107     QGraphicsItem *m_visualTip;
108     QGraphicsItemAnimation *m_animation;
109     QTimeLine *m_animationTimer;
110     QColor m_tipColor;
111     QPen m_tipPen;
112     double m_scale;
113     QPoint m_clickPoint;
114     QList <GenTime> m_snapPoints;
115     void updateSnapPoints(AbstractClipItem *selected);
116     double getSnapPointForPos(double pos);
117     ClipItem *getClipItemAt(int pos, int track);
118     ClipItem *getClipItemAt(GenTime pos, int track);
119     void checkScrolling();
120     /** Should we auto scroll while playing (keep in sync with KdenliveSettings::autoscroll() */
121     bool m_autoScroll;
122     void displayContextMenu(QPoint pos, ClipItem *clip = NULL);
123     QMenu *m_timelineContextMenu;
124     QMenu *m_timelineContextClipMenu;
125     QMenu *m_timelineContextTransitionMenu;
126     QList <TrackInfo> m_tracksList;
127     /** Get the index of the video track that is just below current track */
128     int getPreviousVideoTrack(int track);
129
130
131 signals:
132     void cursorMoved(int, int);
133     void zoomIn();
134     void zoomOut();
135     void mousePosition(int);
136     void clipItemSelected(ClipItem*);
137     void transitionItemSelected(Transition*);
138     void activateDocumentMonitor();
139     void trackHeightChanged();
140 };
141
142 #endif
143