]> git.sesse.net Git - kdenlive/blob - src/cornerswidget.h
Fix monitor scene staying active when disabling a corners effect
[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 public slots:
60     /** @brief Switches from normal monitor to monitor scene according to @param show. */
61     void slotShowScene(bool show = true);
62
63 private:
64     Ui::CornersWidget_UI m_ui;
65     Monitor *m_monitor;
66     /** Position of the clip in timeline. */
67     int m_clipPos;
68     /** In point of the clip (crop from start). */
69     int m_inPoint;
70     /** Out point of the clip (crop from end). */
71     int m_outPoint;
72     bool m_isEffect;
73     MonitorScene *m_scene;
74     OnMonitorCornersItem *m_item;
75     bool m_showScene;
76     MonitorSceneControlWidget *m_config;
77     int m_factor;
78
79 private slots:
80     /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible.
81     * @param renderPos Postion of the Monitor / Timeline cursor */
82     void slotCheckMonitorPosition(int renderPos);
83
84     /** @brief Updates the on-monitor item according to the spinboxes. */
85     void slotUpdateItem();
86     /** @brief Updates the spinboxes according to the on-monitor item.
87      * @param changed (default = true) Whether to emit parameterChanged */
88     void slotUpdateProperties(bool changed = true);
89
90     /** @brief Shows/Hides the lines connecting the corners in the on-monitor item according to @param show. */
91     void slotShowLines(bool show = true);
92
93     void slotShowControls(bool show = true);
94
95     /*
96      * These functions reset the positions of the corners.
97      * The default values in the effect XML file are not considered, but
98      * the position the corner would have without this effect applied. 
99      */
100     void slotResetCorner1();
101     void slotResetCorner2();
102     void slotResetCorner3();
103     void slotResetCorner4();
104
105 signals:
106     void parameterChanged();
107     void checkMonitorPosition(int);
108 };
109
110 #endif