]> git.sesse.net Git - kdenlive/blob - src/geometrywidget.h
Fix monitor scene shown at inappropriate times when used in a effect (instead of...
[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 <mlt++/Mlt.h>
26
27 #include <QWidget>
28
29 class QDomElement;
30 class QGraphicsRectItem;
31 class Monitor;
32 class MonitorScene;
33
34 class GeometryWidget : public QWidget
35 {
36     Q_OBJECT
37 public:
38     /** @brief Sets up the UI and connects it.
39     * @param monitor Project monitor
40     * @param clipPos Position of the clip in timeline
41     * @param parent (optional) Parent widget */
42     GeometryWidget(Monitor *monitor, int clipPos, bool isEffect, QWidget* parent = 0);
43     virtual ~GeometryWidget();
44     /** @brief Gets the geometry as a serialized string. */
45     QString getValue() const;
46
47 public slots:
48     /** @brief Sets up the rect and the geometry object.
49     * @param elem DomElement representing this effect parameter
50     * @param minframe In point of the clip
51     * @param maxframe Out point of the clip */
52     void setupParam(const QDomElement elem, int minframe, int maxframe);
53
54 private:
55     Ui::GeometryWidget_UI m_ui;
56     Monitor *m_monitor;
57     /** Position of the clip in timeline. */
58     int m_clipPos;
59     /** In point of the clip (crop from start). */
60     int m_inPoint;
61     /** Out point of the clip (crop from end). */
62     int m_outPoint;
63     bool m_isEffect;
64     MonitorScene *m_scene;
65     QGraphicsRectItem *m_rect;
66     Mlt::Geometry *m_geometry;
67
68 private slots:
69     /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
70     * @param renderPos Postion of the Monitor / Timeline cursor */
71     void slotCheckPosition(int renderPos);
72     /** @brief Updates the Mlt::Geometry object. */
73     void slotUpdateGeometry();
74     /** @brief Updates the spinBoxes according to the rect. */
75     void slotUpdateProperties();
76
77     /** @brief Sets the rect's x position to @param value. */
78     void slotSetX(int value);
79     /** @brief Sets the rect's y position to @param value. */
80     void slotSetY(int value);
81     /** @brief Sets the rect's width to @param value. */
82     void slotSetWidth(int value);
83     /** @brief Sets the rect's height to @param value. */
84     void slotSetHeight(int value);
85
86     /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
87     void slotResize(int value);
88
89     /** @brief Moves the rect to the left frame border (x position = 0). */
90     void slotMoveLeft();
91     /** @brief Centers the rect horizontally. */
92     void slotCenterH();
93     /** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
94     void slotMoveRight();
95     /** @brief Moves the rect to the top frame border (y position = 0). */
96     void slotMoveTop();
97     /** @brief Centers the rect vertically. */
98     void slotCenterV();
99     /** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
100     void slotMoveBottom();
101
102 signals:
103     void parameterChanged();
104     void checkMonitorPosition(int);
105 };
106
107 #endif