]> git.sesse.net Git - kdenlive/blob - src/monitor.h
604dd39a52d61c8248660f3d3e379965f12ae661
[kdenlive] / src / monitor.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20 #ifndef MONITOR_H
21 #define MONITOR_H
22
23
24 #include "gentime.h"
25 #include "renderer.h"
26 #include "definitions.h"
27 #include "timecodedisplay.h"
28 #include "widgets/abstractmonitor.h"
29 #include "widgets/videoglwidget.h"
30
31 #include <QLabel>
32 #include <QDomElement>
33 #include <QToolBar>
34
35 #include <KIcon>
36
37 class SmallRuler;
38 class DocClipBase;
39 class AbstractClipItem;
40 class Transition;
41 class ClipItem;
42 class MonitorEditWidget;
43 class Monitor;
44 class MonitorManager;
45 class QSlider;
46 class VideoGLWidget;
47 class QGLWidget;
48
49 class Overlay : public QLabel
50 {
51     Q_OBJECT
52 public:
53     Overlay(QWidget* parent = 0);
54     void setOverlayText(const QString &, bool isZone = true);
55
56 protected:
57     void mouseDoubleClickEvent ( QMouseEvent * event );
58     void mousePressEvent ( QMouseEvent * event );
59     void mouseReleaseEvent ( QMouseEvent * event );
60     
61 signals:
62     void editMarker();
63 };
64
65 class Monitor : public AbstractMonitor
66 {
67     Q_OBJECT
68
69 public:
70     Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
71     ~Monitor();
72     Render *render;
73     AbstractRender *abstractRender();
74     void resetProfile(const QString &profile);
75     void setCustomProfile(const QString &profile, const Timecode &tc);
76     void resetSize();
77     void pause();
78     void unpause();
79     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
80     const QString sceneList();
81     DocClipBase *activeClip();
82     GenTime position();
83     void checkOverlay();
84     void updateTimecodeFormat();
85     void updateMarkers(DocClipBase *source);
86     void setMarkers(const QList <CommentedTime> &markers);
87     MonitorEditWidget *getEffectEdit();
88     QWidget *container();
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. */
96     double fps() const;
97     /** @brief Get url for the clip's thumbnail */
98     QString getMarkerThumb(GenTime pos);
99
100 protected:
101     void mousePressEvent(QMouseEvent * event);
102     void mouseReleaseEvent(QMouseEvent * event);
103     void resizeEvent(QResizeEvent *event);
104
105     /** @brief Move to another position on mouse wheel event.
106      *
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;
113    
114     /*virtual void dragMoveEvent(QDragMoveEvent * event);
115     virtual Qt::DropActions supportedDropActions() const;*/
116
117     //virtual void resizeEvent(QResizeEvent * event);
118     //virtual void paintEvent(QPaintEvent * event);
119
120 private:
121     DocClipBase *m_currentClip;
122     SmallRuler *m_ruler;
123     Overlay *m_overlay;
124     double m_scale;
125     int m_length;
126     bool m_dragStarted;
127     KIcon m_playIcon;
128     KIcon m_pauseIcon;
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;
134     QMenu *m_configMenu;
135     QMenu *m_playMenu;
136     QMenu *m_markerMenu;
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;
144     VideoGLWidget *m_glWidget;
145     void createOpenGlWidget(QWidget *parent, const QString &profile);
146
147     GenTime getSnapForPos(bool previous);
148     Qt::WindowFlags m_baseFlags;
149     QToolBar *m_toolbar;
150     QWidget *m_volumeWidget;
151     QSlider *m_audioSlider;
152     QAction *m_editMarker;
153
154 private slots:
155     void seekCursor(int pos);
156     void rendererStopped(int pos);
157     void slotExtractCurrentFrame();
158     void slotSetThumbFrame();
159     void slotSetSizeOneToOne();
160     void slotSetSizeOneToTwo();
161     void slotSaveZone();
162     void slotSeek();
163     void setClipZone(const 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();
171
172 public slots:
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);
179     void stop();
180     void start();
181     void slotPlay();
182     void slotPlayZone();
183     void slotLoopZone();
184     /** @brief Loops the selected item (clip or transition). */
185     void slotLoopClip();
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(const QString &path, const QDomElement &info = QDomElement());
191     void slotStart();
192     void slotEnd();
193     void slotSetZoneStart();
194     void slotSetZoneEnd();
195     void slotZoneStart();
196     void slotZoneEnd();
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();
206
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();
213
214 signals:
215     void renderPosition(int);
216     void durationChanged(int);
217     void refreshClipThumbnail(const QString &, bool);
218     void adjustMonitorSize();
219     void zoneUpdated(const QPoint&);
220     void saveZone(Render *, const 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, const QPoint &zone);
226 };
227
228 #endif