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