]> git.sesse.net Git - kdenlive/blobdiff - src/stopmotion/stopmotion.h
Complete rewrite of the video4linux capture to use MLT, in progress.
[kdenlive] / src / stopmotion / stopmotion.h
index 7742447b840f733e8549862802a96739bf00de09..dcdfa39e79124948b67041af7e755b563b9fd93e 100644 (file)
 #include "../blackmagic/capture.h"
 
 #include <KUrl>
+#include <QLabel>
+#include <QFuture>
+#include <QVBoxLayout>
+#include <QTimer>
+#include <abstractmonitor.h>
 
-class StopmotionWidget : public QDialog , public Ui::Stopmotion_UI
+class MltDeviceCapture;
+class MonitorManager;
+class VideoPreviewContainer;
+
+class MyLabel : public QLabel
+{
+    Q_OBJECT
+public:
+    MyLabel(QWidget* parent = 0);
+    void setImage(QImage img);
+
+protected:
+    virtual void paintEvent(QPaintEvent* event);
+    virtual void wheelEvent(QWheelEvent* event);
+    virtual void mousePressEvent(QMouseEvent*);
+
+private:
+    QImage m_img;
+
+signals:
+    /** @brief Seek to next or previous frame.
+     *  @param forward set to true to go to next frame, fals to go to previous frame */
+    void seek(bool forward);
+
+    /** @brief Switch to live view. */
+    void switchToLive();
+};
+
+
+class StopmotionMonitor : public AbstractMonitor
+{
+    Q_OBJECT
+public:
+    StopmotionMonitor(QWidget *parent);
+    ~StopmotionMonitor();
+    AbstractRender *abstractRender();
+    const QString name() const;
+    void setRender(MltDeviceCapture *render);
+
+private:
+    MltDeviceCapture *m_captureDevice;
+
+public slots:
+    virtual void stop();
+    virtual void start();
+
+signals:
+    void stopCapture();
+};
+
+
+class StopmotionWidget : public QDialog, public Ui::Stopmotion_UI
 {
     Q_OBJECT
 
@@ -31,77 +87,163 @@ public:
 
     /** @brief Build the stopmotion dialog.
      * @param projectFolder The current project folder, where captured files will be stored.
+     * @param actions The actions for this widget that can have a keyboard shortcut.
      * @param parent (optional) parent widget */
-    StopmotionWidget(KUrl projectFolder, QWidget *parent = 0);
+    StopmotionWidget(MonitorManager *manager, KUrl projectFolder, QList< QAction* > actions, QWidget* parent = 0);
     virtual ~StopmotionWidget();
 
-
 protected:
-
+    virtual void closeEvent(QCloseEvent* e);
 
 private:
-  /** @brief Current project folder (where the captured frames will be saved). */
-  KUrl m_projectFolder;
+    /** @brief Current project folder (where the captured frames will be saved). */
+    KUrl m_projectFolder;
+
+    /** @brief Capture holder that will handle all video operation. */
+    MltDeviceCapture *m_captureDevice;
+
+    VideoPreviewContainer *m_videoBox;
+    
+    //CaptureHandler* m_bmCapture;
 
-  /** @brief Capture holder that will handle all video operation. */
-  CaptureHandler *m_bmCapture;
+    /** @brief Holds the name of the current sequence.
+     * Files will be saved in project folder with name: sequence001.png */
+    QString m_sequenceName;
 
-  /** @brief Holds the name of the current sequence.
-   * Files will be saved in project folder with name: sequence001.png */
-  QString m_sequenceName;
+    /** @brief Holds the frame number of the current sequence. */
+    int m_sequenceFrame;
 
-  /** @brief Holds the frame number of the current sequence. */
-  int m_sequenceFrame;
+    QAction* m_captureAction;
+
+    /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
+    int m_animatedIndex;
+
+    /** @brief Find all stopmotion sequences in current project folder. */
+    void parseExistingSequences();
+
+    /** @brief Select a frame in the list. */
+    void selectFrame(int ix);
+
+    /** @brief This widget will hold the frame preview. */
+    MyLabel* m_frame_preview;
+
+    /** @brief The list of files in the sequence to create thumbnails. */
+    QStringList m_filesList;
+
+    /** @brief Holds the state of the threaded thumbnail generation. */
+    QFuture<void> m_future;
+
+    /** @brief Get the frame number ix. */
+    QListWidgetItem* getFrameFromIndex(int ix);
+
+    /** @brief The action triggering display of last frame over current live video feed. */
+    QAction* m_showOverlay;
+
+    /** @brief The list of all frames path. */
+    QStringList m_animationList;
+    
+    /** @brief Tells if we are in animation (playback) mode. */
+    bool m_animate;
+    
+    /** @brief Timer for interval capture. */
+    QTimer m_intervalTimer;
+
+    MonitorManager *m_manager;
+
+    StopmotionMonitor *m_monitor;
+
+
+#ifdef QIMAGEBLITZ
+    int m_effectIndex;
+#endif
+
+public slots:
+    /** @brief Display the live feed from capture device.
+     @param isOn enable or disable the feature */
+    void slotLive(bool isOn = true);
+    void slotStopCapture();
 
-  QAction *m_captureAction;
-  
-  /** @brief Holds the index of the frame to be displayed in the frame preview mode. */
-  int m_animatedIndex;
-  
 private slots:
-  /** @brief Display the live feed from capture device.
-   @param isOn enable or disable the feature */
-  void slotLive(bool isOn);
 
-  /** @brief Display the last captured frame over current live feed.
-   @param isOn enable or disable the feature */
-  void slotShowOverlay(bool isOn);
+    /** @brief Display the last captured frame over current live feed.
+     @param isOn enable or disable the feature */
+    void slotShowOverlay(bool isOn);
+
+    /** @brief Display the last captured frame over current live feed. */
+    void slotUpdateOverlay();
+
+    /** @brief User changed the capture name. */
+    void sequenceNameChanged(const QString& name);
+
+    /** @brief Grab a frame from current capture feed. */
+    void slotCaptureFrame();
+
+    /** @brief Display a previous frame in monitor. */
+    void slotShowFrame(const QString& path);
+
+    /** @brief Get full path for a frame in the sequence.
+     *  @param ix the frame number.
+     *  @param seqName (optional) the name of the sequence. */
+    QString getPathForFrame(int ix, QString seqName = QString());
+
+    /** @brief Add sequence to current project. */
+    void slotAddSequence();
 
-  /** @brief Display the last captured frame over current live feed. */
-  void slotUpdateOverlay();
+    /** @brief Display selected fram in monitor. */
+    void slotShowSelectedFrame();
 
-  /** @brief User changed the capture name. */
-  void sequenceNameChanged(const QString &name);
+    /** @brief Start animation preview mode. */
+    void slotPlayPreview(bool animate);
 
-  /** @brief Grab a frame from current capture feed. */
-  void slotCaptureFrame();
+    /** @brief Simulate animation. */
+    void slotAnimate();
 
-  /** @brief Display a previous frame in monitor. */
-  void slotShowFrame(int);
+    /** @brief Seek to previous or next captured frame.
+     *  @param forward set to true for next frame, false for previous one. */
+    void slotSeekFrame(bool forward);
 
-  /** @brief Get full path for a frame in the sequence.
-   *  @param ix the frame number.
-   *  @param seqName (optional) the name of the sequence. */
-  QString getPathForFrame(int ix, QString seqName = QString());
+    /** @brief Display warning / error message from capture backend. */
+    void slotGotHDMIMessage(const QString& message);
 
-  /** @brief Add sequence to current project. */
-  void slotAddSequence();
+    /** @brief Create thumbnails for existing sequence frames. */
+    void slotCreateThumbs(QImage img, int ix);
 
-  /** @brief Update the frame list widget with newly created frame. */
-  void slotUpdateFrameList(int ix = -1);
-  
-  /** @brief Display selected fram in monitor. */
-  void slotShowSelectedFrame();
+    /** @brief Prepare thumbnails creation. */
+    void slotPrepareThumbs();
 
-  /** @brief Start animation preview mode. */
-  void slotPlayPreview();
-  
-  /** @brief Simulate animation. */
-  void slotAnimate();
+    /** @brief Called when user switches the video capture backend. */
+    void slotUpdateHandler();
+
+    /** @brief Show / hide sequence thumbnails. */
+    void slotShowThumbs(bool show);
+
+    /** @brief Show the config dialog */
+    void slotConfigure();
+
+    /** @brief Prepare to crete thumb for newly captured frame. */
+    void slotNewThumb(const QString path);
+
+    /** @brief Set the effect to be applied to overlay frame. */
+    void slotUpdateOverlayEffect(QAction* act);
+
+    /** @brief Switch between live view / currently selected frame. */
+    void slotSwitchLive();
+
+    /** @brief Delete current frame from disk. */
+    void slotRemoveFrame();
+    
+    /** @brief Enable / disable frame analysis (in color scopes). */
+    void slotSwitchAnalyse(bool isOn);
+    
+    /** @brief Send a notification a few seconds before capturing. */
+    void slotPreNotify();
 
 signals:
-  /** @brief Ask to add sequence to current project. */
-  void addOrUpdateSequence(const QString);
+    /** @brief Ask to add sequence to current project. */
+    void addOrUpdateSequence(const QString);
+
+    void doCreateThumbs(QImage, int);
+    void gotFrame(QImage);
 };
 
 #endif