]> git.sesse.net Git - kdenlive/blob - src/widgets/geometrywidget.h
Moving choosecolorwidget and colorpickerwidget in the widget folder.
[kdenlive] / src / widgets / 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     explicit GeometryWidget(Monitor *monitor, const 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(const QPoint &size);
60     void addParameter(const QDomElement &elem);
61     void importKeyframes(const QString &data, int maximum);
62     int currentPosition() const;
63
64 public slots:
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 slotResetNextKeyframes();
74     void slotResetPreviousKeyframes();
75     void slotUpdateRange(int inPoint, int outPoint);
76
77 private:
78     Ui::GeometryWidget_UI m_ui;
79     Monitor *m_monitor;
80     TimecodeDisplay *m_timePos;
81     /** Position of the clip in timeline. */
82     int m_clipPos;
83     /** In point of the clip (crop from start). */
84     int m_inPoint;
85     /** Out point of the clip (crop from end). */
86     int m_outPoint;
87     bool m_isEffect;
88     MonitorScene *m_scene;
89     OnMonitorRectItem *m_rect;
90     OnMonitorPathItem *m_geomPath;
91     QGraphicsRectItem *m_previous;
92     KeyframeHelper *m_timeline;
93     /** Stores the different settings in the MLT geometry format. */
94     Mlt::Geometry *m_geometry;
95     QStringList m_extraGeometryNames;
96     QStringList m_extraFactors;
97     QList <Mlt::Geometry *>m_extraGeometries;
98     bool m_showScene;
99     DragValue *m_spinX;
100     DragValue *m_spinY;
101     DragValue *m_spinWidth;
102     DragValue *m_spinHeight;
103     DragValue *m_spinSize;
104     DragValue *m_opacity;
105     DragValue *m_rotateX;
106     DragValue *m_rotateY;
107     DragValue *m_rotateZ;
108     QPoint m_frameSize;
109     bool m_showRotation;
110     /** @brief Update monitor rect with current width / height values. */
111     void updateMonitorGeometry();
112
113 private slots:
114     /** @brief Updates controls according to position.
115     * @param pos (optional) Position to update to
116     * @param seek (optional, default = true) Whether to seek timleine & project monitor to pos
117     * If pos = -1 (default) the value of m_timePos is used. */
118     void slotPositionChanged(int pos = -1, bool seek = true);
119     /** @brief Seeking requested from timeline. */
120     void slotRequestSeek(int pos);
121     /** @brief Updates settings after a keyframe was moved to @param pos. */
122     void slotKeyframeMoved(int pos);
123     /** @brief Adds a keyframe.
124     * @param pos (optional) Position where the keyframe should be added
125     * If pos = -1 (default) the value of m_timePos is used. */
126     void slotAddKeyframe(int pos = -1);
127     /** @brief Deletes a keyframe.
128     * @param pos (optional) Position of the keyframe which should be deleted
129     * If pos = -1 (default) the value of m_timePos is used. */
130     void slotDeleteKeyframe(int pos = -1);
131     /** @brief Goes to the next keyframe or to the end if none is available. */
132     void slotNextKeyframe();
133     /** @brief Goes to the previous keyframe or to the beginning if none is available. */
134     void slotPreviousKeyframe();
135     /** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
136     void slotAddDeleteKeyframe();
137
138     /** @brief Updates the Mlt::Geometry path object. */
139     void slotUpdatePath();
140     /** @brief Updates the Mlt::Geometry object. */
141     void slotUpdateGeometry();
142     /** @brief Updates the spinBoxes according to the rect. */
143     void slotUpdateProperties();
144
145     /** @brief Sets the rect's x position to @param value. */
146     void slotSetX(double value);
147     /** @brief Sets the rect's y position to @param value. */
148     void slotSetY(double value);
149     /** @brief Sets the rect's width to @param value. */
150     void slotSetWidth(double value);
151     /** @brief Sets the rect's height to @param value. */
152     void slotSetHeight(double value);
153
154     /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
155     void slotResize(double value);
156
157     /** @brief Sets the opacity to @param value. */
158     void slotSetOpacity(double value);
159
160     /** @brief Moves the rect to the left frame border (x position = 0). */
161     void slotMoveLeft();
162     /** @brief Centers the rect horizontally. */
163     void slotCenterH();
164     /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
165     void slotMoveRight();
166     /** @brief Moves the rect to the top frame border (y position = 0). */
167     void slotMoveTop();
168     /** @brief Centers the rect vertically. */
169     void slotCenterV();
170     /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
171     void slotMoveBottom();
172
173     /** @brief Enables/Disables syncing with the timeline according to @param sync. */
174     void slotSetSynchronize(bool sync);
175     void slotAdjustToFrameSize();
176     void slotFitToWidth();
177     void slotFitToHeight();
178     /** @brief Show / hide previous keyframe in monitor scene. */
179     void slotShowPreviousKeyFrame(bool show);
180     /** @brief Show / hide keyframe path in monitor scene. */
181     void slotShowPath(bool show);
182
183 signals:
184     void parameterChanged();
185     void seekToPos(int);
186     void importClipKeyframes();
187 };
188
189 #endif