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>
41 class AbstractClipItem;
44 class MonitorEditWidget;
50 class Overlay : public QLabel
54 Overlay(QWidget* parent = 0);
55 void setOverlayText(const QString &, bool isZone = true);
58 void mouseDoubleClickEvent ( QMouseEvent * event );
59 void mousePressEvent ( QMouseEvent * event );
60 void mouseReleaseEvent ( QMouseEvent * event );
66 class Monitor : public AbstractMonitor
71 Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
74 AbstractRender *abstractRender();
75 void resetProfile(const QString &profile);
76 void setCustomProfile(const QString &profile, const Timecode &tc);
80 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
81 const QString sceneList();
82 DocClipBase *activeClip();
85 void updateTimecodeFormat();
86 void updateMarkers(DocClipBase *source);
87 void setMarkers(const QList <CommentedTime> &markers);
88 MonitorEditWidget *getEffectEdit();
90 void reloadProducer(const QString &id);
91 QFrame *m_volumePopup;
92 /** @brief Reimplemented from QWidget, updates the palette colors. */
93 void setPalette ( const QPalette & p);
94 /** @brief Returns a hh:mm:ss timecode from a frame number. */
95 QString getTimecodeFromFrames(int pos);
96 /** @brief Returns current project's fps. */
98 /** @brief Get url for the clip's thumbnail */
99 QString getMarkerThumb(GenTime pos);
102 void mousePressEvent(QMouseEvent * event);
103 void mouseReleaseEvent(QMouseEvent * event);
104 void mouseDoubleClickEvent(QMouseEvent * event);
105 void resizeEvent(QResizeEvent *event);
107 /** @brief Move to another position on mouse wheel event.
109 * Moves towards the end of the clip/timeline on mouse wheel down/back, the
110 * opposite on mouse wheel up/forward.
111 * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
112 void wheelEvent(QWheelEvent * event);
113 void mouseMoveEvent(QMouseEvent *event);
114 virtual QStringList mimeTypes() const;
116 /*virtual void dragMoveEvent(QDragMoveEvent * event);
117 virtual Qt::DropActions supportedDropActions() const;*/
119 //virtual void resizeEvent(QResizeEvent * event);
120 //virtual void paintEvent(QPaintEvent * event);
123 DocClipBase *m_currentClip;
131 TimecodeDisplay *m_timePos;
132 QAction *m_playAction;
133 /** Has to be available so we can enable and disable it. */
134 QAction *m_loopClipAction;
135 QMenu *m_contextMenu;
139 QPoint m_DragStartPosition;
140 MonitorEditWidget *m_effectWidget;
141 /** Selected clip/transition in timeline. Used for looping it. */
142 AbstractClipItem *m_selectedClip;
143 /** true if selected clip is transition, false = selected clip is clip.
144 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
145 bool m_loopClipTransition;
148 VideoGLWidget *m_glWidget;
149 bool createOpenGlWidget(QWidget *parent, const QString &profile);
152 GenTime getSnapForPos(bool previous);
153 Qt::WindowFlags m_baseFlags;
155 QWidget *m_volumeWidget;
156 QSlider *m_audioSlider;
157 QAction *m_editMarker;
160 void seekCursor(int pos);
161 void rendererStopped(int pos);
162 void slotExtractCurrentFrame();
163 void slotSetThumbFrame();
164 void slotSetSizeOneToOne();
165 void slotSetSizeOneToTwo();
168 void setClipZone(const QPoint &pos);
169 void slotSwitchMonitorInfo(bool show);
170 void slotSwitchDropFrames(bool show);
171 void slotGoToMarker(QAction *action);
172 void slotSetVolume(int volume);
173 void slotShowVolume();
174 void slotEditMarker();
175 void slotExtractCurrentZone();
178 void slotOpenFile(const QString &);
179 void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
180 void updateClipProducer(Mlt::Producer *prod);
181 void refreshMonitor(bool visible);
182 void refreshMonitor();
183 void slotSeek(int pos);
189 /** @brief Loops the selected item (clip or transition). */
191 void slotForward(double speed = 0);
192 void slotRewind(double speed = 0);
193 void slotRewindOneFrame(int diff = 1);
194 void slotForwardOneFrame(int diff = 1);
195 void saveSceneList(const QString &path, const QDomElement &info = QDomElement());
198 void slotSetZoneStart();
199 void slotSetZoneEnd();
200 void slotZoneStart();
202 void slotZoneMoved(int start, int end);
203 void slotSeekToNextSnap();
204 void slotSeekToPreviousSnap();
205 void adjustRulerSize(int length);
206 void setTimePos(const QString &pos);
207 QStringList getZoneInfo() const;
208 /** @brief Display the on monitor effect scene (to adjust geometry over monitor). */
209 void slotShowEffectScene(bool show = true, bool manuallyTriggered = false);
210 bool effectSceneDisplayed();
212 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
213 void slotSetSelectedClip(AbstractClipItem *item);
214 void slotSetSelectedClip(ClipItem *item);
215 void slotSetSelectedClip(Transition *item);
216 void slotMouseSeek(int eventDelta, bool fast);
217 void slotSwitchFullScreen();
220 void renderPosition(int);
221 void durationChanged(int);
222 void refreshClipThumbnail(const QString &, bool);
223 void adjustMonitorSize();
224 void zoneUpdated(const QPoint&);
225 void saveZone(Render *, const QPoint&, DocClipBase *);
226 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
227 * This causes a major slowdown, so we only enable it if required */
228 void requestFrameForAnalysis(bool);
229 /** @brief Request a zone extraction (ffmpeg transcoding). */
230 void extractZone(const QString &id, const QPoint &zone);