]> git.sesse.net Git - kdenlive/blob - src/geometrywidget.h
35369f434154e2d27016ccf26dde65934da3b968
[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 QGraphicsRectItem;
32 class Monitor;
33 class MonitorScene;
34 class KeyframeHelper;
35 class TimecodeDisplay;
36
37 class GeometryWidget : public QWidget
38 {
39     Q_OBJECT
40 public:
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();
51
52 public slots:
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
59 private:
60     Ui::GeometryWidget_UI m_ui;
61     Monitor *m_monitor;
62     TimecodeDisplay *m_timePos;
63     /** Position of the clip in timeline. */
64     int m_clipPos;
65     /** In point of the clip (crop from start). */
66     int m_inPoint;
67     /** Out point of the clip (crop from end). */
68     int m_outPoint;
69     bool m_isEffect;
70     MonitorScene *m_scene;
71     QGraphicsRectItem *m_rect;
72     KeyframeHelper *m_timeline;
73     /** Stores the different settings in the MLT geometry format. */
74     Mlt::Geometry *m_geometry;
75
76 private slots:
77     /** @brief Updates controls according to position.
78     * @param pos (optional) Position to update to
79     * @param seek (optional, default = true) Whether to seek timleine & project monitor to pos
80     * If pos = -1 (default) the value of m_timePos is used. */
81     void slotPositionChanged(int pos = -1, bool seek = true);
82     /** @brief Updates settings after a keyframe was moved to @param pos. */
83     void slotKeyframeMoved(int pos);
84     /** @brief Adds a keyframe.
85     * @param pos (optional) Position where the keyframe should be added
86     * If pos = -1 (default) the value of m_timePos is used. */
87     void slotAddKeyframe(int pos = -1);
88     /** @brief Deletes a keyframe.
89     * @param pos (optional) Position of the keyframe which should be deleted
90     * If pos = -1 (default) the value of m_timePos is used. */
91     void slotDeleteKeyframe(int pos = -1);
92     /** @brief Goes to the next keyframe or to the end if none is available. */
93     void slotNextKeyframe();
94     /** @brief Goes to the previous keyframe or to the beginning if none is available. */
95     void slotPreviousKeyframe();
96     /** @brief Adds or deletes a keyframe depending on whether there is already a keyframe at the current position. */
97     void slotAddDeleteKeyframe();
98
99     /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
100     * @param renderPos Postion of the Monitor / Timeline cursor */
101     void slotCheckMonitorPosition(int renderPos);
102
103     /** @brief Updates the Mlt::Geometry object. */
104     void slotUpdateGeometry();
105     /** @brief Updates the spinBoxes according to the rect. */
106     void slotUpdateProperties();
107
108     /** @brief Sets the rect's x position to @param value. */
109     void slotSetX(int value);
110     /** @brief Sets the rect's y position to @param value. */
111     void slotSetY(int value);
112     /** @brief Sets the rect's width to @param value. */
113     void slotSetWidth(int value);
114     /** @brief Sets the rect's height to @param value. */
115     void slotSetHeight(int value);
116
117     /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
118     void slotResize(int value);
119
120     /** @brief Moves the rect to the left frame border (x position = 0). */
121     void slotMoveLeft();
122     /** @brief Centers the rect horizontally. */
123     void slotCenterH();
124     /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
125     void slotMoveRight();
126     /** @brief Moves the rect to the top frame border (y position = 0). */
127     void slotMoveTop();
128     /** @brief Centers the rect vertically. */
129     void slotCenterV();
130     /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
131     void slotMoveBottom();
132
133 signals:
134     void parameterChanged();
135     void checkMonitorPosition(int);
136     void seekToPos(int);
137 };
138
139 #endif