]> git.sesse.net Git - kdenlive/blob - src/monitor.h
* Cleanup transode stabilize GUI: http://kdenlive.org/mantis/view.php?id=2930
[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 #include <QSlider>
37
38 #include <KIcon>
39 #include <KAction>
40 #include <KRestrictedLine>
41
42 class SmallRuler;
43 class DocClipBase;
44 class AbstractClipItem;
45 class Transition;
46 class ClipItem;
47 class MonitorEditWidget;
48 class Monitor;
49 class MonitorManager;
50
51
52 class Overlay : public QLabel
53 {
54     Q_OBJECT
55 public:
56     Overlay(QWidget* parent = 0);
57     void setOverlayText(const QString &, bool isZone = true);
58
59 protected:
60     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
61     virtual void mousePressEvent ( QMouseEvent * event );
62     virtual void mouseReleaseEvent ( QMouseEvent * event );
63     
64 signals:
65     void editMarker();
66 };
67
68 class Monitor : public AbstractMonitor
69 {
70     Q_OBJECT
71
72 public:
73     Monitor(Kdenlive::MONITORID id, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
74     ~Monitor();
75     Render *render;
76     AbstractRender *abstractRender();
77     void resetProfile(const QString &profile);
78     void setCustomProfile(const QString &profile, Timecode tc);
79     void resetSize();
80     void pause();
81     void unpause();
82     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
83     const QString sceneList();
84     DocClipBase *activeClip();
85     GenTime position();
86     void checkOverlay();
87     void updateTimecodeFormat();
88     void updateMarkers(DocClipBase *source);
89     MonitorEditWidget *getEffectEdit();
90     QWidget *container();
91     void reloadProducer(const QString &id);
92     QFrame *m_volumePopup;
93     /** @brief Reimplemented from QWidget, updates the palette colors. */
94     void setPalette ( const QPalette & p);
95     /** @brief Returns a hh:mm:ss timecode from a frame number. */
96     QString getTimecodeFromFrames(int pos);
97     /** @brief Returns current project's fps. */
98     double fps() const;
99     /** @brief Get url for the clip's thumbnail */
100     QString getMarkerThumb(GenTime pos);
101
102 protected:
103     virtual void mousePressEvent(QMouseEvent * event);
104     virtual void mouseReleaseEvent(QMouseEvent * event);
105     virtual void mouseDoubleClickEvent(QMouseEvent * event);
106     virtual void resizeEvent(QResizeEvent *event);
107
108     /** @brief Move to another position on mouse wheel event.
109      *
110      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
111      * opposite on mouse wheel up/forward.
112      * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
113     virtual void wheelEvent(QWheelEvent * event);
114     virtual void mouseMoveEvent(QMouseEvent *event);
115     virtual QStringList mimeTypes() const;
116    
117     /*virtual void dragMoveEvent(QDragMoveEvent * event);
118     virtual Qt::DropActions supportedDropActions() const;*/
119
120     //virtual void resizeEvent(QResizeEvent * event);
121     //virtual void paintEvent(QPaintEvent * event);
122
123 private:
124     Kdenlive::MONITORID m_name;
125     DocClipBase *m_currentClip;
126     SmallRuler *m_ruler;
127     Overlay *m_overlay;
128     double m_scale;
129     int m_length;
130     bool m_dragStarted;
131     KIcon m_playIcon;
132     KIcon m_pauseIcon;
133     TimecodeDisplay *m_timePos;
134     QAction *m_playAction;
135     /** Has to be available so we can enable and disable it. */
136     QAction *m_loopClipAction;
137     QMenu *m_contextMenu;
138     QMenu *m_configMenu;
139     QMenu *m_playMenu;
140     QMenu *m_markerMenu;
141     QPoint m_DragStartPosition;
142     MonitorEditWidget *m_effectWidget;
143     VideoContainer *m_videoBox;
144     /** Selected clip/transition in timeline. Used for looping it. */
145     AbstractClipItem *m_selectedClip;
146     /** true if selected clip is transition, false = selected clip is clip.
147      *  Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
148     bool m_loopClipTransition;
149
150 #ifdef USE_OPENGL
151     VideoGLWidget *m_glWidget;
152     bool createOpenGlWidget(QWidget *parent, const QString profile);
153 #endif
154
155     GenTime getSnapForPos(bool previous);
156     Qt::WindowFlags m_baseFlags;
157     QToolBar *m_toolbar;
158     QWidget *m_volumeWidget;
159     QSlider *m_audioSlider;
160     QAction *m_editMarker;
161
162 private slots:
163     void seekCursor(int pos);
164     void rendererStopped(int pos);
165     void slotExtractCurrentFrame();
166     void slotSetThumbFrame();
167     void slotSetSizeOneToOne();
168     void slotSetSizeOneToTwo();
169     void slotSaveZone();
170     void slotSeek();
171     void setClipZone(QPoint pos);
172     void slotSwitchMonitorInfo(bool show);
173     void slotSwitchDropFrames(bool show);
174     void slotGoToMarker(QAction *action);
175     void slotSetVolume(int volume);
176     void slotShowVolume();
177     void slotEditMarker();
178     void slotExtractCurrentZone();
179
180 public slots:
181     void slotOpenFile(const QString &);
182     void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
183     void updateClipProducer(Mlt::Producer *prod);
184     void refreshMonitor(bool visible);
185     void refreshMonitor();
186     void slotSeek(int pos);
187     void stop();
188     void start();
189     void slotPlay();
190     void slotPlayZone();
191     void slotLoopZone();
192     /** @brief Loops the selected item (clip or transition). */
193     void slotLoopClip();
194     void slotForward(double speed = 0);
195     void slotRewind(double speed = 0);
196     void slotRewindOneFrame(int diff = 1);
197     void slotForwardOneFrame(int diff = 1);
198     void saveSceneList(QString path, QDomElement info = QDomElement());
199     void slotStart();
200     void slotEnd();
201     void slotSetZoneStart();
202     void slotSetZoneEnd();
203     void slotZoneStart();
204     void slotZoneEnd();
205     void slotZoneMoved(int start, int end);
206     void slotSeekToNextSnap();
207     void slotSeekToPreviousSnap();
208     void adjustRulerSize(int length);
209     void setTimePos(const QString &pos);
210     QStringList getZoneInfo() const;
211     /** @brief Display the on monitor effect scene (to adjust geometry over monitor). */
212     void slotShowEffectScene(bool show = true, bool manuallyTriggered = false);
213     bool effectSceneDisplayed();
214
215     /** @brief Sets m_selectedClip to @param item. Used for looping it. */
216     void slotSetSelectedClip(AbstractClipItem *item);
217     void slotSetSelectedClip(ClipItem *item);
218     void slotSetSelectedClip(Transition *item);
219     void slotMouseSeek(int eventDelta, bool fast);
220     void slotSwitchFullScreen();
221
222 signals:
223     void renderPosition(int);
224     void durationChanged(int);
225     void refreshClipThumbnail(const QString &, bool);
226     void adjustMonitorSize();
227     void zoneUpdated(QPoint);
228     void saveZone(Render *, QPoint, DocClipBase *);
229     /** @brief  Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
230      *      This causes a major slowdown, so we only enable it if required */
231     void requestFrameForAnalysis(bool);
232     /** @brief Request a zone extraction (ffmpeg transcoding). */
233     void extractZone(const QString &id, QPoint zone);
234 };
235
236 #endif