1 /***************************************************************************
2 * Copyright (C) 2010 by Till Theato (root@ttill.de) *
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. *
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. *
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 ***************************************************************************/
21 #ifndef GEOMETRYWIDGET_H
22 #define GEOMETRYWIDGET_H
24 #include "ui_geometrywidget_ui.h"
26 #include <mlt++/Mlt.h>
34 class TimecodeDisplay;
35 class OnMonitorRectItem;
36 class OnMonitorPathItem;
37 class QGraphicsRectItem;
40 class GeometryWidget : public QWidget
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 int currentPosition() const;
65 /** @brief Sets up the rect and the geometry object.
66 * @param elem DomElement representing this effect parameter
67 * @param minframe In point of the clip
68 * @param maxframe Out point of the clip */
69 void setupParam(const QDomElement elem, int minframe, int maxframe);
70 /** @brief Updates position of the local timeline to @param relTimelinePos. */
71 void slotSyncPosition(int relTimelinePos);
72 void slotResetKeyframes();
73 void slotUpdateRange(int inPoint, int outPoint);
76 Ui::GeometryWidget_UI m_ui;
78 TimecodeDisplay *m_timePos;
79 /** Position of the clip in timeline. */
81 /** In point of the clip (crop from start). */
83 /** Out point of the clip (crop from end). */
86 MonitorScene *m_scene;
87 OnMonitorRectItem *m_rect;
88 OnMonitorPathItem *m_geomPath;
89 QGraphicsRectItem *m_previous;
90 KeyframeHelper *m_timeline;
91 /** Stores the different settings in the MLT geometry format. */
92 Mlt::Geometry *m_geometry;
93 QStringList m_extraGeometryNames;
94 QStringList m_extraFactors;
95 QList <Mlt::Geometry *>m_extraGeometries;
99 DragValue *m_spinWidth;
100 DragValue *m_spinHeight;
101 DragValue *m_spinSize;
102 DragValue *m_opacity;
103 DragValue *m_rotateX;
104 DragValue *m_rotateY;
105 DragValue *m_rotateZ;
108 /** @brief Update monitor rect with current width / height values. */
109 void updateMonitorGeometry();
112 /** @brief Updates controls according to position.
113 * @param pos (optional) Position to update to
114 * @param seek (optional, default = true) Whether to seek timleine & project monitor to pos
115 * If pos = -1 (default) the value of m_timePos is used. */
116 void slotPositionChanged(int pos = -1, bool seek = true);
117 /** @brief Seeking requested from timeline. */
118 void slotRequestSeek(int pos);
119 /** @brief Updates settings after a keyframe was moved to @param pos. */
120 void slotKeyframeMoved(int pos);
121 /** @brief Adds a keyframe.
122 * @param pos (optional) Position where the keyframe should be added
123 * If pos = -1 (default) the value of m_timePos is used. */
124 void slotAddKeyframe(int pos = -1);
125 /** @brief Deletes a keyframe.
126 * @param pos (optional) Position of the keyframe which should be deleted
127 * If pos = -1 (default) the value of m_timePos is used. */
128 void slotDeleteKeyframe(int pos = -1);
129 /** @brief Goes to the next keyframe or to the end if none is available. */
130 void slotNextKeyframe();
131 /** @brief Goes to the previous keyframe or to the beginning if none is available. */
132 void slotPreviousKeyframe();
133 /** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
134 void slotAddDeleteKeyframe();
136 /** @brief Updates the Mlt::Geometry path object. */
137 void slotUpdatePath();
138 /** @brief Updates the Mlt::Geometry object. */
139 void slotUpdateGeometry();
140 /** @brief Updates the spinBoxes according to the rect. */
141 void slotUpdateProperties();
143 /** @brief Sets the rect's x position to @param value. */
144 void slotSetX(double value);
145 /** @brief Sets the rect's y position to @param value. */
146 void slotSetY(double value);
147 /** @brief Sets the rect's width to @param value. */
148 void slotSetWidth(double value);
149 /** @brief Sets the rect's height to @param value. */
150 void slotSetHeight(double value);
152 /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
153 void slotResize(double value);
155 /** @brief Sets the opacity to @param value. */
156 void slotSetOpacity(double value);
158 /** @brief Moves the rect to the left frame border (x position = 0). */
160 /** @brief Centers the rect horizontally. */
162 /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
163 void slotMoveRight();
164 /** @brief Moves the rect to the top frame border (y position = 0). */
166 /** @brief Centers the rect vertically. */
168 /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
169 void slotMoveBottom();
171 /** @brief Enables/Disables syncing with the timeline according to @param sync. */
172 void slotSetSynchronize(bool sync);
173 void slotAdjustToFrameSize();
174 void slotFitToWidth();
175 void slotFitToHeight();
176 /** @brief Show / hide previous keyframe in monitor scene. */
177 void slotShowPreviousKeyFrame(bool show);
180 void parameterChanged();
182 void importClipKeyframes();