]> git.sesse.net Git - kdenlive/blob - src/customtrackview.h
ce7704baf3cf0836849441e4320b97cdc35e55bb
[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
28 #include <KUndoStack>
29
30 #include "kdenlivedoc.h"
31 #include "clipitem.h"
32
33 class CustomTrackView : public QGraphicsView {
34     Q_OBJECT
35
36 public:
37     CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent = 0);
38     virtual void mousePressEvent(QMouseEvent * event);
39     virtual void mouseReleaseEvent(QMouseEvent * event);
40     virtual void mouseMoveEvent(QMouseEvent * event);
41     void addTrack();
42     void removeTrack();
43     int cursorPos();
44     void checkAutoScroll();
45     void moveClip(const QPointF &startPos, const QPointF &endPos);
46     void resizeClip(const QPointF &startPos, const QPointF &endPos, bool resizeClipStart);
47     void addClip(QDomElement xml, int clipId, int track, GenTime startpos, const QRectF &rect, GenTime duration);
48     void deleteClip(int track, GenTime startpos, const QRectF &rect);
49     void setScale(double scaleFactor);
50     void deleteClip(int clipId);
51     void slotAddEffect(QDomElement effect, GenTime pos, int track);
52     void addEffect(int track, GenTime pos, QDomElement effect);
53     void deleteEffect(int track, GenTime pos, QDomElement effect);
54     void updateEffect(int track, GenTime pos, QDomElement effect);
55     void activateMonitor();
56
57 public slots:
58     void setCursorPos(int pos, bool seek = true);
59     void updateCursorPos();
60     void slotDeleteEffect(ClipItem *clip, QDomElement effect);
61     void slotChangeEffectState(ClipItem *clip, QDomElement effect, bool disable);
62     void slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect);
63     void slotRefreshEffects(ClipItem *clip);
64     void setDuration(int duration);
65
66 protected:
67     virtual void drawBackground(QPainter * painter, const QRectF & rect);
68     //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
69     virtual void dragEnterEvent(QDragEnterEvent * event);
70     virtual void dragMoveEvent(QDragMoveEvent * event);
71     virtual void dragLeaveEvent(QDragLeaveEvent * event);
72     virtual void dropEvent(QDropEvent * event);
73     virtual void wheelEvent(QWheelEvent * e);
74     virtual QStringList mimeTypes() const;
75     virtual Qt::DropActions supportedDropActions() const;
76     virtual void resizeEvent(QResizeEvent * event);
77
78 private:
79     int m_tracksCount;
80     int m_projectDuration;
81     int m_cursorPos;
82     ClipItem *m_dropItem;
83     KdenliveDoc *m_document;
84     void addItem(DocClipBase *clip, QPoint pos);
85     QGraphicsLineItem *m_cursorLine;
86     QPointF m_startPos;
87     OPERATIONTYPE m_operationMode;
88     OPERATIONTYPE m_moveOpMode;
89     AbstractClipItem *m_dragItem;
90     KUndoStack *m_commandStack;
91     QGraphicsItem *m_visualTip;
92     QGraphicsItemAnimation *m_animation;
93     QTimeLine *m_animationTimer;
94     QColor m_tipColor;
95     QPen m_tipPen;
96     double m_scale;
97     int m_clickPoint;
98     QList <GenTime> m_snapPoints;
99     void updateSnapPoints(AbstractClipItem *selected);
100     double getSnapPointForPos(double pos);
101     ClipItem *getClipItemAt(int pos, int track);
102     ClipItem *getClipItemAt(GenTime pos, int track);
103     void checkScrolling();
104     /** Should we auto scroll while playing (keep in sync with KdenliveSettings::autoscroll() */
105     bool m_autoScroll;
106
107
108 signals:
109     void cursorMoved(int, int);
110     void zoomIn();
111     void zoomOut();
112     void mousePosition(int);
113     void clipItemSelected(ClipItem*);
114     void activateDocumentMonitor();
115 };
116
117 #endif