]> git.sesse.net Git - kdenlive/blob - src/geometrywidget.h
Cleanup effect stack (part 2) - show monitor scene when required
[kdenlive] / src / 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 QGraphicsRectItem;
37 class DragValue;
38
39 class GeometryWidget : public QWidget
40 {
41     Q_OBJECT
42 public:
43     /** @brief Sets up the UI and connects it.
44     * @param monitor Project monitor
45     * @param timecode Timecode needed by timecode display widget
46     * @param clipPos Position of the clip in timeline
47     * @param isEffect true if used in an effect, false if used in a transition
48     * @param showRotation Should we show or hide the rotation sliders
49     * @param parent (optional) Parent widget */
50     GeometryWidget(Monitor *monitor, Timecode timecode, int clipPos, bool isEffect, bool showRotation, QWidget* parent = 0);
51     virtual ~GeometryWidget();
52     /** @brief Gets the geometry as a serialized string. */
53     QString getValue() const;
54     QString getExtraValue(const QString &name) const;
55     /** @brief Updates the timecode display according to settings (frame number or hh:mm:ss:ff) */
56     void updateTimecodeFormat();
57     /** @brief Sets the size of the original clip. */
58     void setFrameSize(QPoint size);
59
60     void addParameter(const QDomElement elem);
61
62 public slots:
63     /** @brief Sets up the rect and the geometry object.
64     * @param elem DomElement representing this effect parameter
65     * @param minframe In point of the clip
66     * @param maxframe Out point of the clip */
67     void setupParam(const QDomElement elem, int minframe, int maxframe);
68     /** @brief Updates position of the local timeline to @param relTimelinePos.  */
69     void slotSyncPosition(int relTimelinePos);
70
71 private:
72     Ui::GeometryWidget_UI m_ui;
73     Monitor *m_monitor;
74     TimecodeDisplay *m_timePos;
75     /** Position of the clip in timeline. */
76     int m_clipPos;
77     /** In point of the clip (crop from start). */
78     int m_inPoint;
79     /** Out point of the clip (crop from end). */
80     int m_outPoint;
81     bool m_isEffect;
82     MonitorScene *m_scene;
83     OnMonitorRectItem *m_rect;
84     QGraphicsRectItem *m_previous;
85     KeyframeHelper *m_timeline;
86     /** Stores the different settings in the MLT geometry format. */
87     Mlt::Geometry *m_geometry;
88     QStringList m_extraGeometryNames;
89     QStringList m_extraFactors;
90     QList <Mlt::Geometry *>m_extraGeometries;
91     bool m_showScene;
92     DragValue *m_spinX;
93     DragValue *m_spinY;
94     DragValue *m_spinWidth;
95     DragValue *m_spinHeight;
96     DragValue *m_spinSize;
97     DragValue *m_opacity;
98     DragValue *m_rotateX;
99     DragValue *m_rotateY;
100     DragValue *m_rotateZ;
101     QPoint m_frameSize;
102     bool m_showRotation;
103     /** @brief Update monitor rect with current width / height values. */
104     void updateMonitorGeometry();
105
106 private slots:
107     /** @brief Updates controls according to position.
108     * @param pos (optional) Position to update to
109     * @param seek (optional, default = true) Whether to seek timleine & project monitor to pos
110     * If pos = -1 (default) the value of m_timePos is used. */
111     void slotPositionChanged(int pos = -1, bool seek = true);
112     /** @brief Updates settings after a keyframe was moved to @param pos. */
113     void slotKeyframeMoved(int pos);
114     /** @brief Adds a keyframe.
115     * @param pos (optional) Position where the keyframe should be added
116     * If pos = -1 (default) the value of m_timePos is used. */
117     void slotAddKeyframe(int pos = -1);
118     /** @brief Deletes a keyframe.
119     * @param pos (optional) Position of the keyframe which should be deleted
120     * If pos = -1 (default) the value of m_timePos is used. */
121     void slotDeleteKeyframe(int pos = -1);
122     /** @brief Goes to the next keyframe or to the end if none is available. */
123     void slotNextKeyframe();
124     /** @brief Goes to the previous keyframe or to the beginning if none is available. */
125     void slotPreviousKeyframe();
126     /** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
127     void slotAddDeleteKeyframe();
128
129     /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
130     * @param renderPos Postion of the Monitor / Timeline cursor */
131     void slotCheckMonitorPosition(int renderPos);
132
133     /** @brief Updates the Mlt::Geometry object. */
134     void slotUpdateGeometry();
135     /** @brief Updates the spinBoxes according to the rect. */
136     void slotUpdateProperties();
137
138     /** @brief Sets the rect's x position to @param value. */
139     void slotSetX(double value);
140     /** @brief Sets the rect's y position to @param value. */
141     void slotSetY(double value);
142     /** @brief Sets the rect's width to @param value. */
143     void slotSetWidth(double value);
144     /** @brief Sets the rect's height to @param value. */
145     void slotSetHeight(double value);
146
147     /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
148     void slotResize(double value);
149
150     /** @brief Sets the opacity to @param value. */
151     void slotSetOpacity(double value);
152
153     /** @brief Moves the rect to the left frame border (x position = 0). */
154     void slotMoveLeft();
155     /** @brief Centers the rect horizontally. */
156     void slotCenterH();
157     /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
158     void slotMoveRight();
159     /** @brief Moves the rect to the top frame border (y position = 0). */
160     void slotMoveTop();
161     /** @brief Centers the rect vertically. */
162     void slotCenterV();
163     /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
164     void slotMoveBottom();
165
166     /** @brief Enables/Disables syncing with the timeline according to @param sync. */
167     void slotSetSynchronize(bool sync);
168     void slotAdjustToFrameSize();
169     void slotFitToWidth();
170     void slotFitToHeight();
171     /** @brief Show / hide previous keyframe in monitor scene. */
172     void slotShowPreviousKeyFrame(bool show);
173     /** @brief Switches from normal monitor to monitor scene according to @param show. */
174     void slotShowScene(bool show = true);
175
176 signals:
177     void parameterChanged();
178     void checkMonitorPosition(int);
179     void seekToPos(int);
180 };
181
182 #endif