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);
81 void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
82 const QString sceneList();
83 DocClipBase *activeClip();
86 void updateTimecodeFormat();
87 void updateMarkers(DocClipBase *source);
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);
96 virtual void mousePressEvent(QMouseEvent * event);
97 virtual void mouseReleaseEvent(QMouseEvent * event);
98 virtual void mouseDoubleClickEvent(QMouseEvent * event);
99 virtual void resizeEvent(QResizeEvent *event);
101 /** @brief Move to another position on mouse wheel event.
103 * Moves towards the end of the clip/timeline on mouse wheel down/back, the
104 * opposite on mouse wheel up/forward.
105 * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
106 virtual void wheelEvent(QWheelEvent * event);
107 virtual void mouseMoveEvent(QMouseEvent *event);
108 virtual QStringList mimeTypes() const;
109 /*virtual void dragMoveEvent(QDragMoveEvent * event);
110 virtual Qt::DropActions supportedDropActions() const;*/
112 //virtual void resizeEvent(QResizeEvent * event);
113 //virtual void paintEvent(QPaintEvent * event);
116 Kdenlive::MONITORID m_name;
117 DocClipBase *m_currentClip;
125 TimecodeDisplay *m_timePos;
126 QAction *m_playAction;
127 /** Has to be available so we can enable and disable it. */
128 QAction *m_loopClipAction;
129 QMenu *m_contextMenu;
133 QPoint m_DragStartPosition;
134 MonitorEditWidget *m_effectWidget;
135 VideoContainer *m_videoBox;
136 /** Selected clip/transition in timeline. Used for looping it. */
137 AbstractClipItem *m_selectedClip;
138 /** true if selected clip is transition, false = selected clip is clip.
139 * Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
140 bool m_loopClipTransition;
143 VideoGLWidget *m_glWidget;
144 bool createOpenGlWidget(QWidget *parent, const QString profile);
147 GenTime getSnapForPos(bool previous);
148 Qt::WindowFlags m_baseFlags;
150 QWidget *m_volumeWidget;
151 QSlider *m_audioSlider;
152 QAction *m_editMarker;
155 void seekCursor(int pos);
156 void rendererStopped(int pos);
157 void slotExtractCurrentFrame();
158 void slotSetThumbFrame();
159 void slotSetSizeOneToOne();
160 void slotSetSizeOneToTwo();
163 void setClipZone(QPoint pos);
164 void slotSwitchMonitorInfo(bool show);
165 void slotSwitchDropFrames(bool show);
166 void slotGoToMarker(QAction *action);
167 void slotSetVolume(int volume);
168 void slotShowVolume();
169 void slotEditMarker();
170 void slotExtractCurrentZone();
173 void slotOpenFile(const QString &);
174 void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
175 void updateClipProducer(Mlt::Producer *prod);
176 void refreshMonitor(bool visible);
177 void refreshMonitor();
178 void slotSeek(int pos);
184 /** @brief Loops the selected item (clip or transition). */
186 void slotForward(double speed = 0);
187 void slotRewind(double speed = 0);
188 void slotRewindOneFrame(int diff = 1);
189 void slotForwardOneFrame(int diff = 1);
190 void saveSceneList(QString path, QDomElement info = QDomElement());
193 void slotSetZoneStart();
194 void slotSetZoneEnd();
195 void slotZoneStart();
197 void slotZoneMoved(int start, int end);
198 void slotSeekToNextSnap();
199 void slotSeekToPreviousSnap();
200 void adjustRulerSize(int length);
201 void setTimePos(const QString &pos);
202 QStringList getZoneInfo() const;
203 /** @brief Display the on monitor effect scene (to adjust geometry over monitor). */
204 void slotShowEffectScene(bool show = true, bool manuallyTriggered = false);
205 bool effectSceneDisplayed();
207 /** @brief Sets m_selectedClip to @param item. Used for looping it. */
208 void slotSetSelectedClip(AbstractClipItem *item);
209 void slotSetSelectedClip(ClipItem *item);
210 void slotSetSelectedClip(Transition *item);
211 void slotMouseSeek(int eventDelta, bool fast);
212 void slotSwitchFullScreen();
215 void renderPosition(int);
216 void durationChanged(int);
217 void refreshClipThumbnail(const QString &, bool);
218 void adjustMonitorSize();
219 void zoneUpdated(QPoint);
220 void saveZone(Render *, QPoint, DocClipBase *);
221 /** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
222 * This causes a major slowdown, so we only enable it if required */
223 void requestFrameForAnalysis(bool);
224 /** @brief Request a zone extraction (ffmpeg transcoding). */
225 void extractZone(const QString &id, QPoint zone);