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>
45 class AbstractClipItem;
49 class QGraphicsPixmapItem;
53 class VideoContainer : public QFrame
57 VideoContainer(Monitor *parent = 0);
58 void switchFullScreen();
61 virtual void mouseDoubleClickEvent(QMouseEvent * event);
62 virtual void mousePressEvent(QMouseEvent * event);
63 virtual void mouseReleaseEvent(QMouseEvent *event);
64 virtual void mouseMoveEvent(QMouseEvent *event);
65 void keyPressEvent(QKeyEvent *event);
66 virtual void wheelEvent(QWheelEvent * event);
69 Qt::WindowFlags m_baseFlags;
73 class MonitorRefresh : public QWidget
77 MonitorRefresh(QWidget *parent = 0);
78 void setRenderer(Render* render);
81 virtual void paintEvent(QPaintEvent *event);
87 void switchFullScreen();
89 void mouseSeek(int, bool);
92 class Overlay : public QLabel
96 Overlay(QWidget* parent);
97 void setOverlayText(const QString &, bool isZone = true);
103 class Monitor : public QWidget
108 Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
111 void resetProfile(const QString profile);
112 QString name() const;
114 bool isActive() const;
116 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
117 const QString sceneList();
118 DocClipBase *activeClip();
121 void updateTimecodeFormat();
122 void updateMarkers(DocClipBase *source);
123 MonitorScene *getEffectScene();
124 QWidget *container();
125 QFrame *m_volumePopup;
128 virtual void mousePressEvent(QMouseEvent * event);
129 virtual void mouseReleaseEvent(QMouseEvent * 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;
155 MonitorRefresh *m_monitorRefresh;
158 TimecodeDisplay *m_timePos;
159 QAction *m_playAction;
160 /** Has to be available so we can enable and disable it. */
161 QAction *m_loopClipAction;
162 QMenu *m_contextMenu;
166 QPoint m_DragStartPosition;
167 MonitorScene *m_effectScene;
168 QGraphicsView *m_effectView;
169 VideoContainer *m_videoBox;
170 /** Selected clip/transition in timeline. Used for looping it. */
171 AbstractClipItem *m_selectedClip;
172 /** true if selected clip is transition, false = selected clip is clip.
173 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
174 bool m_loopClipTransition;
175 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
176 VideoGLWidget *m_glWidget;
177 bool createOpenGlWidget(QWidget *parent, const QString profile);
180 GenTime getSnapForPos(bool previous);
181 Qt::WindowFlags m_baseFlags;
183 QWidget *m_volumeWidget;
184 QSlider *m_audioSlider;
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();
203 void slotOpenFile(const QString &);
204 void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
205 void refreshMonitor(bool visible);
206 void refreshMonitor();
207 void slotSeek(int pos);
210 void activateMonitor();
214 /** @brief Loops the selected item (clip or transition). */
216 void slotForward(double speed = 0);
217 void slotRewind(double speed = 0);
218 void slotRewindOneFrame(int diff = 1);
219 void slotForwardOneFrame(int diff = 1);
220 void saveSceneList(QString path, QDomElement info = QDomElement());
223 void slotSetZoneStart();
224 void slotSetZoneEnd();
225 void slotZoneStart();
227 void slotZoneMoved(int start, int end);
228 void slotSeekToNextSnap();
229 void slotSeekToPreviousSnap();
230 void adjustRulerSize(int length);
231 void setTimePos(const QString &pos);
232 QStringList getZoneInfo() const;
233 void slotEffectScene(bool show = true);
234 bool effectSceneDisplayed();
236 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
237 void slotSetSelectedClip(AbstractClipItem *item);
238 void slotSetSelectedClip(ClipItem *item);
239 void slotSetSelectedClip(Transition *item);
240 void slotMouseSeek(int eventDelta, bool fast);
241 void slotSwitchFullScreen();
244 void renderPosition(int);
245 void durationChanged(int);
246 void refreshClipThumbnail(const QString &);
247 void adjustMonitorSize();
248 void zoneUpdated(QPoint);
249 void saveZone(Render *, QPoint);
250 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
251 * This causes a major slowdown, so we only enable it if required */
252 void requestFrameForAnalysis(bool);