]> git.sesse.net Git - kdenlive/blob - src/stopmotion/stopmotion.h
Preliminary support for blackmagic capture (only .raw format for now, cannot be read...
[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
28 class MyLabel : public QLabel
29 {
30   Q_OBJECT
31 public:
32     MyLabel(QWidget *parent = 0);
33     void setImage(QImage img);
34
35 protected:
36     virtual void paintEvent( QPaintEvent * event);
37     virtual void wheelEvent(QWheelEvent * event);
38
39 private:
40     QImage m_img;
41
42 signals:
43     /** @brief Seek to next or previous frame.
44      *  @param forward set to true to go to next frame, fals to go to previous frame */
45     void seek(bool forward);
46 };
47
48 class StopmotionWidget : public QDialog , public Ui::Stopmotion_UI
49 {
50     Q_OBJECT
51
52 public:
53
54     /** @brief Build the stopmotion dialog.
55      * @param projectFolder The current project folder, where captured files will be stored.
56      * @param parent (optional) parent widget */
57     StopmotionWidget(KUrl projectFolder, QWidget *parent = 0);
58     virtual ~StopmotionWidget();
59
60
61 protected:
62
63
64 private:
65   /** @brief Current project folder (where the captured frames will be saved). */
66   KUrl m_projectFolder;
67
68   /** @brief Capture holder that will handle all video operation. */
69   CaptureHandler *m_bmCapture;
70
71   /** @brief Holds the name of the current sequence.
72    * Files will be saved in project folder with name: sequence001.png */
73   QString m_sequenceName;
74
75   /** @brief Holds the frame number of the current sequence. */
76   int m_sequenceFrame;
77
78   QAction *m_captureAction;
79   
80   /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
81   int m_animatedIndex;
82
83   /** @brief Find all stopmotion sequences in current project folder. */
84   void parseExistingSequences();
85
86   /** @brief Select a frame in the list. */
87   void selectFrame(int ix);
88
89   /** @brief This widget will hold the frame preview. */
90   MyLabel *m_frame_preview;
91
92   /** @brief The list of files in the sequence to create thumbnails. */
93   QStringList m_filesList;
94   
95   /** @brief The index of currently created thumbnail. */
96   int m_currentIndex;
97   
98   /** @brief Holds the state of the threaded thumbnail generation. */
99   QFuture<void> m_future;
100   
101 private slots:
102   /** @brief Display the live feed from capture device.
103    @param isOn enable or disable the feature */
104   void slotLive(bool isOn);
105
106   /** @brief Display the last captured frame over current live feed.
107    @param isOn enable or disable the feature */
108   void slotShowOverlay(bool isOn);
109
110   /** @brief Display the last captured frame over current live feed. */
111   void slotUpdateOverlay();
112
113   /** @brief User changed the capture name. */
114   void sequenceNameChanged(const QString &name);
115
116   /** @brief Grab a frame from current capture feed. */
117   void slotCaptureFrame();
118
119   /** @brief Display a previous frame in monitor. */
120   void slotShowFrame(int);
121
122   /** @brief Get full path for a frame in the sequence.
123    *  @param ix the frame number.
124    *  @param seqName (optional) the name of the sequence. */
125   QString getPathForFrame(int ix, QString seqName = QString());
126
127   /** @brief Add sequence to current project. */
128   void slotAddSequence();
129
130   /** @brief Update the frame list widget with newly created frame. */
131   void slotUpdateFrameList(int ix = -1);
132   
133   /** @brief Display selected fram in monitor. */
134   void slotShowSelectedFrame();
135
136   /** @brief Start animation preview mode. */
137   void slotPlayPreview();
138   
139   /** @brief Simulate animation. */
140   void slotAnimate();
141   
142   /** @brief Seek to previous or next captured frame.
143    *  @param forward set to true for next frame, false for previous one. */
144   void slotSeekFrame(bool forward);
145
146   /** @brief Display warning / error message from capture backend. */
147   void slotGotHDMIMessage(const QString &message);
148
149   /** @brief Create thumbnails for existing sequence frames. */
150   void slotCreateThumbs(QImage img, int ix);
151
152   /** @brief Prepare thumbnails creation. */
153   void slotPrepareThumbs();
154
155 signals:
156   /** @brief Ask to add sequence to current project. */
157   void addOrUpdateSequence(const QString);
158
159   void doCreateThumbs(QImage, int);
160 };
161
162 #endif