]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.h
Fix crash when dropping effect on a group
[kdenlive] / src / effectstack / collapsibleeffect.h
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
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 COLLAPSIBLEEFFECT_H
22 #define COLLAPSIBLEEFFECT_H
23
24
25 #include "ui_collapsiblewidget_ui.h"
26
27 #include "abstractcollapsiblewidget.h"
28 #include "timecode.h"
29 #include "keyframeedit.h"
30
31 #include <QDomElement>
32 #include <QToolButton>
33
34 class QFrame;
35 class Monitor;
36 class GeometryWidget;
37
38 struct EffectMetaInfo {
39     MltVideoProfile profile;
40     Timecode timecode;
41     Monitor *monitor;
42     QPoint frameSize;
43     bool trackMode;
44 };
45
46 enum WIPE_DIRECTON { UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3, CENTER = 4 };
47
48 struct wipeInfo {
49     WIPE_DIRECTON start;
50     WIPE_DIRECTON end;
51     int startTransparency;
52     int endTransparency;
53 };
54
55 class MySpinBox : public QSpinBox
56 {
57     Q_OBJECT
58
59 public:
60     MySpinBox(QWidget * parent = 0);
61     
62 protected:
63     virtual void focusInEvent(QFocusEvent*);
64     virtual void focusOutEvent(QFocusEvent*);
65 };
66
67 class ParameterContainer : public QObject
68 {
69     Q_OBJECT
70
71 public:
72     ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent = 0);
73     ~ParameterContainer();
74     void updateTimecodeFormat();
75     void updateProjectFormat(MltVideoProfile profile, Timecode t);
76
77 private slots:
78     void slotCollectAllParameters();
79     void slotStartFilterJobAction();
80
81 private:
82         /** @brief Updates parameter @param name according to new value of dependency.
83     * @param name Name of the parameter which will be updated
84     * @param type Type of the parameter which will be updated
85     * @param value Value of the dependency parameter */
86     void meetDependency(const QString& name, QString type, QString value);
87     wipeInfo getWipeInfo(QString value);
88     QString getWipeString(wipeInfo info);
89     
90     int m_in;
91     int m_out;
92     QList<QWidget*> m_uiItems;
93     QMap<QString, QWidget*> m_valueItems;
94     Timecode m_timecode;
95     KeyframeEdit *m_keyframeEditor;
96     GeometryWidget *m_geometryWidget;
97     EffectMetaInfo *m_metaInfo;
98     QDomElement m_effect;
99     QVBoxLayout *m_vbox;
100
101 signals:
102     void parameterChanged(const QDomElement, const QDomElement, int);
103     void syncEffectsPos(int);
104     void effectStateChanged(bool);
105     void checkMonitorPosition(int);
106     void seekTimeline(int);
107     void showComments(bool);    
108     /** @brief Start an MLT filter job on this clip. */
109     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
110     
111 };
112
113 /**)
114  * @class CollapsibleEffect
115  * @brief A dialog for editing markers and guides.
116  * @author Jean-Baptiste Mardelle
117  */
118
119 class CollapsibleEffect : public AbstractCollapsibleWidget, public Ui::CollapsibleWidget_UI
120 {
121     Q_OBJECT
122
123 public:
124     CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent = 0);
125     ~CollapsibleEffect();
126     static QMap<QString, QImage> iconCache;
127     void setupWidget(ItemInfo info, EffectMetaInfo *metaInfo);
128     void updateTimecodeFormat();
129     void setActive(bool activate);
130     virtual bool eventFilter( QObject * o, QEvent * e );
131     /** @brief Update effect GUI to reflect parameted changes. */
132     void updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo);
133     QDomElement effect() const;
134     int groupIndex() const;
135     bool isGroup() const;
136     int effectIndex() const;
137     void setGroupIndex(int ix);
138     void setGroupName(const QString &groupName);
139     /** @brief Remove this effect from its group. */
140     void removeFromGroup();
141     QString infoString() const;
142     bool isActive() const;
143     /** @brief Should the wheel event be sent to parent widget for scrolling. */
144     bool filterWheelEvent;
145     
146     /** @brief Return the stylesheet required for effect parameters. */
147     static const QString getStyleSheet(QPalette p);
148
149 public slots:
150     void slotSyncEffectsPos(int pos);
151     void slotEnable(bool enable);
152     void slotResetEffect();
153
154 private slots:
155     void slotSwitch();
156     void slotShow(bool show);
157     void slotDeleteEffect();
158     void slotEffectUp();
159     void slotEffectDown();
160     void slotSaveEffect();
161     void slotCreateGroup();
162     void slotUnGroup();
163
164 private:
165     ParameterContainer *m_paramWidget;
166     QList <CollapsibleEffect *> m_subParamWidgets;
167     QDomElement m_effect;
168     QDomElement m_original_effect;
169     QList <QDomElement> m_subEffects;
170     bool m_lastEffect;
171     int m_in;
172     int m_out;
173     QMenu *m_menu;
174     QPoint m_clickPoint;
175     EffectInfo m_info;
176     
177 protected:
178     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
179     virtual void mousePressEvent ( QMouseEvent * event );
180     virtual void dragEnterEvent(QDragEnterEvent *event);
181     virtual void dragLeaveEvent(QDragLeaveEvent *event);
182     virtual void dropEvent(QDropEvent *event);
183     
184 signals:
185     void parameterChanged(const QDomElement, const QDomElement, int);
186     void syncEffectsPos(int);
187     void effectStateChanged(bool, int ix = -1);
188     void deleteEffect(const QDomElement);
189     void changeEffectPosition(int, bool);
190     void activateEffect(int);
191     void checkMonitorPosition(int);
192     void seekTimeline(int);
193     /** @brief Start an MLT filter job on this clip. */
194     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
195     /** @brief An effect was saved, trigger effect list reload. */
196     void reloadEffects();
197     /** @brief An effect was reset, trigger param reload. */
198     void resetEffect(int ix);
199     /** @brief Ask for creation of a group. */
200     void createGroup(int ix);
201     void moveEffect(int current_pos, int new_pos, int groupIndex, QString groupName);
202     void unGroup(CollapsibleEffect *);
203     void addEffect(QDomElement e);
204 };
205
206
207 #endif
208