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