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 clipPos Position of the clip in timeline
45 * @param parent (optional) Parent widget */
46 GeometryWidget(Monitor *monitor, Timecode timecode, int clipPos, bool isEffect, QWidget* parent = 0);
47 virtual ~GeometryWidget();
48 /** @brief Gets the geometry as a serialized string. */
49 QString getValue() const;
50 /** @brief Updates the timecode display according to settings (frame number or hh:mm:ss:ff) */
51 void updateTimecodeFormat();
54 /** @brief Sets up the rect and the geometry object.
55 * @param elem DomElement representing this effect parameter
56 * @param minframe In point of the clip
57 * @param maxframe Out point of the clip */
58 void setupParam(const QDomElement elem, int minframe, int maxframe);
59 /** @brief Updates position of the local timeline to @param relTimelinePos. */
60 void slotSyncPosition(int relTimelinePos);
63 Ui::GeometryWidget_UI m_ui;
65 TimecodeDisplay *m_timePos;
66 /** Position of the clip in timeline. */
68 /** In point of the clip (crop from start). */
70 /** Out point of the clip (crop from end). */
73 MonitorScene *m_scene;
74 OnMonitorRectItem *m_rect;
75 KeyframeHelper *m_timeline;
76 /** Stores the different settings in the MLT geometry format. */
77 Mlt::Geometry *m_geometry;
81 /** @brief Updates controls according to position.
82 * @param pos (optional) Position to update to
83 * @param seek (optional, default = true) Whether to seek timleine & project monitor to pos
84 * If pos = -1 (default) the value of m_timePos is used. */
85 void slotPositionChanged(int pos = -1, bool seek = true);
86 /** @brief Updates settings after a keyframe was moved to @param pos. */
87 void slotKeyframeMoved(int pos);
88 /** @brief Adds a keyframe.
89 * @param pos (optional) Position where the keyframe should be added
90 * If pos = -1 (default) the value of m_timePos is used. */
91 void slotAddKeyframe(int pos = -1);
92 /** @brief Deletes a keyframe.
93 * @param pos (optional) Position of the keyframe which should be deleted
94 * If pos = -1 (default) the value of m_timePos is used. */
95 void slotDeleteKeyframe(int pos = -1);
96 /** @brief Goes to the next keyframe or to the end if none is available. */
97 void slotNextKeyframe();
98 /** @brief Goes to the previous keyframe or to the beginning if none is available. */
99 void slotPreviousKeyframe();
100 /** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
101 void slotAddDeleteKeyframe();
103 /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
104 * @param renderPos Postion of the Monitor / Timeline cursor */
105 void slotCheckMonitorPosition(int renderPos);
107 /** @brief Updates the Mlt::Geometry object. */
108 void slotUpdateGeometry();
109 /** @brief Updates the spinBoxes according to the rect. */
110 void slotUpdateProperties();
112 /** @brief Sets the rect's x position to @param value. */
113 void slotSetX(int value);
114 /** @brief Sets the rect's y position to @param value. */
115 void slotSetY(int value);
116 /** @brief Sets the rect's width to @param value. */
117 void slotSetWidth(int value);
118 /** @brief Sets the rect's height to @param value. */
119 void slotSetHeight(int value);
121 /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
122 void slotResize(int value);
124 /** @brief Sets the opacity to @param value. */
125 void slotSetOpacity(int value);
127 /** @brief Moves the rect to the left frame border (x position = 0). */
129 /** @brief Centers the rect horizontally. */
131 /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
132 void slotMoveRight();
133 /** @brief Moves the rect to the top frame border (y position = 0). */
135 /** @brief Centers the rect vertically. */
137 /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
138 void slotMoveBottom();
140 /** @brief Enables/Disables syncing with the timeline according to @param sync. */
141 void slotSetSynchronize(bool sync);
142 /** @brief Switches from normal monitor to monitor scene according to @param show. */
143 void slotShowScene(bool show = true);
146 void parameterChanged();
147 void checkMonitorPosition(int);