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