]> git.sesse.net Git - kdenlive/blob - src/monitor.h
Add Mac OS X compatibility through new MLT sdl_audio consumer and a QTGLWidget!
[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 #ifdef Q_WS_MAC
34 #include "videoglwidget.h"
35 #endif
36
37 class MonitorManager;
38 class Render;
39 class SmallRuler;
40 class DocClipBase;
41
42 class MonitorRefresh : public QWidget
43 {
44     Q_OBJECT
45 public:
46     MonitorRefresh(QWidget* parent);
47     virtual void paintEvent(QPaintEvent * event);
48     void setRenderer(Render* render);
49
50 private:
51     Render *m_renderer;
52 };
53
54 class Overlay : public QLabel
55 {
56     Q_OBJECT
57 public:
58     Overlay(QWidget* parent);
59     virtual void paintEvent(QPaintEvent * event);
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, QWidget *parent = 0);
72     virtual ~Monitor();
73     Render *render;
74     void resetProfile();
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
86 protected:
87     virtual void mousePressEvent(QMouseEvent * event);
88     virtual void mouseReleaseEvent(QMouseEvent * event);
89     virtual void wheelEvent(QWheelEvent * event);
90     virtual void mouseMoveEvent(QMouseEvent *event);
91     virtual QStringList mimeTypes() const;
92     /*    virtual void dragMoveEvent(QDragMoveEvent * event);
93         virtual Qt::DropActions supportedDropActions() const;*/
94
95 //    virtual void resizeEvent(QResizeEvent * event);
96 //    virtual void paintEvent(QPaintEvent * event);
97
98 private:
99     Ui::Monitor_UI m_ui;
100     QString m_name;
101     MonitorManager *m_monitorManager;
102     DocClipBase *m_currentClip;
103     SmallRuler *m_ruler;
104     Overlay *m_overlay;
105     bool m_isActive;
106     double m_scale;
107     int m_length;
108     bool m_dragStarted;
109     MonitorRefresh *m_monitorRefresh;
110     KIcon m_playIcon;
111     KIcon m_pauseIcon;
112     KRestrictedLine *m_timePos;
113     QAction *m_playAction;
114     QMenu *m_contextMenu;
115     QMenu *m_configMenu;
116     QMenu *m_playMenu;
117     QPoint m_DragStartPosition;
118 #ifdef Q_WS_MAC
119     VideoGLWidget *m_glWidget;
120 #endif
121     GenTime getSnapForPos(bool previous);
122     bool m_frametimecode;
123
124 private slots:
125     void seekCursor(int pos);
126     void rendererStopped(int pos);
127     void slotExtractCurrentFrame();
128     void slotSetThumbFrame();
129     void slotSetSizeOneToOne();
130     void slotSetSizeOneToTwo();
131     void slotSaveZone();
132     void slotSeek();
133     void setClipZone(QPoint pos);
134     void slotSwitchMonitorInfo(bool show);
135     void slotSwitchDropFrames(bool show);
136
137 public slots:
138     void slotOpenFile(const QString &);
139     void slotSetXml(DocClipBase *clip, const int position = -1);
140     void initMonitor();
141     void refreshMonitor(bool visible = true);
142     void slotSeek(int pos);
143     void stop();
144     void start();
145     void activateMonitor();
146     void slotPlay();
147     void slotPlayZone();
148     void slotLoopZone();
149     void slotForward(double speed = 0);
150     void slotRewind(double speed = 0);
151     void slotRewindOneFrame(int diff = 1);
152     void slotForwardOneFrame(int diff = 1);
153     void saveSceneList(QString path, QDomElement info = QDomElement());
154     void slotStart();
155     void slotEnd();
156     void slotSetZoneStart();
157     void slotSetZoneEnd();
158     void slotZoneStart();
159     void slotZoneEnd();
160     void slotZoneMoved(int start, int end);
161     void slotSeekToNextSnap();
162     void slotSeekToPreviousSnap();
163     void adjustRulerSize(int length);
164     void setTimePos(const QString &pos);
165
166 signals:
167     void renderPosition(int);
168     void durationChanged(int);
169     void refreshClipThumbnail(const QString &);
170     void adjustMonitorSize();
171     void zoneUpdated(QPoint);
172     void saveZone(Render *, QPoint);
173     void blockMonitors();
174 };
175
176 #endif