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