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