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