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 virtual void wheelEvent(QWheelEvent * event);
64 Qt::WindowFlags m_baseFlags;
68 class MonitorRefresh : public QWidget
72 MonitorRefresh(QWidget *parent = 0);
73 void setRenderer(Render* render);
76 virtual void paintEvent(QPaintEvent *event);
82 void switchFullScreen();
84 void mouseSeek(int, bool);
87 class Overlay : public QLabel
91 Overlay(QWidget* parent);
92 void setOverlayText(const QString &, bool isZone = true);
98 class Monitor : public QWidget
103 Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
106 void resetProfile(const QString profile);
107 QString name() const;
109 bool isActive() const;
111 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
112 const QString sceneList();
113 DocClipBase *activeClip();
116 void updateTimecodeFormat();
117 void updateMarkers(DocClipBase *source);
118 MonitorScene *getEffectScene();
119 QWidget *container();
122 virtual void mousePressEvent(QMouseEvent * event);
123 virtual void mouseReleaseEvent(QMouseEvent * event);
125 /** @brief Move to another position on mouse wheel event.
127 * Moves towards the end of the clip/timeline on mouse wheel down/back, the
128 * opposite on mouse wheel up/forward.
129 * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
130 virtual void wheelEvent(QWheelEvent * event);
131 virtual void mouseMoveEvent(QMouseEvent *event);
132 virtual QStringList mimeTypes() const;
133 /*virtual void dragMoveEvent(QDragMoveEvent * event);
134 virtual Qt::DropActions supportedDropActions() const;*/
136 //virtual void resizeEvent(QResizeEvent * event);
137 //virtual void paintEvent(QPaintEvent * event);
141 MonitorManager *m_monitorManager;
142 DocClipBase *m_currentClip;
149 MonitorRefresh *m_monitorRefresh;
152 TimecodeDisplay *m_timePos;
153 QAction *m_playAction;
154 /** Has to be available so we can enable and disable it. */
155 QAction *m_loopClipAction;
156 QMenu *m_contextMenu;
160 QPoint m_DragStartPosition;
161 MonitorScene *m_effectScene;
162 QGraphicsView *m_effectView;
163 VideoContainer *m_videoBox;
164 /** Selected clip/transition in timeline. Used for looping it. */
165 AbstractClipItem *m_selectedClip;
166 /** true if selected clip is transition, false = selected clip is clip.
167 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
168 bool m_loopClipTransition;
169 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
170 VideoGLWidget *m_glWidget;
171 bool createOpenGlWidget(QWidget *parent, const QString profile);
174 GenTime getSnapForPos(bool previous);
175 Qt::WindowFlags m_baseFlags;
178 void seekCursor(int pos);
179 void rendererStopped(int pos);
180 void slotExtractCurrentFrame();
181 void slotSetThumbFrame();
182 void slotSetSizeOneToOne();
183 void slotSetSizeOneToTwo();
186 void setClipZone(QPoint pos);
187 void slotSwitchMonitorInfo(bool show);
188 void slotSwitchDropFrames(bool show);
189 void slotGoToMarker(QAction *action);
192 void slotOpenFile(const QString &);
193 void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
194 void refreshMonitor(bool visible);
195 void refreshMonitor();
196 void slotSeek(int pos);
199 void activateMonitor();
203 /** @brief Loops the selected item (clip or transition). */
205 void slotForward(double speed = 0);
206 void slotRewind(double speed = 0);
207 void slotRewindOneFrame(int diff = 1);
208 void slotForwardOneFrame(int diff = 1);
209 void saveSceneList(QString path, QDomElement info = QDomElement());
212 void slotSetZoneStart();
213 void slotSetZoneEnd();
214 void slotZoneStart();
216 void slotZoneMoved(int start, int end);
217 void slotSeekToNextSnap();
218 void slotSeekToPreviousSnap();
219 void adjustRulerSize(int length);
220 void setTimePos(const QString &pos);
221 QStringList getZoneInfo() const;
222 void slotEffectScene(bool show = true);
223 bool effectSceneDisplayed();
225 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
226 void slotSetSelectedClip(AbstractClipItem *item);
227 void slotSetSelectedClip(ClipItem *item);
228 void slotSetSelectedClip(Transition *item);
229 void slotMouseSeek(int eventDelta, bool fast);
230 void slotSwitchFullScreen();
233 void renderPosition(int);
234 void durationChanged(int);
235 void refreshClipThumbnail(const QString &);
236 void adjustMonitorSize();
237 void zoneUpdated(QPoint);
238 void saveZone(Render *, QPoint);
239 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
240 * This causes a major slowdown, so we only enable it if required */
241 void requestFrameForAnalysis(bool);