1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
26 #include "timecodedisplay.h"
27 #include "abstractmonitor.h"
28 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
29 #include "videoglwidget.h"
33 #include <QDomElement>
39 #include <KRestrictedLine>
43 class AbstractClipItem;
46 class MonitorEditWidget;
50 class VideoContainer : public QFrame
54 VideoContainer(Monitor *parent = 0);
55 void switchFullScreen();
58 virtual void mouseDoubleClickEvent(QMouseEvent * event);
59 virtual void mousePressEvent(QMouseEvent * event);
60 virtual void mouseReleaseEvent(QMouseEvent *event);
61 virtual void mouseMoveEvent(QMouseEvent *event);
62 void keyPressEvent(QKeyEvent *event);
63 virtual void wheelEvent(QWheelEvent * event);
66 Qt::WindowFlags m_baseFlags;
70 class MonitorRefresh : public QWidget
74 MonitorRefresh(QWidget *parent = 0);
75 void setRenderer(Render* render);
78 virtual void paintEvent(QPaintEvent *event);
84 void switchFullScreen();
86 void mouseSeek(int, bool);
89 class Overlay : public QLabel
93 Overlay(QWidget* parent = 0);
94 void setOverlayText(const QString &, bool isZone = true);
100 virtual void mouseDoubleClickEvent ( QMouseEvent * event );
101 virtual void mousePressEvent ( QMouseEvent * event );
102 virtual void mouseReleaseEvent ( QMouseEvent * event );
108 class Monitor : public AbstractMonitor
113 Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
116 AbstractRender *abstractRender();
117 void resetProfile(const QString profile);
118 const QString name() const;
120 bool isActive() const;
122 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
123 const QString sceneList();
124 DocClipBase *activeClip();
127 void updateTimecodeFormat();
128 void updateMarkers(DocClipBase *source);
129 MonitorEditWidget *getEffectEdit();
130 QWidget *container();
131 QFrame *m_volumePopup;
134 virtual void mousePressEvent(QMouseEvent * event);
135 virtual void mouseReleaseEvent(QMouseEvent * event);
137 /** @brief Move to another position on mouse wheel event.
139 * Moves towards the end of the clip/timeline on mouse wheel down/back, the
140 * opposite on mouse wheel up/forward.
141 * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
142 virtual void wheelEvent(QWheelEvent * event);
143 virtual void mouseMoveEvent(QMouseEvent *event);
144 virtual QStringList mimeTypes() const;
145 /*virtual void dragMoveEvent(QDragMoveEvent * event);
146 virtual Qt::DropActions supportedDropActions() const;*/
148 //virtual void resizeEvent(QResizeEvent * event);
149 //virtual void paintEvent(QPaintEvent * event);
153 MonitorManager *m_monitorManager;
154 DocClipBase *m_currentClip;
160 MonitorRefresh *m_monitorRefresh;
163 TimecodeDisplay *m_timePos;
164 QAction *m_playAction;
165 /** Has to be available so we can enable and disable it. */
166 QAction *m_loopClipAction;
167 QMenu *m_contextMenu;
171 QPoint m_DragStartPosition;
172 MonitorEditWidget *m_effectWidget;
173 VideoContainer *m_videoBox;
174 /** Selected clip/transition in timeline. Used for looping it. */
175 AbstractClipItem *m_selectedClip;
176 /** true if selected clip is transition, false = selected clip is clip.
177 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
178 bool m_loopClipTransition;
179 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
180 VideoGLWidget *m_glWidget;
181 bool createOpenGlWidget(QWidget *parent, const QString profile);
184 GenTime getSnapForPos(bool previous);
185 Qt::WindowFlags m_baseFlags;
187 QWidget *m_volumeWidget;
188 QSlider *m_audioSlider;
189 QAction *m_editMarker;
192 void seekCursor(int pos);
193 void rendererStopped(int pos);
194 void slotExtractCurrentFrame();
195 void slotSetThumbFrame();
196 void slotSetSizeOneToOne();
197 void slotSetSizeOneToTwo();
200 void setClipZone(QPoint pos);
201 void slotSwitchMonitorInfo(bool show);
202 void slotSwitchDropFrames(bool show);
203 void slotGoToMarker(QAction *action);
204 void slotSetVolume(int volume);
205 void slotShowVolume();
206 void slotEditMarker();
209 void slotOpenFile(const QString &);
210 void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
211 void refreshMonitor(bool visible);
212 void refreshMonitor();
213 void slotSeek(int pos);
216 void activateMonitor();
220 /** @brief Loops the selected item (clip or transition). */
222 void slotForward(double speed = 0);
223 void slotRewind(double speed = 0);
224 void slotRewindOneFrame(int diff = 1);
225 void slotForwardOneFrame(int diff = 1);
226 void saveSceneList(QString path, QDomElement info = QDomElement());
229 void slotSetZoneStart();
230 void slotSetZoneEnd();
231 void slotZoneStart();
233 void slotZoneMoved(int start, int end);
234 void slotSeekToNextSnap();
235 void slotSeekToPreviousSnap();
236 void adjustRulerSize(int length);
237 void setTimePos(const QString &pos);
238 QStringList getZoneInfo() const;
239 void slotEffectScene(bool show = true);
240 bool effectSceneDisplayed();
242 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
243 void slotSetSelectedClip(AbstractClipItem *item);
244 void slotSetSelectedClip(ClipItem *item);
245 void slotSetSelectedClip(Transition *item);
246 void slotMouseSeek(int eventDelta, bool fast);
247 void slotSwitchFullScreen();
250 void renderPosition(int);
251 void durationChanged(int);
252 void refreshClipThumbnail(const QString &, bool);
253 void adjustMonitorSize();
254 void zoneUpdated(QPoint);
255 void saveZone(Render *, QPoint);
256 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
257 * This causes a major slowdown, so we only enable it if required */
258 void requestFrameForAnalysis(bool);