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 "definitions.h"
27 #include "timecodedisplay.h"
28 #include "abstractmonitor.h"
30 #include "videoglwidget.h"
34 #include <QDomElement>
40 #include <KRestrictedLine>
44 class AbstractClipItem;
47 class MonitorEditWidget;
52 class MonitorRefresh : public QWidget
56 MonitorRefresh(QWidget *parent = 0);
57 void setRenderer(Render* render);
63 class Overlay : public QLabel
67 Overlay(QWidget* parent = 0);
68 void setOverlayText(const QString &, bool isZone = true);
74 virtual void mouseDoubleClickEvent ( QMouseEvent * event );
75 virtual void mousePressEvent ( QMouseEvent * event );
76 virtual void mouseReleaseEvent ( QMouseEvent * event );
82 class Monitor : public AbstractMonitor
87 Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
90 AbstractRender *abstractRender();
91 void resetProfile(const QString &profile);
95 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
96 const QString sceneList();
97 DocClipBase *activeClip();
100 void updateTimecodeFormat();
101 void updateMarkers(DocClipBase *source);
102 MonitorEditWidget *getEffectEdit();
103 QWidget *container();
104 void reloadProducer(const QString &id);
105 QFrame *m_volumePopup;
108 virtual void mousePressEvent(QMouseEvent * event);
109 virtual void mouseReleaseEvent(QMouseEvent * event);
110 virtual void mouseDoubleClickEvent(QMouseEvent * event);
111 virtual void resizeEvent(QResizeEvent *event);
113 /** @brief Move to another position on mouse wheel event.
115 * Moves towards the end of the clip/timeline on mouse wheel down/back, the
116 * opposite on mouse wheel up/forward.
117 * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
118 virtual void wheelEvent(QWheelEvent * event);
119 virtual void mouseMoveEvent(QMouseEvent *event);
120 virtual QStringList mimeTypes() const;
121 /*virtual void dragMoveEvent(QDragMoveEvent * event);
122 virtual Qt::DropActions supportedDropActions() const;*/
124 //virtual void resizeEvent(QResizeEvent * event);
125 //virtual void paintEvent(QPaintEvent * event);
128 Kdenlive::MONITORID m_name;
129 DocClipBase *m_currentClip;
135 MonitorRefresh *m_monitorRefresh;
138 TimecodeDisplay *m_timePos;
139 QAction *m_playAction;
140 /** Has to be available so we can enable and disable it. */
141 QAction *m_loopClipAction;
142 QMenu *m_contextMenu;
146 QPoint m_DragStartPosition;
147 MonitorEditWidget *m_effectWidget;
148 VideoContainer *m_videoBox;
149 /** Selected clip/transition in timeline. Used for looping it. */
150 AbstractClipItem *m_selectedClip;
151 /** true if selected clip is transition, false = selected clip is clip.
152 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
153 bool m_loopClipTransition;
156 VideoGLWidget *m_glWidget;
157 bool createOpenGlWidget(QWidget *parent, const QString profile);
160 GenTime getSnapForPos(bool previous);
161 Qt::WindowFlags m_baseFlags;
163 QWidget *m_volumeWidget;
164 QSlider *m_audioSlider;
165 QAction *m_editMarker;
168 void seekCursor(int pos);
169 void rendererStopped(int pos);
170 void slotExtractCurrentFrame();
171 void slotSetThumbFrame();
172 void slotSetSizeOneToOne();
173 void slotSetSizeOneToTwo();
176 void setClipZone(QPoint pos);
177 void slotSwitchMonitorInfo(bool show);
178 void slotSwitchDropFrames(bool show);
179 void slotGoToMarker(QAction *action);
180 void slotSetVolume(int volume);
181 void slotShowVolume();
182 void slotEditMarker();
183 void slotExtractCurrentZone();
186 void slotOpenFile(const QString &);
187 void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
188 void updateClipProducer(Mlt::Producer *prod);
189 void refreshMonitor(bool visible);
190 void refreshMonitor();
191 void slotSeek(int pos);
197 /** @brief Loops the selected item (clip or transition). */
199 void slotForward(double speed = 0);
200 void slotRewind(double speed = 0);
201 void slotRewindOneFrame(int diff = 1);
202 void slotForwardOneFrame(int diff = 1);
203 void saveSceneList(QString path, QDomElement info = QDomElement());
206 void slotSetZoneStart();
207 void slotSetZoneEnd();
208 void slotZoneStart();
210 void slotZoneMoved(int start, int end);
211 void slotSeekToNextSnap();
212 void slotSeekToPreviousSnap();
213 void adjustRulerSize(int length);
214 void setTimePos(const QString &pos);
215 QStringList getZoneInfo() const;
216 void slotEffectScene(bool show = true);
217 bool effectSceneDisplayed();
219 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
220 void slotSetSelectedClip(AbstractClipItem *item);
221 void slotSetSelectedClip(ClipItem *item);
222 void slotSetSelectedClip(Transition *item);
223 void slotMouseSeek(int eventDelta, bool fast);
224 void slotSwitchFullScreen();
227 void renderPosition(int);
228 void durationChanged(int);
229 void refreshClipThumbnail(const QString &, bool);
230 void adjustMonitorSize();
231 void zoneUpdated(QPoint);
232 void saveZone(Render *, QPoint, DocClipBase *);
233 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
234 * This causes a major slowdown, so we only enable it if required */
235 void requestFrameForAnalysis(bool);
236 /** @brief Request a zone extraction (ffmpeg transcoding). */
237 void extractZone(const QString &id, QPoint zone);