]> git.sesse.net Git - kdenlive/blob - src/rotoscoping/rotowidget.h
small code cleanup
[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 "bpoint.h"
23 #include "timecode.h"
24
25 #include <QWidget>
26
27 class Monitor;
28 class MonitorScene;
29 class SplineItem;
30 class SimpleKeyframeWidget;
31
32 /** @brief Adjusts keyframes after resizing a clip. */
33 bool adjustRotoDuration(QString *data, int in, int out);
34
35 class RotoWidget : public QWidget
36 {
37     Q_OBJECT
38
39 public:
40     RotoWidget(QString data, Monitor *monitor, int in, int out, Timecode t, QWidget* parent = 0);
41     virtual ~RotoWidget();
42
43     /** @brief Returns the spline(s) in the JSON format used by filter_rotoscoping (MLT). */
44     QString getSpline();
45
46     /** @brief Passed on to the keyframe timeline. Switches between frames and hh:mm:ss:ff timecode. */
47     void updateTimecodeFormat();
48
49 public slots:
50     /** @brief Switches from normal monitor to monitor scene according to @param show. */
51     void slotShowScene(bool show = true);
52     /** @brief Updates the on-monitor item.  */
53     void slotSyncPosition(int relTimelinePos);
54
55 signals:
56     void valueChanged();
57     void checkMonitorPosition(int);
58     void seekToPos(int pos);
59
60
61 private:
62     SimpleKeyframeWidget *m_keyframeWidget;
63     Monitor *m_monitor;
64     MonitorScene *m_scene;
65     bool m_showScene;
66     QVariant m_data;
67     SplineItem *m_item;
68     int m_in;
69     int m_out;
70
71     /** @brief Returns the list of cubic Bézier points that form the spline at position @param keyframe.
72      * The points are brought from the range [0, 1] into project resolution space.
73      * This function does not do any interpolation and therfore will only return a list when a keyframe at the given postion exists.
74      * Set @param keyframe to -1 if only one keyframe currently exists. */
75     QList <BPoint> getPoints(int keyframe);
76
77 private slots:
78     /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
79     * @param renderPos Postion of the Monitor / Timeline cursor */
80     void slotCheckMonitorPosition(int renderPos);
81
82     /** @brief Updates/Creates the spline at @param pos based on the on-monitor items. */
83     void slotUpdateData(int pos = -1, bool editing = false);
84     /** @brief Updates/Creates the spline at the current timeline position based on the on-monitor items. */
85     void slotUpdateData(bool editing);
86
87     /** @brief Updates the on-monitor items to fit the spline at position @param pos. */
88     void slotPositionChanged(int pos, bool seek = true);
89
90     void slotAddKeyframe(int pos = -1);
91     void slotRemoveKeyframe(int pos = -1);
92     void slotMoveKeyframe(int oldPos, int newPos);
93 };
94
95 #endif