]> git.sesse.net Git - kdenlive/blob - src/monitor.h
simplify monitor overlay info
[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     void setOverlayText(const QString &, bool isZone = true);
60
61 private:
62     bool m_isZone;
63 };
64
65 class Monitor : public QWidget
66 {
67     Q_OBJECT
68
69 public:
70     Monitor(QString name, MonitorManager *manager, QString profile = QString(), QWidget *parent = 0);
71     virtual ~Monitor();
72     Render *render;
73     void resetProfile(const QString profile);
74     QString name() const;
75     void resetSize();
76     bool isActive() const;
77     void pause();
78     void setupMenu(QMenu *goMenu, QAction *playZone, QAction *loopZone, QMenu *markerMenu = NULL);
79     const QString sceneList();
80     DocClipBase *activeClip();
81     GenTime position();
82     void checkOverlay();
83     void updateTimecodeFormat();
84     void updateMarkers(DocClipBase *source);
85
86 protected:
87     virtual void mousePressEvent(QMouseEvent * event);
88     virtual void mouseReleaseEvent(QMouseEvent * event);
89
90     /** @brief Move to another position on mouse wheel event.
91      *
92      * Moves towards the end of the clip/timeline on mouse wheel down/back, the
93      * opposite on mouse wheel up/forward.
94      * Ctrl + wheel moves by a single frame, without Ctrl it moves by a second.
95      *
96      * See also http://www.kdenlive.org/mantis/view.php?id=265. */
97     virtual void wheelEvent(QWheelEvent * event);
98     virtual void mouseMoveEvent(QMouseEvent *event);
99     virtual QStringList mimeTypes() const;
100     /*virtual void dragMoveEvent(QDragMoveEvent * event);
101     virtual Qt::DropActions supportedDropActions() const;*/
102
103     //virtual void resizeEvent(QResizeEvent * event);
104     //virtual void paintEvent(QPaintEvent * event);
105
106 private:
107     Ui::Monitor_UI m_ui;
108     QString m_name;
109     MonitorManager *m_monitorManager;
110     DocClipBase *m_currentClip;
111     SmallRuler *m_ruler;
112     Overlay *m_overlay;
113     bool m_isActive;
114     double m_scale;
115     int m_length;
116     bool m_dragStarted;
117     MonitorRefresh *m_monitorRefresh;
118     KIcon m_playIcon;
119     KIcon m_pauseIcon;
120     KRestrictedLine *m_timePos;
121     QAction *m_playAction;
122     QMenu *m_contextMenu;
123     QMenu *m_configMenu;
124     QMenu *m_playMenu;
125     QMenu *m_markerMenu;
126     QPoint m_DragStartPosition;
127 #ifdef Q_WS_MAC
128     VideoGLWidget *m_glWidget;
129 #endif
130     GenTime getSnapForPos(bool previous);
131     bool m_frametimecode;
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