]> git.sesse.net Git - kdenlive/blob - src/monitor.h
Use enum instead of string to identify monitors
[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 #ifndef MONITOR_H
21 #define MONITOR_H
22
23
24 #include "gentime.h"
25 #include "renderer.h"
26 #include "definitions.h"
27 #include "timecodedisplay.h"
28 #include "abstractmonitor.h"
29 #ifdef USE_OPENGL
30 #include "videoglwidget.h"
31 #endif
32
33 #include <QLabel>
34 #include <QDomElement>
35 #include <QToolBar>
36 #include <QSlider>
37
38 #include <KIcon>
39 #include <KAction>
40 #include <KRestrictedLine>
41
42 class SmallRuler;
43 class DocClipBase;
44 class AbstractClipItem;
45 class Transition;
46 class ClipItem;
47 class MonitorEditWidget;
48 class Monitor;
49 class MonitorManager;
50
51 class VideoContainer : public QFrame
52 {
53     Q_OBJECT
54 public:
55     VideoContainer(Monitor *parent = 0);
56     void switchFullScreen();
57
58 protected:
59     virtual void mouseDoubleClickEvent(QMouseEvent * event);
60     virtual void mouseReleaseEvent(QMouseEvent *event);
61     void keyPressEvent(QKeyEvent *event);
62     virtual void wheelEvent(QWheelEvent * event);
63
64 private:
65     Qt::WindowFlags m_baseFlags;
66     Monitor *m_monitor;
67 };
68
69 class MonitorRefresh : public QWidget
70 {
71     Q_OBJECT
72 public:
73     MonitorRefresh(QWidget *parent = 0);
74     void setRenderer(Render* render);
75
76 private:
77     Render *m_renderer;
78 };
79
80 class Overlay : public QLabel
81 {
82     Q_OBJECT
83 public:
84     Overlay(QWidget* parent = 0);
85     void setOverlayText(const QString &, bool isZone = true);
86
87 private:
88     bool m_isZone;
89
90 protected:
91     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
92     virtual void mousePressEvent ( QMouseEvent * event );
93     virtual void mouseReleaseEvent ( QMouseEvent * event );
94     
95 signals:
96     void editMarker();
97 };
98
99 class Monitor : public AbstractMonitor
100 {
101     Q_OBJECT
102
103 public:
104     Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
105     ~Monitor();
106     Render *render;
107     AbstractRender *abstractRender();
108     void resetProfile(const QString &profile);
109     void resetSize();
110     bool isActive() const;
111     void pause();
112     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
113     const QString sceneList();
114     DocClipBase *activeClip();
115     GenTime position();
116     void checkOverlay();
117     void updateTimecodeFormat();
118     void updateMarkers(DocClipBase *source);
119     MonitorEditWidget *getEffectEdit();
120     QWidget *container();
121     void reloadProducer(const QString &id);
122     QFrame *m_volumePopup;
123
124 protected:
125     virtual void mousePressEvent(QMouseEvent * event);
126     virtual void mouseReleaseEvent(QMouseEvent * event);
127     virtual void mouseDoubleClickEvent(QMouseEvent * event);
128     virtual void resizeEvent(QResizeEvent *event);
129
130     /** @brief Move to another position on mouse wheel event.
131      *
132      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
133      * opposite on mouse wheel up/forward.
134      * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
135     virtual void wheelEvent(QWheelEvent * event);
136     virtual void mouseMoveEvent(QMouseEvent *event);
137     virtual QStringList mimeTypes() const;
138     /*virtual void dragMoveEvent(QDragMoveEvent * event);
139     virtual Qt::DropActions supportedDropActions() const;*/
140
141     //virtual void resizeEvent(QResizeEvent * event);
142     //virtual void paintEvent(QPaintEvent * event);
143
144 private:
145     Kdenlive::MONITORID m_name;
146     MonitorManager *m_monitorManager;
147     DocClipBase *m_currentClip;
148     SmallRuler *m_ruler;
149     Overlay *m_overlay;
150     double m_scale;
151     int m_length;
152     bool m_dragStarted;
153     MonitorRefresh *m_monitorRefresh;
154     KIcon m_playIcon;
155     KIcon m_pauseIcon;
156     TimecodeDisplay *m_timePos;
157     QAction *m_playAction;
158     /** Has to be available so we can enable and disable it. */
159     QAction *m_loopClipAction;
160     QMenu *m_contextMenu;
161     QMenu *m_configMenu;
162     QMenu *m_playMenu;
163     QMenu *m_markerMenu;
164     QPoint m_DragStartPosition;
165     MonitorEditWidget *m_effectWidget;
166     VideoContainer *m_videoBox;
167     /** Selected clip/transition in timeline. Used for looping it. */
168     AbstractClipItem *m_selectedClip;
169     /** true if selected clip is transition, false = selected clip is clip.
170      *  Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
171     bool m_loopClipTransition;
172
173 #ifdef USE_OPENGL
174     VideoGLWidget *m_glWidget;
175     bool createOpenGlWidget(QWidget *parent, const QString profile);
176 #endif
177
178     GenTime getSnapForPos(bool previous);
179     Qt::WindowFlags m_baseFlags;
180     QToolBar *m_toolbar;
181     QWidget *m_volumeWidget;
182     QSlider *m_audioSlider;
183     QAction *m_editMarker;
184
185 private slots:
186     void seekCursor(int pos);
187     void rendererStopped(int pos);
188     void slotExtractCurrentFrame();
189     void slotSetThumbFrame();
190     void slotSetSizeOneToOne();
191     void slotSetSizeOneToTwo();
192     void slotSaveZone();
193     void slotSeek();
194     void setClipZone(QPoint pos);
195     void slotSwitchMonitorInfo(bool show);
196     void slotSwitchDropFrames(bool show);
197     void slotGoToMarker(QAction *action);
198     void slotSetVolume(int volume);
199     void slotShowVolume();
200     void slotEditMarker();
201     void slotExtractCurrentZone();
202
203 public slots:
204     void slotOpenFile(const QString &);
205     void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
206     void updateClipProducer(Mlt::Producer *prod);
207     void refreshMonitor(bool visible);
208     void refreshMonitor();
209     void slotSeek(int pos);
210     void stop();
211     void start();
212     bool activateMonitor();
213     void slotPlay();
214     void slotPlayZone();
215     void slotLoopZone();
216     /** @brief Loops the selected item (clip or transition). */
217     void slotLoopClip();
218     void slotForward(double speed = 0);
219     void slotRewind(double speed = 0);
220     void slotRewindOneFrame(int diff = 1);
221     void slotForwardOneFrame(int diff = 1);
222     void saveSceneList(QString path, QDomElement info = QDomElement());
223     void slotStart();
224     void slotEnd();
225     void slotSetZoneStart();
226     void slotSetZoneEnd();
227     void slotZoneStart();
228     void slotZoneEnd();
229     void slotZoneMoved(int start, int end);
230     void slotSeekToNextSnap();
231     void slotSeekToPreviousSnap();
232     void adjustRulerSize(int length);
233     void setTimePos(const QString &pos);
234     QStringList getZoneInfo() const;
235     void slotEffectScene(bool show = true);
236     bool effectSceneDisplayed();
237
238     /** @brief Sets m_selectedClip to @param item. Used for looping it. */
239     void slotSetSelectedClip(AbstractClipItem *item);
240     void slotSetSelectedClip(ClipItem *item);
241     void slotSetSelectedClip(Transition *item);
242     void slotMouseSeek(int eventDelta, bool fast);
243     void slotSwitchFullScreen();
244
245 signals:
246     void renderPosition(int);
247     void durationChanged(int);
248     void refreshClipThumbnail(const QString &, bool);
249     void adjustMonitorSize();
250     void zoneUpdated(QPoint);
251     void saveZone(Render *, QPoint, DocClipBase *);
252     /** @brief  Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
253      *      This causes a major slowdown, so we only enable it if required */
254     void requestFrameForAnalysis(bool);
255     /** @brief Request a zone extraction (ffmpeg transcoding). */
256     void extractZone(const QString &id, QPoint zone);
257 };
258
259 #endif