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