]> git.sesse.net Git - kdenlive/blob - src/customtrackview.h
Track height can now be changed from settings dialog
[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 #include "clipitem.h"
33
34
35
36 class CustomTrackView : public QGraphicsView {
37     Q_OBJECT
38
39 public:
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);
45     void removeTrack();
46     int cursorPos();
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();
61     int duration() const;
62     void deleteSelectedClips();
63     void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition);
64     void checkTrackHeight();
65     QList <TRACKTYPE> tracksList() const;
66
67 public slots:
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);
76
77 protected:
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);
88
89 private:
90     uint m_tracksHeight;
91     int m_projectDuration;
92     int m_cursorPos;
93     ClipItem *m_dropItem;
94     KdenliveDoc *m_document;
95     void addItem(DocClipBase *clip, QPoint pos);
96     QGraphicsLineItem *m_cursorLine;
97     QPointF m_startPos;
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;
105     QColor m_tipColor;
106     QPen m_tipPen;
107     double m_scale;
108     QPoint m_clickPoint;
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() */
116     bool m_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;
122
123
124 signals:
125     void cursorMoved(int, int);
126     void zoomIn();
127     void zoomOut();
128     void mousePosition(int);
129     void clipItemSelected(ClipItem*);
130     void transitionItemSelected(Transition*);
131     void activateDocumentMonitor();
132     void trackHeightChanged();
133 };
134
135 #endif
136