]> git.sesse.net Git - kdenlive/blob - src/rotoscoping/rotowidget.h
Integrate with the required MLT hooks for getting Movit to work.
[kdenlive] / src / rotoscoping / rotowidget.h
1 /***************************************************************************
2  *   Copyright (C) 2011 by Till Theato (root@ttill.de)                     *
3  *   This file is part of Kdenlive (www.kdenlive.org).                     *
4  *                                                                         *
5  *   Kdenlive 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  *   Kdenlive is distributed in the hope that it will be useful,           *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with Kdenlive.  If not, see <http://www.gnu.org/licenses/>.     *
17  ***************************************************************************/
18
19 #ifndef ROTOWIDGET_H
20 #define ROTOWIDGET_H
21
22 #include "definitions.h"
23 #include "beziercurve/bpoint.h"
24 #include "timecode.h"
25
26 #include <QWidget>
27
28 class Monitor;
29 class MonitorScene;
30 class SplineItem;
31 class SimpleKeyframeWidget;
32 namespace Mlt
33 {
34 class Filter;
35 }
36
37 /** @brief Adjusts keyframes after resizing a clip. */
38 bool adjustRotoDuration(QString *data, int in, int out);
39
40 class RotoWidget : public QWidget
41 {
42     Q_OBJECT
43
44 public:
45     RotoWidget(const QString &data, Monitor *monitor, const ItemInfo &info, const Timecode &t, QWidget* parent = 0);
46     ~RotoWidget();
47
48     /** @brief Returns the spline(s) in the JSON format used by filter_rotoscoping (MLT). */
49     QString getSpline();
50
51     /** @brief Replaces current data with \param spline (JSON). */
52     void setSpline(const QString &spline, bool notify = true);
53
54     /** @brief Passed on to the keyframe timeline. Switches between frames and hh:mm:ss:ff timecode. */
55     void updateTimecodeFormat();
56
57 public slots:
58     /** @brief Updates the on-monitor item.  */
59     void slotSyncPosition(int relTimelinePos);
60
61 signals:
62     void valueChanged();
63     void seekToPos(int pos);
64
65
66 private:
67     SimpleKeyframeWidget *m_keyframeWidget;
68     Monitor *m_monitor;
69     MonitorScene *m_scene;
70     bool m_showScene;
71     QVariant m_data;
72     SplineItem *m_item;
73     int m_in;
74     int m_out;
75     Mlt::Filter *m_filter;
76
77     /** @brief Returns the list of cubic Bézier points that form the spline at position @param keyframe.
78      * The points are brought from the range [0, 1] into project resolution space.
79      * This function does not do any interpolation and therfore will only return a list when a keyframe at the given postion exists.
80      * Set @param keyframe to -1 if only one keyframe currently exists. */
81     QList <BPoint> getPoints(int keyframe);
82
83     /** @brief Adds tracking_finished as listener for "tracking-finished" event in MLT rotoscoping filter. */
84     void setupTrackingListen(const ItemInfo &info);
85
86     /** @brief Passes list of keyframe positions to keyframe timeline widget. */
87     void keyframeTimelineFullUpdate();
88
89 private slots:
90
91     /** @brief Updates/Creates the spline at @param pos based on the on-monitor items. */
92     void slotUpdateData(int pos = -1, bool editing = false);
93     /** @brief Updates/Creates the spline at the current timeline position based on the on-monitor items. */
94     void slotUpdateData(bool editing);
95
96     /** @brief Updates the on-monitor items to fit the spline at position @param pos. */
97     void slotPositionChanged(int pos, bool seek = true);
98
99     void slotAddKeyframe(int pos = -1);
100     void slotRemoveKeyframe(int pos = -1);
101     void slotMoveKeyframe(int oldPos, int newPos);
102 };
103
104 #endif