]> git.sesse.net Git - kdenlive/blob - src/geometrywidget.h
Minor improvements to keyframe widget, allow resetting keyframes
[kdenlive] / src / geometrywidget.h
1 /***************************************************************************
2  *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef GEOMETRYWIDGET_H
22 #define GEOMETRYWIDGET_H
23
24 #include "ui_geometrywidget_ui.h"
25 #include "timecode.h"
26 #include <mlt++/Mlt.h>
27
28 #include <QWidget>
29
30 class QDomElement;
31 class Monitor;
32 class MonitorScene;
33 class KeyframeHelper;
34 class TimecodeDisplay;
35 class OnMonitorRectItem;
36 class OnMonitorPathItem;
37 class QGraphicsRectItem;
38 class DragValue;
39
40 class GeometryWidget : public QWidget
41 {
42     Q_OBJECT
43 public:
44     /** @brief Sets up the UI and connects it.
45     * @param monitor Project monitor
46     * @param timecode Timecode needed by timecode display widget
47     * @param clipPos Position of the clip in timeline
48     * @param isEffect true if used in an effect, false if used in a transition
49     * @param showRotation Should we show or hide the rotation sliders
50     * @param parent (optional) Parent widget */
51     GeometryWidget(Monitor *monitor, Timecode timecode, int clipPos, bool isEffect, bool showRotation, QWidget* parent = 0);
52     virtual ~GeometryWidget();
53     /** @brief Gets the geometry as a serialized string. */
54     QString getValue() const;
55     QString getExtraValue(const QString &name) const;
56     /** @brief Updates the timecode display according to settings (frame number or hh:mm:ss:ff) */
57     void updateTimecodeFormat();
58     /** @brief Sets the size of the original clip. */
59     void setFrameSize(QPoint size);
60     void addParameter(const QDomElement elem);
61     void importKeyframes(const QString &data, int maximum);
62
63 public slots:
64     /** @brief Sets up the rect and the geometry object.
65     * @param elem DomElement representing this effect parameter
66     * @param minframe In point of the clip
67     * @param maxframe Out point of the clip */
68     void setupParam(const QDomElement elem, int minframe, int maxframe);
69     /** @brief Updates position of the local timeline to @param relTimelinePos.  */
70     void slotSyncPosition(int relTimelinePos);
71     void slotResetKeyframes();
72
73 private:
74     Ui::GeometryWidget_UI m_ui;
75     Monitor *m_monitor;
76     TimecodeDisplay *m_timePos;
77     /** Position of the clip in timeline. */
78     int m_clipPos;
79     /** In point of the clip (crop from start). */
80     int m_inPoint;
81     /** Out point of the clip (crop from end). */
82     int m_outPoint;
83     bool m_isEffect;
84     MonitorScene *m_scene;
85     OnMonitorRectItem *m_rect;
86     OnMonitorPathItem *m_geomPath;
87     QGraphicsRectItem *m_previous;
88     KeyframeHelper *m_timeline;
89     /** Stores the different settings in the MLT geometry format. */
90     Mlt::Geometry *m_geometry;
91     QStringList m_extraGeometryNames;
92     QStringList m_extraFactors;
93     QList <Mlt::Geometry *>m_extraGeometries;
94     bool m_showScene;
95     DragValue *m_spinX;
96     DragValue *m_spinY;
97     DragValue *m_spinWidth;
98     DragValue *m_spinHeight;
99     DragValue *m_spinSize;
100     DragValue *m_opacity;
101     DragValue *m_rotateX;
102     DragValue *m_rotateY;
103     DragValue *m_rotateZ;
104     QPoint m_frameSize;
105     bool m_showRotation;
106     /** @brief Update monitor rect with current width / height values. */
107     void updateMonitorGeometry();
108
109 private slots:
110     /** @brief Updates controls according to position.
111     * @param pos (optional) Position to update to
112     * @param seek (optional, default = true) Whether to seek timleine & project monitor to pos
113     * If pos = -1 (default) the value of m_timePos is used. */
114     void slotPositionChanged(int pos = -1, bool seek = true);
115     /** @brief Seeking requested from timeline. */
116     void slotRequestSeek(int pos);
117     /** @brief Updates settings after a keyframe was moved to @param pos. */
118     void slotKeyframeMoved(int pos);
119     /** @brief Adds a keyframe.
120     * @param pos (optional) Position where the keyframe should be added
121     * If pos = -1 (default) the value of m_timePos is used. */
122     void slotAddKeyframe(int pos = -1);
123     /** @brief Deletes a keyframe.
124     * @param pos (optional) Position of the keyframe which should be deleted
125     * If pos = -1 (default) the value of m_timePos is used. */
126     void slotDeleteKeyframe(int pos = -1);
127     /** @brief Goes to the next keyframe or to the end if none is available. */
128     void slotNextKeyframe();
129     /** @brief Goes to the previous keyframe or to the beginning if none is available. */
130     void slotPreviousKeyframe();
131     /** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
132     void slotAddDeleteKeyframe();
133
134     /** @brief Updates the Mlt::Geometry path object. */
135     void slotUpdatePath();
136     /** @brief Updates the Mlt::Geometry object. */
137     void slotUpdateGeometry();
138     /** @brief Updates the spinBoxes according to the rect. */
139     void slotUpdateProperties();
140
141     /** @brief Sets the rect's x position to @param value. */
142     void slotSetX(double value);
143     /** @brief Sets the rect's y position to @param value. */
144     void slotSetY(double value);
145     /** @brief Sets the rect's width to @param value. */
146     void slotSetWidth(double value);
147     /** @brief Sets the rect's height to @param value. */
148     void slotSetHeight(double value);
149
150     /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
151     void slotResize(double value);
152
153     /** @brief Sets the opacity to @param value. */
154     void slotSetOpacity(double value);
155
156     /** @brief Moves the rect to the left frame border (x position = 0). */
157     void slotMoveLeft();
158     /** @brief Centers the rect horizontally. */
159     void slotCenterH();
160     /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
161     void slotMoveRight();
162     /** @brief Moves the rect to the top frame border (y position = 0). */
163     void slotMoveTop();
164     /** @brief Centers the rect vertically. */
165     void slotCenterV();
166     /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
167     void slotMoveBottom();
168
169     /** @brief Enables/Disables syncing with the timeline according to @param sync. */
170     void slotSetSynchronize(bool sync);
171     void slotAdjustToFrameSize();
172     void slotFitToWidth();
173     void slotFitToHeight();
174     /** @brief Show / hide previous keyframe in monitor scene. */
175     void slotShowPreviousKeyFrame(bool show);
176
177 signals:
178     void parameterChanged();
179     void seekToPos(int);
180     void importClipKeyframes();
181 };
182
183 #endif