]> git.sesse.net Git - kdenlive/blob - src/abstractmonitor.h
Some more cleanup in monitors, improve capture fullscreen
[kdenlive] / src / abstractmonitor.h
1 /***************************************************************************
2  *   Copyright (C) 2011 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 #ifndef ABSTRACTMONITOR_H
21 #define ABSTRACTMONITOR_H
22
23 #include "definitions.h"
24
25 #include <QObject>
26 #include <QVector>
27 #include <QWidget>
28 #include <QImage>
29 #include <QPainter>
30 #include <QFrame>
31 #include <QTimer>
32
33 #include <stdint.h>
34
35 class MonitorManager;
36 class VideoContainer;
37
38 class AbstractRender: public QObject
39 {
40 Q_OBJECT public:
41
42     /** @brief Build an abstract MLT Renderer
43      *  @param name A unique identifier for this renderer
44      *  @param winid The parent widget identifier (required for SDL display). Set to 0 for OpenGL rendering
45      *  @param profile The MLT profile used for the renderer (default one will be used if empty). */
46     AbstractRender(Kdenlive::MONITORID name, QWidget *parent = 0):QObject(parent), sendFrameForAnalysis(false), m_name(name) {};
47
48     /** @brief Destroy the MLT Renderer. */
49     virtual ~AbstractRender() {};
50
51     /** @brief This property is used to decide if the renderer should convert it's frames to QImage for use in other Kdenlive widgets. */
52     bool sendFrameForAnalysis;
53     
54     /** @brief This property is used to decide if the renderer should send audio data for monitoring. */
55     bool analyseAudio;
56     
57     const QString &name() const {return m_name;};
58
59     /** @brief Someone needs us to send again a frame. */
60     virtual void sendFrameUpdate() = 0;
61
62 private:
63     QString m_name;
64     
65 signals:
66     /** @brief The renderer refreshed the current frame. */
67     void frameUpdated(QImage);
68
69     /** @brief This signal contains the audio of the current frame. */
70     void audioSamplesSignal(QVector<int16_t>,int,int,int);
71 };
72
73
74
75 class VideoSurface : public QWidget
76 {
77     Q_OBJECT
78 public:
79     VideoSurface(QWidget *parent = 0);
80     
81 signals:
82     void refreshMonitor();
83
84 protected:
85     virtual void paintEvent ( QPaintEvent * event );
86 };
87
88
89 class AbstractMonitor : public QWidget
90 {
91     Q_OBJECT
92 public:
93     AbstractMonitor(Kdenlive::MONITORID id, MonitorManager *manager, QWidget *parent = 0);
94     Kdenlive::MONITORID id() {return m_id;};
95     virtual ~AbstractMonitor();
96     virtual AbstractRender *abstractRender() = 0;
97     bool isActive() const;
98     VideoContainer *videoBox;
99     VideoSurface *videoSurface;
100     void createVideoSurface();
101     
102     
103 public slots:
104     virtual void stop() = 0;
105     virtual void start() = 0;
106     virtual void slotPlay() = 0;
107     virtual void slotMouseSeek(int eventDelta, bool fast) = 0;
108     bool slotActivateMonitor();
109     virtual void slotSwitchFullScreen() = 0;
110
111 protected:
112     Kdenlive::MONITORID m_id;
113     MonitorManager *m_monitorManager;
114 };
115
116 class VideoContainer : public QFrame
117 {
118     Q_OBJECT
119 public:
120     VideoContainer(AbstractMonitor *monitor, QWidget *parent = 0);
121     void switchFullScreen();
122
123 protected:
124     virtual void mouseDoubleClickEvent(QMouseEvent * event);
125     virtual void mouseReleaseEvent(QMouseEvent *event);
126     void keyPressEvent(QKeyEvent *event);
127     virtual void wheelEvent(QWheelEvent * event);
128
129 private:
130     Qt::WindowFlags m_baseFlags;
131     AbstractMonitor *m_monitor;
132 };
133
134 #endif