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