]> git.sesse.net Git - kdenlive/blob - src/monitor.h
* Clip Markers are now displayed over the clip monitor
[kdenlive] / src / monitor.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 MONITOR_H
22 #define MONITOR_H
23
24 #include <QLabel>
25
26 #include <KIcon>
27 #include <KAction>
28 #include <KRestrictedLine>
29 #include <QDomElement>
30
31 #include "gentime.h"
32 #include "ui_monitor_ui.h"
33
34 class MonitorManager;
35 class Render;
36 class SmallRuler;
37 class DocClipBase;
38
39 class MonitorRefresh : public QWidget {
40     Q_OBJECT
41 public:
42     MonitorRefresh(QWidget* parent);
43     virtual void paintEvent(QPaintEvent * event);
44     void setRenderer(Render* render);
45
46 private:
47     Render *m_renderer;
48 };
49
50 class Overlay : public QLabel {
51     Q_OBJECT
52 public:
53     Overlay(QWidget* parent);
54     virtual void paintEvent(QPaintEvent * event);
55     void setOverlayText(const QString &, bool isZone = true);
56
57 private:
58     bool m_isZone;
59 };
60
61 class Monitor : public QWidget {
62     Q_OBJECT
63
64 public:
65     Monitor(QString name, MonitorManager *manager, QWidget *parent = 0);
66     virtual ~Monitor();
67     Render *render;
68     void resetProfile();
69     QString name() const;
70     void resetSize();
71     bool isActive() const;
72     void pause();
73     void setupMenu(QMenu *goMenu);
74     QDomDocument sceneList();
75
76 protected:
77     virtual void mousePressEvent(QMouseEvent * event);
78     virtual void mouseReleaseEvent(QMouseEvent * event);
79     virtual void wheelEvent(QWheelEvent * event);
80     virtual void mouseMoveEvent(QMouseEvent *event);
81     virtual QStringList mimeTypes() const;
82     /*    virtual void dragMoveEvent(QDragMoveEvent * event);
83         virtual Qt::DropActions supportedDropActions() const;*/
84
85 //    virtual void resizeEvent(QResizeEvent * event);
86 //    virtual void paintEvent(QPaintEvent * event);
87
88 private:
89     Ui::Monitor_UI ui;
90     MonitorManager *m_monitorManager;
91     MonitorRefresh *m_monitorRefresh;
92     QString m_name;
93     double m_scale;
94     int m_length;
95     int m_position;
96     SmallRuler *m_ruler;
97     KIcon m_playIcon;
98     KIcon m_pauseIcon;
99     bool m_isActive;
100     KRestrictedLine *m_timePos;
101     QAction *m_playAction;
102     QMenu *m_contextMenu;
103     QMenu *m_configMenu;
104     QMenu *m_playMenu;
105     DocClipBase *m_currentClip;
106     QPoint m_DragStartPosition;
107     bool m_dragStarted;
108     Overlay *m_overlay;
109     void checkOverlay();
110     GenTime getSnapForPos(bool previous);
111
112 private slots:
113     void adjustRulerSize(int length);
114     void seekCursor(int pos);
115     void rendererStopped(int pos);
116     void slotExtractCurrentFrame();
117     void slotSetThumbFrame();
118     void slotSetSizeOneToOne();
119     void slotSetSizeOneToTwo();
120     void slotSaveZone();
121     void slotSeek();
122
123 public slots:
124     void slotOpenFile(const QString &);
125     void slotSetXml(DocClipBase *clip, const int position = -1);
126     void initMonitor();
127     void refreshMonitor(bool visible);
128     void slotSeek(int pos);
129     void stop();
130     void start();
131     void activateMonitor();
132     void slotPlay();
133     void slotPlayZone();
134     void slotLoopZone();
135     void slotForward(double speed = 0);
136     void slotRewind(double speed = 0);
137     void slotRewindOneFrame();
138     void slotForwardOneFrame();
139     void saveSceneList(QString path, QDomElement info = QDomElement());
140     void slotStart();
141     void slotEnd();
142     void slotSetZoneStart();
143     void slotSetZoneEnd();
144     void slotZoneStart();
145     void slotZoneEnd();
146     void slotZoneMoved(int start, int end);
147     void slotSeekToNextSnap();
148     void slotSeekToPreviousSnap();
149
150 signals:
151     void renderPosition(int);
152     void durationChanged(int);
153     void refreshClipThumbnail(const QString &);
154     void adjustMonitorSize();
155     void zoneUpdated(QPoint);
156     void saveZone(Render *, QPoint);
157 };
158
159 #endif