]> git.sesse.net Git - kdenlive/blob - src/monitor.h
Use real MLT position in monitors instead of cached one, preventing race condition...
[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
34 class MonitorManager;
35 class Render;
36 class SmallRuler;
37 class DocClipBase;
38
39 class MonitorRefresh : public QWidget
40 {
41     Q_OBJECT
42 public:
43     MonitorRefresh(QWidget* parent);
44     virtual void paintEvent(QPaintEvent * event);
45     void setRenderer(Render* render);
46
47 private:
48     Render *m_renderer;
49 };
50
51 class Overlay : public QLabel
52 {
53     Q_OBJECT
54 public:
55     Overlay(QWidget* parent);
56     virtual void paintEvent(QPaintEvent * event);
57     void setOverlayText(const QString &, bool isZone = true);
58
59 private:
60     bool m_isZone;
61 };
62
63 class Monitor : public QWidget
64 {
65     Q_OBJECT
66
67 public:
68     Monitor(QString name, MonitorManager *manager, QWidget *parent = 0);
69     virtual ~Monitor();
70     Render *render;
71     void resetProfile();
72     QString name() const;
73     void resetSize();
74     bool isActive() const;
75     void pause();
76     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL);
77     const QString sceneList();
78     DocClipBase *activeClip();
79     GenTime position();
80     void checkOverlay();
81
82 protected:
83     virtual void mousePressEvent(QMouseEvent * event);
84     virtual void mouseReleaseEvent(QMouseEvent * event);
85     virtual void wheelEvent(QWheelEvent * event);
86     virtual void mouseMoveEvent(QMouseEvent *event);
87     virtual QStringList mimeTypes() const;
88     /*    virtual void dragMoveEvent(QDragMoveEvent * event);
89         virtual Qt::DropActions supportedDropActions() const;*/
90
91 //    virtual void resizeEvent(QResizeEvent * event);
92 //    virtual void paintEvent(QPaintEvent * event);
93
94 private:
95     Ui::Monitor_UI m_ui;
96     QString m_name;
97     MonitorManager *m_monitorManager;
98     DocClipBase *m_currentClip;
99     SmallRuler *m_ruler;
100     Overlay *m_overlay;
101     bool m_isActive;
102     double m_scale;
103     int m_length;
104     bool m_dragStarted;
105     MonitorRefresh *m_monitorRefresh;
106     KIcon m_playIcon;
107     KIcon m_pauseIcon;
108     KRestrictedLine *m_timePos;
109     QAction *m_playAction;
110     QMenu *m_contextMenu;
111     QMenu *m_configMenu;
112     QMenu *m_playMenu;
113     QPoint m_DragStartPosition;
114     GenTime getSnapForPos(bool previous);
115
116 private slots:
117     void seekCursor(int pos);
118     void rendererStopped(int pos);
119     void slotExtractCurrentFrame();
120     void slotSetThumbFrame();
121     void slotSetSizeOneToOne();
122     void slotSetSizeOneToTwo();
123     void slotSaveZone();
124     void slotSeek();
125     void setClipZone(QPoint pos);
126     void slotSwitchMonitorInfo(bool show);
127     void slotSwitchDropFrames(bool show);
128
129 public slots:
130     void slotOpenFile(const QString &);
131     void slotSetXml(DocClipBase *clip, const int position = -1);
132     void initMonitor();
133     void refreshMonitor(bool visible = true);
134     void slotSeek(int pos);
135     void stop();
136     void start();
137     void activateMonitor();
138     void slotPlay();
139     void slotPlayZone();
140     void slotLoopZone();
141     void slotForward(double speed = 0);
142     void slotRewind(double speed = 0);
143     void slotRewindOneFrame(int diff = 1);
144     void slotForwardOneFrame(int diff = 1);
145     void saveSceneList(QString path, QDomElement info = QDomElement());
146     void slotStart();
147     void slotEnd();
148     void slotSetZoneStart();
149     void slotSetZoneEnd();
150     void slotZoneStart();
151     void slotZoneEnd();
152     void slotZoneMoved(int start, int end);
153     void slotSeekToNextSnap();
154     void slotSeekToPreviousSnap();
155     void adjustRulerSize(int length);
156     void setTimePos(const QString &pos);
157
158 signals:
159     void renderPosition(int);
160     void durationChanged(int);
161     void refreshClipThumbnail(const QString &);
162     void adjustMonitorSize();
163     void zoneUpdated(QPoint);
164     void saveZone(Render *, QPoint);
165     void blockMonitors();
166 };
167
168 #endif