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 ***************************************************************************/
25 #include "timecodedisplay.h"
26 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
27 #include "videoglwidget.h"
31 #include <QDomElement>
37 #include <KRestrictedLine>
44 class AbstractClipItem;
47 class MonitorEditWidget;
51 class VideoContainer : public QFrame
55 VideoContainer(Monitor *parent = 0);
56 void switchFullScreen();
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);
67 Qt::WindowFlags m_baseFlags;
71 class MonitorRefresh : public QWidget
75 MonitorRefresh(QWidget *parent = 0);
76 void setRenderer(Render* render);
79 virtual void paintEvent(QPaintEvent *event);
85 void switchFullScreen();
87 void mouseSeek(int, bool);
90 class Overlay : public QLabel
94 Overlay(QWidget* parent);
95 void setOverlayText(const QString &, bool isZone = true);
101 class Monitor : public QWidget
106 Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
109 void resetProfile(const QString profile);
110 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 QFrame *m_volumePopup;
126 virtual void mousePressEvent(QMouseEvent * event);
127 virtual void mouseReleaseEvent(QMouseEvent * event);
129 /** @brief Move to another position on mouse wheel event.
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;*/
140 //virtual void resizeEvent(QResizeEvent * event);
141 //virtual void paintEvent(QPaintEvent * event);
145 MonitorManager *m_monitorManager;
146 DocClipBase *m_currentClip;
153 MonitorRefresh *m_monitorRefresh;
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;
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);
177 GenTime getSnapForPos(bool previous);
178 Qt::WindowFlags m_baseFlags;
180 QWidget *m_volumeWidget;
181 QSlider *m_audioSlider;
184 void seekCursor(int pos);
185 void rendererStopped(int pos);
186 void slotExtractCurrentFrame();
187 void slotSetThumbFrame();
188 void slotSetSizeOneToOne();
189 void slotSetSizeOneToTwo();
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();
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);
207 void activateMonitor();
211 /** @brief Loops the selected item (clip or transition). */
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());
220 void slotSetZoneStart();
221 void slotSetZoneEnd();
222 void slotZoneStart();
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();
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();
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);