]> git.sesse.net Git - kdenlive/blob - src/monitor.h
Add widget for easier timecode 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
43 class MonitorRefresh : public QWidget
44 {
45     Q_OBJECT
46 public:
47     MonitorRefresh(QWidget* parent);
48     virtual void paintEvent(QPaintEvent * event);
49     void setRenderer(Render* render);
50
51 private:
52     Render *m_renderer;
53 };
54
55 class Overlay : public QLabel
56 {
57     Q_OBJECT
58 public:
59     Overlay(QWidget* parent);
60     void setOverlayText(const QString &, bool isZone = true);
61
62 private:
63     bool m_isZone;
64 };
65
66 class Monitor : public QWidget
67 {
68     Q_OBJECT
69
70 public:
71     Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
72     virtual ~Monitor();
73     Render *render;
74     void resetProfile(const QString profile);
75     QString name() const;
76     void resetSize();
77     bool isActive() const;
78     void pause();
79     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL);
80     const QString sceneList();
81     DocClipBase *activeClip();
82     GenTime position();
83     void checkOverlay();
84     void updateTimecodeFormat();
85     void updateMarkers(DocClipBase *source);
86
87 protected:
88     virtual void mousePressEvent(QMouseEvent * event);
89     virtual void mouseReleaseEvent(QMouseEvent * event);
90
91     /** @brief Move to another position on mouse wheel event.
92      *
93      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
94      * opposite on mouse wheel up/forward.
95      * Ctrl + wheel moves by a single frame, without Ctrl it moves by a second.
96      *
97      * See also http://www.kdenlive.org/mantis/view.php?id=265. */
98     virtual void wheelEvent(QWheelEvent * event);
99     virtual void mouseMoveEvent(QMouseEvent *event);
100     virtual QStringList mimeTypes() const;
101     /*virtual void dragMoveEvent(QDragMoveEvent * event);
102     virtual Qt::DropActions supportedDropActions() const;*/
103
104     //virtual void resizeEvent(QResizeEvent * event);
105     //virtual void paintEvent(QPaintEvent * event);
106
107 private:
108     Ui::Monitor_UI m_ui;
109     QString m_name;
110     MonitorManager *m_monitorManager;
111     DocClipBase *m_currentClip;
112     SmallRuler *m_ruler;
113     Overlay *m_overlay;
114     bool m_isActive;
115     double m_scale;
116     int m_length;
117     bool m_dragStarted;
118     MonitorRefresh *m_monitorRefresh;
119     KIcon m_playIcon;
120     KIcon m_pauseIcon;
121     TimecodeDisplay *m_timePos;
122     QAction *m_playAction;
123     QMenu *m_contextMenu;
124     QMenu *m_configMenu;
125     QMenu *m_playMenu;
126     QMenu *m_markerMenu;
127     QPoint m_DragStartPosition;
128 #ifdef Q_WS_MAC
129     VideoGLWidget *m_glWidget;
130 #endif
131     GenTime getSnapForPos(bool previous);
132
133 private slots:
134     void seekCursor(int pos);
135     void rendererStopped(int pos);
136     void slotExtractCurrentFrame();
137     void slotSetThumbFrame();
138     void slotSetSizeOneToOne();
139     void slotSetSizeOneToTwo();
140     void slotSaveZone();
141     void slotSeek();
142     void setClipZone(QPoint pos);
143     void slotSwitchMonitorInfo(bool show);
144     void slotSwitchDropFrames(bool show);
145     void slotGoToMarker(QAction *action);
146
147 public slots:
148     void slotOpenFile(const QString &);
149     void slotSetXml(DocClipBase *clip, QPoint zone = QPoint(), const int position = -1);
150     void initMonitor();
151     void refreshMonitor(bool visible = true);
152     void slotSeek(int pos);
153     void stop();
154     void start();
155     void activateMonitor();
156     void slotPlay();
157     void slotPlayZone();
158     void slotLoopZone();
159     void slotForward(double speed = 0);
160     void slotRewind(double speed = 0);
161     void slotRewindOneFrame(int diff = 1);
162     void slotForwardOneFrame(int diff = 1);
163     void saveSceneList(QString path, QDomElement info = QDomElement());
164     void slotStart();
165     void slotEnd();
166     void slotSetZoneStart();
167     void slotSetZoneEnd();
168     void slotZoneStart();
169     void slotZoneEnd();
170     void slotZoneMoved(int start, int end);
171     void slotSeekToNextSnap();
172     void slotSeekToPreviousSnap();
173     void adjustRulerSize(int length);
174     void setTimePos(const QString &pos);
175     QStringList getZoneInfo() const;
176
177 signals:
178     void renderPosition(int);
179     void durationChanged(int);
180     void refreshClipThumbnail(const QString &);
181     void adjustMonitorSize();
182     void zoneUpdated(QPoint);
183     void saveZone(Render *, QPoint);
184 };
185
186 #endif