]> git.sesse.net Git - kdenlive/blob - src/monitor.h
40414dd70c43205efd54d40c8a95b2b164e51fd5
[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 "abstractmonitor.h"
29 #ifdef USE_OPENGL
30 #include "videoglwidget.h"
31 #endif
32
33 #include <QLabel>
34 #include <QDomElement>
35 #include <QToolBar>
36
37 #include <KIcon>
38
39 class SmallRuler;
40 class DocClipBase;
41 class AbstractClipItem;
42 class Transition;
43 class ClipItem;
44 class MonitorEditWidget;
45 class Monitor;
46 class MonitorManager;
47 class QSlider;
48
49
50 class Overlay : public QLabel
51 {
52     Q_OBJECT
53 public:
54     Overlay(QWidget* parent = 0);
55     void setOverlayText(const QString &, bool isZone = true);
56
57 protected:
58     void mouseDoubleClickEvent ( QMouseEvent * event );
59     void mousePressEvent ( QMouseEvent * event );
60     void mouseReleaseEvent ( QMouseEvent * event );
61     
62 signals:
63     void editMarker();
64 };
65
66 class Monitor : public AbstractMonitor
67 {
68     Q_OBJECT
69
70 public:
71     Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
72     ~Monitor();
73     Render *render;
74     AbstractRender *abstractRender();
75     void resetProfile(const QString &profile);
76     void setCustomProfile(const QString &profile, const Timecode &tc);
77     void resetSize();
78     void pause();
79     void unpause();
80     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
81     const QString sceneList();
82     DocClipBase *activeClip();
83     GenTime position();
84     void checkOverlay();
85     void updateTimecodeFormat();
86     void updateMarkers(DocClipBase *source);
87     void setMarkers(const QList <CommentedTime> &markers);
88     MonitorEditWidget *getEffectEdit();
89     QWidget *container();
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. */
97     double fps() const;
98     /** @brief Get url for the clip's thumbnail */
99     QString getMarkerThumb(GenTime pos);
100
101 protected:
102     void mousePressEvent(QMouseEvent * event);
103     void mouseReleaseEvent(QMouseEvent * event);
104     void mouseDoubleClickEvent(QMouseEvent * event);
105     void resizeEvent(QResizeEvent *event);
106
107     /** @brief Move to another position on mouse wheel event.
108      *
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;
115    
116     /*virtual void dragMoveEvent(QDragMoveEvent * event);
117     virtual Qt::DropActions supportedDropActions() const;*/
118
119     //virtual void resizeEvent(QResizeEvent * event);
120     //virtual void paintEvent(QPaintEvent * event);
121
122 private:
123     DocClipBase *m_currentClip;
124     SmallRuler *m_ruler;
125     Overlay *m_overlay;
126     double m_scale;
127     int m_length;
128     bool m_dragStarted;
129     KIcon m_playIcon;
130     KIcon m_pauseIcon;
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;
136     QMenu *m_configMenu;
137     QMenu *m_playMenu;
138     QMenu *m_markerMenu;
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;
146
147 #ifdef USE_OPENGL
148     VideoGLWidget *m_glWidget;
149     bool createOpenGlWidget(QWidget *parent, const QString &profile);
150 #endif
151
152     GenTime getSnapForPos(bool previous);
153     Qt::WindowFlags m_baseFlags;
154     QToolBar *m_toolbar;
155     QWidget *m_volumeWidget;
156     QSlider *m_audioSlider;
157     QAction *m_editMarker;
158
159 private slots:
160     void seekCursor(int pos);
161     void rendererStopped(int pos);
162     void slotExtractCurrentFrame();
163     void slotSetThumbFrame();
164     void slotSetSizeOneToOne();
165     void slotSetSizeOneToTwo();
166     void slotSaveZone();
167     void slotSeek();
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();
176
177 public slots:
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);
184     void stop();
185     void start();
186     void slotPlay();
187     void slotPlayZone();
188     void slotLoopZone();
189     /** @brief Loops the selected item (clip or transition). */
190     void slotLoopClip();
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());
196     void slotStart();
197     void slotEnd();
198     void slotSetZoneStart();
199     void slotSetZoneEnd();
200     void slotZoneStart();
201     void slotZoneEnd();
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();
211
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();
218
219 signals:
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);
231 };
232
233 #endif