]> git.sesse.net Git - kdenlive/blob - src/monitor.h
Volume slider in monitors
[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 "timecodedisplay.h"
26 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
27 #include "videoglwidget.h"
28 #endif
29
30 #include <QLabel>
31 #include <QDomElement>
32 #include <QToolBar>
33 #include <QSlider>
34
35 #include <KIcon>
36 #include <KAction>
37 #include <KRestrictedLine>
38
39
40 class MonitorManager;
41 class Render;
42 class SmallRuler;
43 class DocClipBase;
44 class MonitorScene;
45 class AbstractClipItem;
46 class Transition;
47 class ClipItem;
48 class QGraphicsView;
49 class QGraphicsPixmapItem;
50
51 class Monitor;
52
53 class VideoContainer : public QFrame
54 {
55     Q_OBJECT
56 public:
57     VideoContainer(Monitor *parent = 0);
58     void switchFullScreen();
59
60 protected:
61     virtual void mouseDoubleClickEvent(QMouseEvent * event);
62     virtual void mousePressEvent(QMouseEvent * event);
63     virtual void mouseReleaseEvent(QMouseEvent *event);
64     virtual void mouseMoveEvent(QMouseEvent *event);
65     void keyPressEvent(QKeyEvent *event);
66     virtual void wheelEvent(QWheelEvent * event);
67
68 private:
69     Qt::WindowFlags m_baseFlags;
70     Monitor *m_monitor;
71 };
72
73 class MonitorRefresh : public QWidget
74 {
75     Q_OBJECT
76 public:
77     MonitorRefresh(QWidget *parent = 0);
78     void setRenderer(Render* render);
79
80 protected:
81     virtual void paintEvent(QPaintEvent *event);
82
83 private:
84     Render *m_renderer;
85
86 signals:
87     void switchFullScreen();
88     void switchPlay();
89     void mouseSeek(int, bool);
90 };
91
92 class Overlay : public QLabel
93 {
94     Q_OBJECT
95 public:
96     Overlay(QWidget* parent);
97     void setOverlayText(const QString &, bool isZone = true);
98
99 private:
100     bool m_isZone;
101 };
102
103 class Monitor : public QWidget
104 {
105     Q_OBJECT
106
107 public:
108     Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
109     virtual ~Monitor();
110     Render *render;
111     void resetProfile(const QString profile);
112     QString name() const;
113     void resetSize();
114     bool isActive() const;
115     void pause();
116     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
117     const QString sceneList();
118     DocClipBase *activeClip();
119     GenTime position();
120     void checkOverlay();
121     void updateTimecodeFormat();
122     void updateMarkers(DocClipBase *source);
123     MonitorScene *getEffectScene();
124     QWidget *container();
125     QFrame *m_volumePopup;
126
127 protected:
128     virtual void mousePressEvent(QMouseEvent * event);
129     virtual void mouseReleaseEvent(QMouseEvent * event);
130
131     /** @brief Move to another position on mouse wheel event.
132      *
133      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
134      * opposite on mouse wheel up/forward.
135      * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
136     virtual void wheelEvent(QWheelEvent * event);
137     virtual void mouseMoveEvent(QMouseEvent *event);
138     virtual QStringList mimeTypes() const;
139     /*virtual void dragMoveEvent(QDragMoveEvent * event);
140     virtual Qt::DropActions supportedDropActions() const;*/
141
142     //virtual void resizeEvent(QResizeEvent * event);
143     //virtual void paintEvent(QPaintEvent * event);
144
145 private:
146     QString m_name;
147     MonitorManager *m_monitorManager;
148     DocClipBase *m_currentClip;
149     SmallRuler *m_ruler;
150     Overlay *m_overlay;
151     bool m_isActive;
152     double m_scale;
153     int m_length;
154     bool m_dragStarted;
155     MonitorRefresh *m_monitorRefresh;
156     KIcon m_playIcon;
157     KIcon m_pauseIcon;
158     TimecodeDisplay *m_timePos;
159     QAction *m_playAction;
160     /** Has to be available so we can enable and disable it. */
161     QAction *m_loopClipAction;
162     QMenu *m_contextMenu;
163     QMenu *m_configMenu;
164     QMenu *m_playMenu;
165     QMenu *m_markerMenu;
166     QPoint m_DragStartPosition;
167     MonitorScene *m_effectScene;
168     QGraphicsView *m_effectView;
169     VideoContainer *m_videoBox;
170     /** Selected clip/transition in timeline. Used for looping it. */
171     AbstractClipItem *m_selectedClip;
172     /** true if selected clip is transition, false = selected clip is clip.
173      *  Necessary because sometimes we get two signals, e.g. we get a clip and we get selected transition = NULL. */
174     bool m_loopClipTransition;
175 #if defined(Q_WS_MAC) || defined(USE_OPEN_GL)
176     VideoGLWidget *m_glWidget;
177     bool createOpenGlWidget(QWidget *parent, const QString profile);
178 #endif
179
180     GenTime getSnapForPos(bool previous);
181     Qt::WindowFlags m_baseFlags;
182     QToolBar *m_toolbar;
183     QWidget *m_volumeWidget;
184     QSlider *m_audioSlider;
185
186 private slots:
187     void seekCursor(int pos);
188     void rendererStopped(int pos);
189     void slotExtractCurrentFrame();
190     void slotSetThumbFrame();
191     void slotSetSizeOneToOne();
192     void slotSetSizeOneToTwo();
193     void slotSaveZone();
194     void slotSeek();
195     void setClipZone(QPoint pos);
196     void slotSwitchMonitorInfo(bool show);
197     void slotSwitchDropFrames(bool show);
198     void slotGoToMarker(QAction *action);
199     void slotSetVolume(int volume);
200     void slotShowVolume();
201
202 public slots:
203     void slotOpenFile(const QString &);
204     void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
205     void refreshMonitor(bool visible);
206     void refreshMonitor();
207     void slotSeek(int pos);
208     void stop();
209     void start();
210     void activateMonitor();
211     void slotPlay();
212     void slotPlayZone();
213     void slotLoopZone();
214     /** @brief Loops the selected item (clip or transition). */
215     void slotLoopClip();
216     void slotForward(double speed = 0);
217     void slotRewind(double speed = 0);
218     void slotRewindOneFrame(int diff = 1);
219     void slotForwardOneFrame(int diff = 1);
220     void saveSceneList(QString path, QDomElement info = QDomElement());
221     void slotStart();
222     void slotEnd();
223     void slotSetZoneStart();
224     void slotSetZoneEnd();
225     void slotZoneStart();
226     void slotZoneEnd();
227     void slotZoneMoved(int start, int end);
228     void slotSeekToNextSnap();
229     void slotSeekToPreviousSnap();
230     void adjustRulerSize(int length);
231     void setTimePos(const QString &pos);
232     QStringList getZoneInfo() const;
233     void slotEffectScene(bool show = true);
234     bool effectSceneDisplayed();
235
236     /** @brief Sets m_selectedClip to @param item. Used for looping it. */
237     void slotSetSelectedClip(AbstractClipItem *item);
238     void slotSetSelectedClip(ClipItem *item);
239     void slotSetSelectedClip(Transition *item);
240     void slotMouseSeek(int eventDelta, bool fast);
241     void slotSwitchFullScreen();
242
243 signals:
244     void renderPosition(int);
245     void durationChanged(int);
246     void refreshClipThumbnail(const QString &);
247     void adjustMonitorSize();
248     void zoneUpdated(QPoint);
249     void saveZone(Render *, QPoint);
250     /** @brief  Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
251      *      This causes a major slowdown, so we only enable it if required */
252     void requestFrameForAnalysis(bool);
253 };
254
255 #endif