]> git.sesse.net Git - kdenlive/blob - src/abstractscopewidget.h
Abstract scope class AbstractScopeWidget added.
[kdenlive] / src / abstractscopewidget.h
1 /***************************************************************************
2  *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  ***************************************************************************/
10
11 /**
12      _____________________
13     /                     \
14    /      HUD Layer        \
15   /                         \
16   ---------------------------
17      _____________________
18     /                     \
19    /     Scope Layer       \
20   /                         \
21   ---------------------------
22      _____________________
23     /                     \
24    /   Background Layer    \
25   /                         \
26   ---------------------------
27  */
28
29 #ifndef ABSTRACTSCOPEWIDGET_H
30 #define ABSTRACTSCOPEWIDGET_H
31
32 #include <QtCore>
33 #include <QWidget>
34
35 class QMenu;
36
37 class Monitor;
38 class Render;
39
40 class AbstractScopeWidget : public QWidget
41 {
42     Q_OBJECT
43
44 public:
45     AbstractScopeWidget(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent = 0);
46     virtual ~AbstractScopeWidget(); // Must be virtual because of inheritance, to avoid memory leaks
47     QPalette m_scopePalette;
48
49     virtual QString widgetName() const = 0;
50
51 protected:
52     ///// Variables /////
53
54     Monitor *m_projMonitor;
55     Monitor *m_clipMonitor;
56     Render *m_activeRender;
57
58     QMenu *m_menu;
59     QAction *m_aAutoRefresh;
60     QAction *m_aRealtime;
61
62     /** Offset from the widget's borders */
63     const uchar offset;
64
65     QRect m_scopeRect;
66     QImage m_imgHUD;
67     QImage m_imgScope;
68     QImage m_imgBackground;
69
70     /** Counts the number of frames that have been rendered in the active monitor.
71       The frame number will be reset when the calculation starts for the current frame. */
72     QAtomicInt m_newHUDFrames;
73     QAtomicInt m_newScopeFrames;
74     QAtomicInt m_newBackgroundFrames;
75
76     /** Counts the number of updates that, unlike new frames, force a recalculation
77       of the scope, like for example a resize event. */
78     QAtomicInt m_newHUDUpdates;
79     QAtomicInt m_newScopeUpdates;
80     QAtomicInt m_newBackgroundUpdates;
81
82     QFuture<QImage> m_threadHUD;
83     QFuture<QImage> m_threadScope;
84     QFuture<QImage> m_threadBackground;
85
86     QSemaphore m_semaphoreHUD;
87     QSemaphore m_semaphoreScope;
88     QSemaphore m_semaphoreBackground;
89
90
91     ///// Unimplemented Methods /////
92
93     /** Where on the widget we can paint in */
94     virtual QRect scopeRect() = 0;
95
96     /** HUD renderer. Must emit signalHUDRenderingFinished(). */
97     virtual QImage renderHUD() = 0;
98     /** Scope renderer. Must emit signalScopeRenderingFinished(). */
99     virtual QImage renderScope() = 0;
100     /** Background renderer. Must emit signalBackgroundRenderingFinished(). */
101     virtual QImage renderBackground() = 0;
102
103     ///// Methods /////
104
105     void mouseReleaseEvent(QMouseEvent *);
106     void paintEvent(QPaintEvent *);
107     void resizeEvent(QResizeEvent *);
108
109
110 protected slots:
111     /** Called when the active monitor has shown a new frame. */
112     void slotRenderZoneUpdated();
113     void slotHUDRenderingFinished();
114     void slotScopeRenderingFinished();
115     void slotBackgroundRenderingFinished();
116
117 signals:
118     void signalHUDRenderingFinished();
119     void signalScopeRenderingFinished();
120     void signalBackgroundRenderingFinished();
121
122 private:
123     void prodScopeThread();
124
125 private slots:
126     void customContextMenuRequested(const QPoint &pos);
127     void slotActiveMonitorChanged(bool isClipMonitor);
128
129 };
130
131 #endif // ABSTRACTSCOPEWIDGET_H