]> git.sesse.net Git - kdenlive/blob - src/cornerswidget.h
Monitorscene control widget:
[kdenlive] / src / cornerswidget.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 CORNERSWIDGET_H
22 #define CORNERSWIDGET_H
23
24 #include "ui_cornerswidget_ui.h"
25
26 #include <QWidget>
27
28 class QDomElement;
29 class Monitor;
30 class MonitorScene;
31 class OnMonitorCornersItem;
32 class MonitorSceneControlWidget;
33
34
35 class CornersWidget : public QWidget
36 {
37     Q_OBJECT
38 public:
39     /** @brief Sets up the UI and connects it.
40      * @param monitor Project monitor
41      * @param clipPos Position of the clip in timeline
42      * @param isEffect true if used in an effect, false if used in a transition
43      * @param factor Factor by which the parameters differ from the range 0-1
44      * @param parent (optional) Parent widget */
45     CornersWidget(Monitor *monitor, int clipPos, bool isEffect, int factor, QWidget* parent = 0);
46     virtual ~CornersWidget();
47
48     /** @brief Returns a polygon representing the corners in the range 0 - factor. */
49     QPolygon getValue();
50
51     /** @brief Takes a polygon @param points in the range 0 - factor and converts it into range (- frame width|height) - (2*frame width|height). */
52     void setValue(const QPolygon &points);
53
54     /** @brief Takes in and outpoint of the clip to know when to show the on-monitor scene.
55      * @param minframe In point of the clip
56      * @param maxframe Out point of the clip */
57     void setRange(int minframe, int maxframe);
58
59 private:
60     Ui::CornersWidget_UI m_ui;
61     Monitor *m_monitor;
62     /** Position of the clip in timeline. */
63     int m_clipPos;
64     /** In point of the clip (crop from start). */
65     int m_inPoint;
66     /** Out point of the clip (crop from end). */
67     int m_outPoint;
68     bool m_isEffect;
69     MonitorScene *m_scene;
70     OnMonitorCornersItem *m_item;
71     bool m_showScene;
72     MonitorSceneControlWidget *m_config;
73     int m_factor;
74
75 private slots:
76     /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
77     * @param renderPos Postion of the Monitor / Timeline cursor */
78     void slotCheckMonitorPosition(int renderPos);
79
80     /** @brief Switches from normal monitor to monitor scene according to @param show. */
81     void slotShowScene(bool show = true);
82
83     /** @brief Updates the on-monitor item according to the spinboxes. */
84     void slotUpdateItem();
85     /** @brief Updates the spinboxes according to the on-monitor item.
86      * @param changed (default = true) Whether to emit parameterChanged */
87     void slotUpdateProperties(bool changed = true);
88
89     /** @brief Shows/Hides the lines connecting the corners in the on-monitor item according to @param show. */
90     void slotShowLines(bool show = true);
91
92     /*
93      * These functions reset the positions of the corners.
94      * The default values in the effect XML file are not considered, but
95      * the position the corner would have without this effect applied. 
96      */
97     void slotResetCorner1();
98     void slotResetCorner2();
99     void slotResetCorner3();
100     void slotResetCorner4();
101
102 signals:
103     void parameterChanged();
104     void checkMonitorPosition(int);
105 };
106
107 #endif