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