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;
38 class GeometryWidget : public QWidget
42 /** @brief Sets up the UI and connects it.
43 * @param monitor Project monitor
44 * @param timecode Timecode needed by timecode display widget
45 * @param clipPos Position of the clip in timeline
46 * @param isEffect true if used in an effect, false if used in a transition
47 * @param parent (optional) Parent widget */
48 GeometryWidget(Monitor *monitor, Timecode timecode, int clipPos, bool isEffect, QWidget* parent = 0);
49 virtual ~GeometryWidget();
50 /** @brief Gets the geometry as a serialized string. */
51 QString getValue() const;
52 /** @brief Updates the timecode display according to settings (frame number or hh:mm:ss:ff) */
53 void updateTimecodeFormat();
54 /** @brief Sets the size of the original clip. */
55 void setFrameSize(QPoint size);
58 /** @brief Sets up the rect and the geometry object.
59 * @param elem DomElement representing this effect parameter
60 * @param minframe In point of the clip
61 * @param maxframe Out point of the clip */
62 void setupParam(const QDomElement elem, int minframe, int maxframe);
63 /** @brief Updates position of the local timeline to @param relTimelinePos. */
64 void slotSyncPosition(int relTimelinePos);
65 /** @brief Switches from normal monitor to monitor scene according to @param show. */
66 void slotShowScene(bool show = true);
69 Ui::GeometryWidget_UI m_ui;
71 TimecodeDisplay *m_timePos;
72 /** Position of the clip in timeline. */
74 /** In point of the clip (crop from start). */
76 /** Out point of the clip (crop from end). */
79 MonitorScene *m_scene;
80 OnMonitorRectItem *m_rect;
81 KeyframeHelper *m_timeline;
82 /** Stores the different settings in the MLT geometry format. */
83 Mlt::Geometry *m_geometry;
87 DragValue *m_spinWidth;
88 DragValue *m_spinHeight;
89 DragValue *m_spinSize;
94 /** @brief Updates controls according to position.
95 * @param pos (optional) Position to update to
96 * @param seek (optional, default = true) Whether to seek timleine & project monitor to pos
97 * If pos = -1 (default) the value of m_timePos is used. */
98 void slotPositionChanged(int pos = -1, bool seek = true);
99 /** @brief Updates settings after a keyframe was moved to @param pos. */
100 void slotKeyframeMoved(int pos);
101 /** @brief Adds a keyframe.
102 * @param pos (optional) Position where the keyframe should be added
103 * If pos = -1 (default) the value of m_timePos is used. */
104 void slotAddKeyframe(int pos = -1);
105 /** @brief Deletes a keyframe.
106 * @param pos (optional) Position of the keyframe which should be deleted
107 * If pos = -1 (default) the value of m_timePos is used. */
108 void slotDeleteKeyframe(int pos = -1);
109 /** @brief Goes to the next keyframe or to the end if none is available. */
110 void slotNextKeyframe();
111 /** @brief Goes to the previous keyframe or to the beginning if none is available. */
112 void slotPreviousKeyframe();
113 /** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
114 void slotAddDeleteKeyframe();
116 /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
117 * @param renderPos Postion of the Monitor / Timeline cursor */
118 void slotCheckMonitorPosition(int renderPos);
120 /** @brief Updates the Mlt::Geometry object. */
121 void slotUpdateGeometry();
122 /** @brief Updates the spinBoxes according to the rect. */
123 void slotUpdateProperties();
125 /** @brief Sets the rect's x position to @param value. */
126 void slotSetX(int value);
127 /** @brief Sets the rect's y position to @param value. */
128 void slotSetY(int value);
129 /** @brief Sets the rect's width to @param value. */
130 void slotSetWidth(int value);
131 /** @brief Sets the rect's height to @param value. */
132 void slotSetHeight(int value);
134 /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
135 void slotResize(int value);
137 /** @brief Sets the opacity to @param value. */
138 void slotSetOpacity(int value);
140 /** @brief Moves the rect to the left frame border (x position = 0). */
142 /** @brief Centers the rect horizontally. */
144 /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
145 void slotMoveRight();
146 /** @brief Moves the rect to the top frame border (y position = 0). */
148 /** @brief Centers the rect vertically. */
150 /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
151 void slotMoveBottom();
153 /** @brief Enables/Disables syncing with the timeline according to @param sync. */
154 void slotSetSynchronize(bool sync);
155 void slotAdjustToFrameSize();
156 void slotFitToWidth();
157 void slotFitToHeight();
160 void parameterChanged();
161 void checkMonitorPosition(int);