]> git.sesse.net Git - kdenlive/blob - src/stopmotion/stopmotion.h
Complete rewrite of the video4linux capture to use MLT, in progress.
[kdenlive] / src / stopmotion / stopmotion.h
1 /***************************************************************************
2                           titlewidget.h  -  description
3                              -------------------
4     begin                : Feb 28 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef STOPMOTION_H
19 #define STOPMOTION_H
20
21 #include "ui_stopmotion_ui.h"
22 #include "../blackmagic/capture.h"
23
24 #include <KUrl>
25 #include <QLabel>
26 #include <QFuture>
27 #include <QVBoxLayout>
28 #include <QTimer>
29 #include <abstractmonitor.h>
30
31 class MltDeviceCapture;
32 class MonitorManager;
33 class VideoPreviewContainer;
34
35 class MyLabel : public QLabel
36 {
37     Q_OBJECT
38 public:
39     MyLabel(QWidget* parent = 0);
40     void setImage(QImage img);
41
42 protected:
43     virtual void paintEvent(QPaintEvent* event);
44     virtual void wheelEvent(QWheelEvent* event);
45     virtual void mousePressEvent(QMouseEvent*);
46
47 private:
48     QImage m_img;
49
50 signals:
51     /** @brief Seek to next or previous frame.
52      *  @param forward set to true to go to next frame, fals to go to previous frame */
53     void seek(bool forward);
54
55     /** @brief Switch to live view. */
56     void switchToLive();
57 };
58
59
60 class StopmotionMonitor : public AbstractMonitor
61 {
62     Q_OBJECT
63 public:
64     StopmotionMonitor(QWidget *parent);
65     ~StopmotionMonitor();
66     AbstractRender *abstractRender();
67     const QString name() const;
68     void setRender(MltDeviceCapture *render);
69
70 private:
71     MltDeviceCapture *m_captureDevice;
72
73 public slots:
74     virtual void stop();
75     virtual void start();
76
77 signals:
78     void stopCapture();
79 };
80
81
82 class StopmotionWidget : public QDialog, public Ui::Stopmotion_UI
83 {
84     Q_OBJECT
85
86 public:
87
88     /** @brief Build the stopmotion dialog.
89      * @param projectFolder The current project folder, where captured files will be stored.
90      * @param actions The actions for this widget that can have a keyboard shortcut.
91      * @param parent (optional) parent widget */
92     StopmotionWidget(MonitorManager *manager, KUrl projectFolder, QList< QAction* > actions, QWidget* parent = 0);
93     virtual ~StopmotionWidget();
94
95 protected:
96     virtual void closeEvent(QCloseEvent* e);
97
98 private:
99     /** @brief Current project folder (where the captured frames will be saved). */
100     KUrl m_projectFolder;
101
102     /** @brief Capture holder that will handle all video operation. */
103     MltDeviceCapture *m_captureDevice;
104
105     VideoPreviewContainer *m_videoBox;
106     
107     //CaptureHandler* m_bmCapture;
108
109     /** @brief Holds the name of the current sequence.
110      * Files will be saved in project folder with name: sequence001.png */
111     QString m_sequenceName;
112
113     /** @brief Holds the frame number of the current sequence. */
114     int m_sequenceFrame;
115
116     QAction* m_captureAction;
117
118     /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
119     int m_animatedIndex;
120
121     /** @brief Find all stopmotion sequences in current project folder. */
122     void parseExistingSequences();
123
124     /** @brief Select a frame in the list. */
125     void selectFrame(int ix);
126
127     /** @brief This widget will hold the frame preview. */
128     MyLabel* m_frame_preview;
129
130     /** @brief The list of files in the sequence to create thumbnails. */
131     QStringList m_filesList;
132
133     /** @brief Holds the state of the threaded thumbnail generation. */
134     QFuture<void> m_future;
135
136     /** @brief Get the frame number ix. */
137     QListWidgetItem* getFrameFromIndex(int ix);
138
139     /** @brief The action triggering display of last frame over current live video feed. */
140     QAction* m_showOverlay;
141
142     /** @brief The list of all frames path. */
143     QStringList m_animationList;
144     
145     /** @brief Tells if we are in animation (playback) mode. */
146     bool m_animate;
147     
148     /** @brief Timer for interval capture. */
149     QTimer m_intervalTimer;
150
151     MonitorManager *m_manager;
152
153     StopmotionMonitor *m_monitor;
154
155
156 #ifdef QIMAGEBLITZ
157     int m_effectIndex;
158 #endif
159
160 public slots:
161     /** @brief Display the live feed from capture device.
162      @param isOn enable or disable the feature */
163     void slotLive(bool isOn = true);
164     void slotStopCapture();
165
166 private slots:
167
168     /** @brief Display the last captured frame over current live feed.
169      @param isOn enable or disable the feature */
170     void slotShowOverlay(bool isOn);
171
172     /** @brief Display the last captured frame over current live feed. */
173     void slotUpdateOverlay();
174
175     /** @brief User changed the capture name. */
176     void sequenceNameChanged(const QString& name);
177
178     /** @brief Grab a frame from current capture feed. */
179     void slotCaptureFrame();
180
181     /** @brief Display a previous frame in monitor. */
182     void slotShowFrame(const QString& path);
183
184     /** @brief Get full path for a frame in the sequence.
185      *  @param ix the frame number.
186      *  @param seqName (optional) the name of the sequence. */
187     QString getPathForFrame(int ix, QString seqName = QString());
188
189     /** @brief Add sequence to current project. */
190     void slotAddSequence();
191
192     /** @brief Display selected fram in monitor. */
193     void slotShowSelectedFrame();
194
195     /** @brief Start animation preview mode. */
196     void slotPlayPreview(bool animate);
197
198     /** @brief Simulate animation. */
199     void slotAnimate();
200
201     /** @brief Seek to previous or next captured frame.
202      *  @param forward set to true for next frame, false for previous one. */
203     void slotSeekFrame(bool forward);
204
205     /** @brief Display warning / error message from capture backend. */
206     void slotGotHDMIMessage(const QString& message);
207
208     /** @brief Create thumbnails for existing sequence frames. */
209     void slotCreateThumbs(QImage img, int ix);
210
211     /** @brief Prepare thumbnails creation. */
212     void slotPrepareThumbs();
213
214     /** @brief Called when user switches the video capture backend. */
215     void slotUpdateHandler();
216
217     /** @brief Show / hide sequence thumbnails. */
218     void slotShowThumbs(bool show);
219
220     /** @brief Show the config dialog */
221     void slotConfigure();
222
223     /** @brief Prepare to crete thumb for newly captured frame. */
224     void slotNewThumb(const QString path);
225
226     /** @brief Set the effect to be applied to overlay frame. */
227     void slotUpdateOverlayEffect(QAction* act);
228
229     /** @brief Switch between live view / currently selected frame. */
230     void slotSwitchLive();
231
232     /** @brief Delete current frame from disk. */
233     void slotRemoveFrame();
234     
235     /** @brief Enable / disable frame analysis (in color scopes). */
236     void slotSwitchAnalyse(bool isOn);
237     
238     /** @brief Send a notification a few seconds before capturing. */
239     void slotPreNotify();
240
241 signals:
242     /** @brief Ask to add sequence to current project. */
243     void addOrUpdateSequence(const QString);
244
245     void doCreateThumbs(QImage, int);
246     void gotFrame(QImage);
247 };
248
249 #endif