]> git.sesse.net Git - kdenlive/blob - src/monitor.h
waveform display
[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
21 #ifndef MONITOR_H
22 #define MONITOR_H
23
24 #include <QLabel>
25
26 #include <KIcon>
27 #include <KAction>
28 #include <KRestrictedLine>
29 #include <QDomElement>
30
31 #include "gentime.h"
32 #include "ui_monitor_ui.h"
33 #include "timecodedisplay.h"
34 #ifdef Q_WS_MAC
35 #include "videoglwidget.h"
36 #endif
37
38 class MonitorManager;
39 class Render;
40 class SmallRuler;
41 class DocClipBase;
42 class MonitorScene;
43 class AbstractClipItem;
44 class Transition;
45 class ClipItem;
46 class QGraphicsView;
47 class QGraphicsPixmapItem;
48 class AudioSignal;
49
50 class MonitorRefresh : public QWidget
51 {
52     Q_OBJECT
53 public:
54     MonitorRefresh(QWidget *parent = 0);
55     virtual void paintEvent(QPaintEvent *event);
56     void setRenderer(Render* render);
57
58 private:
59     Render *m_renderer;
60 };
61
62 class Overlay : public QLabel
63 {
64     Q_OBJECT
65 public:
66     Overlay(QWidget* parent);
67     void setOverlayText(const QString &, bool isZone = true);
68
69 private:
70     bool m_isZone;
71 };
72
73 class Monitor : public QWidget
74 {
75     Q_OBJECT
76
77 public:
78     Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
79     virtual ~Monitor();
80     Render *render;
81     void resetProfile(const QString profile);
82     QString name() const;
83     void resetSize();
84     bool isActive() const;
85     void pause();
86     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL, QAction *loopClip = NULL);
87     const QString sceneList();
88     DocClipBase *activeClip();
89     GenTime position();
90     void checkOverlay();
91     void updateTimecodeFormat();
92     void updateMarkers(DocClipBase *source);
93     MonitorScene *getEffectScene();
94
95 protected:
96     virtual void mousePressEvent(QMouseEvent * event);
97     virtual void mouseReleaseEvent(QMouseEvent * event);
98
99     /** @brief Move to another position on mouse wheel event.
100      *
101      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
102      * opposite on mouse wheel up/forward.
103      * Ctrl + wheel moves by a second, without Ctrl it moves by a single frame. */
104     virtual void wheelEvent(QWheelEvent * event);
105     virtual void mouseMoveEvent(QMouseEvent *event);
106     virtual QStringList mimeTypes() const;
107     /*virtual void dragMoveEvent(QDragMoveEvent * event);
108     virtual Qt::DropActions supportedDropActions() const;*/
109
110     //virtual void resizeEvent(QResizeEvent * event);
111     //virtual void paintEvent(QPaintEvent * event);
112
113 private:
114     Ui::Monitor_UI m_ui;
115     QString m_name;
116     MonitorManager *m_monitorManager;
117     DocClipBase *m_currentClip;
118     SmallRuler *m_ruler;
119     Overlay *m_overlay;
120     bool m_isActive;
121     double m_scale;
122     int m_length;
123     bool m_dragStarted;
124     MonitorRefresh *m_monitorRefresh;
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     MonitorScene *m_effectScene;
137     QGraphicsView *m_effectView;
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 #ifdef Q_WS_MAC
144     VideoGLWidget *m_glWidget;
145 #endif
146         AudioSignal *m_audiosignal;
147
148     GenTime getSnapForPos(bool previous);
149
150 private slots:
151     void seekCursor(int pos);
152     void rendererStopped(int pos);
153     void slotExtractCurrentFrame();
154     void slotSetThumbFrame();
155     void slotSetSizeOneToOne();
156     void slotSetSizeOneToTwo();
157     void slotSaveZone();
158     void slotSeek();
159     void setClipZone(QPoint pos);
160     void slotSwitchMonitorInfo(bool show);
161     void slotSwitchDropFrames(bool show);
162     void slotGoToMarker(QAction *action);
163
164 public slots:
165     void slotOpenFile(const QString &);
166     void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
167     void initMonitor();
168     void refreshMonitor(bool visible = true);
169     void slotSeek(int pos);
170     void stop();
171     void start();
172     void activateMonitor();
173     void slotPlay();
174     void slotPlayZone();
175     void slotLoopZone();
176     /** @brief Loops the selected item (clip or transition). */
177     void slotLoopClip();
178     void slotForward(double speed = 0);
179     void slotRewind(double speed = 0);
180     void slotRewindOneFrame(int diff = 1);
181     void slotForwardOneFrame(int diff = 1);
182     void saveSceneList(QString path, QDomElement info = QDomElement());
183     void slotStart();
184     void slotEnd();
185     void slotSetZoneStart();
186     void slotSetZoneEnd();
187     void slotZoneStart();
188     void slotZoneEnd();
189     void slotZoneMoved(int start, int end);
190     void slotSeekToNextSnap();
191     void slotSeekToPreviousSnap();
192     void adjustRulerSize(int length);
193     void setTimePos(const QString &pos);
194     QStringList getZoneInfo() const;
195     void slotEffectScene(bool show = true);
196     bool effectSceneDisplayed();
197
198     /** @brief Sets m_selectedClip to @param item. Used for looping it. */
199     void slotSetSelectedClip(AbstractClipItem *item);
200     void slotSetSelectedClip(ClipItem *item);
201     void slotSetSelectedClip(Transition *item);
202
203 signals:
204     void renderPosition(int);
205     void durationChanged(int);
206     void refreshClipThumbnail(const QString &);
207     void adjustMonitorSize();
208     void zoneUpdated(QPoint);
209     void saveZone(Render *, QPoint);
210     /** @brief  Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
211      *      This causes a major slowdown, so we only enable it if required */
212     void requestFrameForAnalysis(bool);
213 };
214
215 #endif