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