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