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"
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);
81 class Overlay : public QLabel
85 Overlay(QWidget* parent = 0);
86 void setOverlayText(const QString &, bool isZone = true);
92 virtual void mouseDoubleClickEvent ( QMouseEvent * event );
93 virtual void mousePressEvent ( QMouseEvent * event );
94 virtual void mouseReleaseEvent ( QMouseEvent * event );
100 class Monitor : public AbstractMonitor
105 Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
108 AbstractRender *abstractRender();
109 void resetProfile(const QString &profile);
110 const QString name() const;
112 bool isActive() const;
114 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
115 const QString sceneList();
116 DocClipBase *activeClip();
119 void updateTimecodeFormat();
120 void updateMarkers(DocClipBase *source);
121 MonitorEditWidget *getEffectEdit();
122 QWidget *container();
123 void reloadProducer(const QString &id);
124 QFrame *m_volumePopup;
127 virtual void mousePressEvent(QMouseEvent * event);
128 virtual void mouseReleaseEvent(QMouseEvent * event);
129 virtual void resizeEvent(QResizeEvent *event);
131 /** @brief Move to another position on mouse wheel event.
133 * Moves towards the end of the clip/timeline on mouse wheel down/back, the
134 * opposite on mouse wheel up/forward.
135 * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
136 virtual void wheelEvent(QWheelEvent * event);
137 virtual void mouseMoveEvent(QMouseEvent *event);
138 virtual QStringList mimeTypes() const;
139 /*virtual void dragMoveEvent(QDragMoveEvent * event);
140 virtual Qt::DropActions supportedDropActions() const;*/
142 //virtual void resizeEvent(QResizeEvent * event);
143 //virtual void paintEvent(QPaintEvent * event);
147 MonitorManager *m_monitorManager;
148 DocClipBase *m_currentClip;
154 MonitorRefresh *m_monitorRefresh;
157 TimecodeDisplay *m_timePos;
158 QAction *m_playAction;
159 /** Has to be available so we can enable and disable it. */
160 QAction *m_loopClipAction;
161 QMenu *m_contextMenu;
165 QPoint m_DragStartPosition;
166 MonitorEditWidget *m_effectWidget;
167 VideoContainer *m_videoBox;
168 /** Selected clip/transition in timeline. Used for looping it. */
169 AbstractClipItem *m_selectedClip;
170 /** true if selected clip is transition, false = selected clip is clip.
171 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
172 bool m_loopClipTransition;
175 VideoGLWidget *m_glWidget;
176 bool createOpenGlWidget(QWidget *parent, const QString profile);
179 GenTime getSnapForPos(bool previous);
180 Qt::WindowFlags m_baseFlags;
182 QWidget *m_volumeWidget;
183 QSlider *m_audioSlider;
184 QAction *m_editMarker;
187 void seekCursor(int pos);
188 void rendererStopped(int pos);
189 void slotExtractCurrentFrame();
190 void slotSetThumbFrame();
191 void slotSetSizeOneToOne();
192 void slotSetSizeOneToTwo();
195 void setClipZone(QPoint pos);
196 void slotSwitchMonitorInfo(bool show);
197 void slotSwitchDropFrames(bool show);
198 void slotGoToMarker(QAction *action);
199 void slotSetVolume(int volume);
200 void slotShowVolume();
201 void slotEditMarker();
202 void slotExtractCurrentZone();
205 void slotOpenFile(const QString &);
206 void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
207 void updateClipProducer(Mlt::Producer *prod);
208 void refreshMonitor(bool visible);
209 void refreshMonitor();
210 void slotSeek(int pos);
213 bool activateMonitor();
217 /** @brief Loops the selected item (clip or transition). */
219 void slotForward(double speed = 0);
220 void slotRewind(double speed = 0);
221 void slotRewindOneFrame(int diff = 1);
222 void slotForwardOneFrame(int diff = 1);
223 void saveSceneList(QString path, QDomElement info = QDomElement());
226 void slotSetZoneStart();
227 void slotSetZoneEnd();
228 void slotZoneStart();
230 void slotZoneMoved(int start, int end);
231 void slotSeekToNextSnap();
232 void slotSeekToPreviousSnap();
233 void adjustRulerSize(int length);
234 void setTimePos(const QString &pos);
235 QStringList getZoneInfo() const;
236 void slotEffectScene(bool show = true);
237 bool effectSceneDisplayed();
239 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
240 void slotSetSelectedClip(AbstractClipItem *item);
241 void slotSetSelectedClip(ClipItem *item);
242 void slotSetSelectedClip(Transition *item);
243 void slotMouseSeek(int eventDelta, bool fast);
244 void slotSwitchFullScreen();
247 void renderPosition(int);
248 void durationChanged(int);
249 void refreshClipThumbnail(const QString &, bool);
250 void adjustMonitorSize();
251 void zoneUpdated(QPoint);
252 void saveZone(Render *, QPoint, DocClipBase *);
253 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
254 * This causes a major slowdown, so we only enable it if required */
255 void requestFrameForAnalysis(bool);
256 /** @brief Request a zone extraction (ffmpeg transcoding). */
257 void extractZone(const QString &id, QPoint zone);