]> git.sesse.net Git - kdenlive/blob - src/monitor.h
Fix seeking in monitor ruler sometimes not working
[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 resetSize();
79     void pause();
80     void unpause();
81     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
82     const QString sceneList();
83     DocClipBase *activeClip();
84     GenTime position();
85     void checkOverlay();
86     void updateTimecodeFormat();
87     void updateMarkers(DocClipBase *source);
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
95 protected:
96     virtual void mousePressEvent(QMouseEvent * event);
97     virtual void mouseReleaseEvent(QMouseEvent * event);
98     virtual void mouseDoubleClickEvent(QMouseEvent * event);
99     virtual void resizeEvent(QResizeEvent *event);
100
101     /** @brief Move to another position on mouse wheel event.
102      *
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    
110     /*virtual void dragMoveEvent(QDragMoveEvent * event);
111     virtual Qt::DropActions supportedDropActions() const;*/
112
113     //virtual void resizeEvent(QResizeEvent * event);
114     //virtual void paintEvent(QPaintEvent * event);
115
116 private:
117     Kdenlive::MONITORID m_name;
118     DocClipBase *m_currentClip;
119     SmallRuler *m_ruler;
120     Overlay *m_overlay;
121     double m_scale;
122     int m_length;
123     bool m_dragStarted;
124     KIcon m_playIcon;
125     KIcon m_pauseIcon;
126     TimecodeDisplay *m_timePos;
127     QAction *m_playAction;
128     /** Has to be available so we can enable and disable it. */
129     QAction *m_loopClipAction;
130     QMenu *m_contextMenu;
131     QMenu *m_configMenu;
132     QMenu *m_playMenu;
133     QMenu *m_markerMenu;
134     QPoint m_DragStartPosition;
135     MonitorEditWidget *m_effectWidget;
136     VideoContainer *m_videoBox;
137     /** Selected clip/transition in timeline. Used for looping it. */
138     AbstractClipItem *m_selectedClip;
139     /** true if selected clip is transition, false = selected clip is clip.
140      *  Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
141     bool m_loopClipTransition;
142
143 #ifdef USE_OPENGL
144     VideoGLWidget *m_glWidget;
145     bool createOpenGlWidget(QWidget *parent, const QString profile);
146 #endif
147
148     GenTime getSnapForPos(bool previous);
149     Qt::WindowFlags m_baseFlags;
150     QToolBar *m_toolbar;
151     QWidget *m_volumeWidget;
152     QSlider *m_audioSlider;
153     QAction *m_editMarker;
154
155 private slots:
156     void seekCursor(int pos);
157     void rendererStopped(int pos);
158     void slotExtractCurrentFrame();
159     void slotSetThumbFrame();
160     void slotSetSizeOneToOne();
161     void slotSetSizeOneToTwo();
162     void slotSaveZone();
163     void slotSeek();
164     void setClipZone(QPoint pos);
165     void slotSwitchMonitorInfo(bool show);
166     void slotSwitchDropFrames(bool show);
167     void slotGoToMarker(QAction *action);
168     void slotSetVolume(int volume);
169     void slotShowVolume();
170     void slotEditMarker();
171     void slotExtractCurrentZone();
172
173 public slots:
174     void slotOpenFile(const QString &);
175     void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
176     void updateClipProducer(Mlt::Producer *prod);
177     void refreshMonitor(bool visible);
178     void refreshMonitor();
179     void slotSeek(int pos);
180     void stop();
181     void start();
182     void slotPlay();
183     void slotPlayZone();
184     void slotLoopZone();
185     /** @brief Loops the selected item (clip or transition). */
186     void slotLoopClip();
187     void slotForward(double speed = 0);
188     void slotRewind(double speed = 0);
189     void slotRewindOneFrame(int diff = 1);
190     void slotForwardOneFrame(int diff = 1);
191     void saveSceneList(QString path, QDomElement info = QDomElement());
192     void slotStart();
193     void slotEnd();
194     void slotSetZoneStart();
195     void slotSetZoneEnd();
196     void slotZoneStart();
197     void slotZoneEnd();
198     void slotZoneMoved(int start, int end);
199     void slotSeekToNextSnap();
200     void slotSeekToPreviousSnap();
201     void adjustRulerSize(int length);
202     void setTimePos(const QString &pos);
203     QStringList getZoneInfo() const;
204     /** @brief Display the on monitor effect scene (to adjust geometry over monitor). */
205     void slotShowEffectScene(bool show = true, bool manuallyTriggered = false);
206     bool effectSceneDisplayed();
207
208     /** @brief Sets m_selectedClip to @param item. Used for looping it. */
209     void slotSetSelectedClip(AbstractClipItem *item);
210     void slotSetSelectedClip(ClipItem *item);
211     void slotSetSelectedClip(Transition *item);
212     void slotMouseSeek(int eventDelta, bool fast);
213     void slotSwitchFullScreen();
214
215 signals:
216     void renderPosition(int);
217     void durationChanged(int);
218     void refreshClipThumbnail(const QString &, bool);
219     void adjustMonitorSize();
220     void zoneUpdated(QPoint);
221     void saveZone(Render *, QPoint, DocClipBase *);
222     /** @brief  Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
223      *      This causes a major slowdown, so we only enable it if required */
224     void requestFrameForAnalysis(bool);
225     /** @brief Request a zone extraction (ffmpeg transcoding). */
226     void extractZone(const QString &id, QPoint zone);
227 };
228
229 #endif