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 ***************************************************************************/
27 #include <KRestrictedLine>
28 #include <QDomElement>
31 #include "timecodedisplay.h"
32 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
33 #include "videoglwidget.h"
41 class AbstractClipItem;
45 class QGraphicsPixmapItem;
49 class VideoContainer : public QFrame
53 VideoContainer(Monitor *parent = 0);
54 void switchFullScreen();
57 virtual void mouseDoubleClickEvent(QMouseEvent * event);
58 virtual void mousePressEvent(QMouseEvent * event);
59 virtual void mouseReleaseEvent(QMouseEvent *event);
60 virtual void mouseMoveEvent(QMouseEvent *event);
61 void keyPressEvent(QKeyEvent *event);
62 virtual void wheelEvent(QWheelEvent * event);
65 Qt::WindowFlags m_baseFlags;
69 class MonitorRefresh : public QWidget
73 MonitorRefresh(QWidget *parent = 0);
74 void setRenderer(Render* render);
77 virtual void paintEvent(QPaintEvent *event);
83 void switchFullScreen();
85 void mouseSeek(int, bool);
88 class Overlay : public QLabel
92 Overlay(QWidget* parent);
93 void setOverlayText(const QString &, bool isZone = true);
99 class Monitor : public QWidget
104 Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
107 void resetProfile(const QString profile);
108 QString name() const;
110 bool isActive() const;
112 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
113 const QString sceneList();
114 DocClipBase *activeClip();
117 void updateTimecodeFormat();
118 void updateMarkers(DocClipBase *source);
119 MonitorScene *getEffectScene();
120 QWidget *container();
123 virtual void mousePressEvent(QMouseEvent * event);
124 virtual void mouseReleaseEvent(QMouseEvent * event);
126 /** @brief Move to another position on mouse wheel event.
128 * Moves towards the end of the clip/timeline on mouse wheel down/back, the
129 * opposite on mouse wheel up/forward.
130 * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
131 virtual void wheelEvent(QWheelEvent * event);
132 virtual void mouseMoveEvent(QMouseEvent *event);
133 virtual QStringList mimeTypes() const;
134 /*virtual void dragMoveEvent(QDragMoveEvent * event);
135 virtual Qt::DropActions supportedDropActions() const;*/
137 //virtual void resizeEvent(QResizeEvent * event);
138 //virtual void paintEvent(QPaintEvent * event);
142 MonitorManager *m_monitorManager;
143 DocClipBase *m_currentClip;
150 MonitorRefresh *m_monitorRefresh;
153 TimecodeDisplay *m_timePos;
154 QAction *m_playAction;
155 /** Has to be available so we can enable and disable it. */
156 QAction *m_loopClipAction;
157 QMenu *m_contextMenu;
161 QPoint m_DragStartPosition;
162 MonitorScene *m_effectScene;
163 QGraphicsView *m_effectView;
164 VideoContainer *m_videoBox;
165 /** Selected clip/transition in timeline. Used for looping it. */
166 AbstractClipItem *m_selectedClip;
167 /** true if selected clip is transition, false = selected clip is clip.
168 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
169 bool m_loopClipTransition;
170 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
171 VideoGLWidget *m_glWidget;
172 bool createOpenGlWidget(QWidget *parent, const QString profile);
175 GenTime getSnapForPos(bool previous);
176 Qt::WindowFlags m_baseFlags;
179 void seekCursor(int pos);
180 void rendererStopped(int pos);
181 void slotExtractCurrentFrame();
182 void slotSetThumbFrame();
183 void slotSetSizeOneToOne();
184 void slotSetSizeOneToTwo();
187 void setClipZone(QPoint pos);
188 void slotSwitchMonitorInfo(bool show);
189 void slotSwitchDropFrames(bool show);
190 void slotGoToMarker(QAction *action);
193 void slotOpenFile(const QString &);
194 void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
195 void refreshMonitor(bool visible);
196 void refreshMonitor();
197 void slotSeek(int pos);
200 void activateMonitor();
204 /** @brief Loops the selected item (clip or transition). */
206 void slotForward(double speed = 0);
207 void slotRewind(double speed = 0);
208 void slotRewindOneFrame(int diff = 1);
209 void slotForwardOneFrame(int diff = 1);
210 void saveSceneList(QString path, QDomElement info = QDomElement());
213 void slotSetZoneStart();
214 void slotSetZoneEnd();
215 void slotZoneStart();
217 void slotZoneMoved(int start, int end);
218 void slotSeekToNextSnap();
219 void slotSeekToPreviousSnap();
220 void adjustRulerSize(int length);
221 void setTimePos(const QString &pos);
222 QStringList getZoneInfo() const;
223 void slotEffectScene(bool show = true);
224 bool effectSceneDisplayed();
226 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
227 void slotSetSelectedClip(AbstractClipItem *item);
228 void slotSetSelectedClip(ClipItem *item);
229 void slotSetSelectedClip(Transition *item);
230 void slotMouseSeek(int eventDelta, bool fast);
231 void slotSwitchFullScreen();
234 void renderPosition(int);
235 void durationChanged(int);
236 void refreshClipThumbnail(const QString &);
237 void adjustMonitorSize();
238 void zoneUpdated(QPoint);
239 void saveZone(Render *, QPoint);
240 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
241 * This causes a major slowdown, so we only enable it if required */
242 void requestFrameForAnalysis(bool);