]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.h
59cf59561758c329a023bf467c90917fe6e56327
[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 #include "abstractcollapsiblewidget.h"
25 #include "timecode.h"
26 #include "keyframeedit.h"
27
28 #include <QDomElement>
29 #include <QToolButton>
30
31 class QFrame;
32 class QLabel;
33
34 class Monitor;
35 class GeometryWidget;
36
37 struct EffectMetaInfo {
38     MltVideoProfile profile;
39     Timecode timecode;
40     Monitor *monitor;
41     QPoint frameSize;
42     bool trackMode;
43 };
44
45 enum WIPE_DIRECTON { UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3, CENTER = 4 };
46
47 struct wipeInfo {
48     WIPE_DIRECTON start;
49     WIPE_DIRECTON end;
50     int startTransparency;
51     int endTransparency;
52 };
53
54 class MySpinBox : public QSpinBox
55 {
56     Q_OBJECT
57
58 public:
59     MySpinBox(QWidget * parent = 0);
60     
61 protected:
62     virtual void focusInEvent(QFocusEvent*);
63     virtual void focusOutEvent(QFocusEvent*);
64 };
65
66 class ParameterContainer : public QObject
67 {
68     Q_OBJECT
69
70 public:
71     ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent = 0);
72     ~ParameterContainer();
73     void updateTimecodeFormat();
74     void updateProjectFormat(MltVideoProfile profile, Timecode t);
75     void updateParameter(const QString &key, const QString &value);
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
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     QLabel *title;
128         
129     void setupWidget(ItemInfo info, EffectMetaInfo *metaInfo);
130     void updateTimecodeFormat();
131     void setActive(bool activate);
132     /** @brief Install event filter so that scrolling with mouse wheel does not change parameter value. */
133     virtual bool eventFilter( QObject * o, QEvent * e );
134     /** @brief Update effect GUI to reflect parameted changes. */
135     void updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo);
136     QDomElement effect() const;
137     int groupIndex() const;
138     bool isGroup() const;
139     int effectIndex() const;
140     void setGroupIndex(int ix);
141     void setGroupName(const QString &groupName);
142     /** @brief Remove this effect from its group. */
143     void removeFromGroup();
144     QString infoString() const;
145     bool isActive() const;
146     /** @brief Should the wheel event be sent to parent widget for scrolling. */
147     bool filterWheelEvent;
148     /** @brief Return the stylesheet required for effect parameters. */
149     static const QString getStyleSheet();
150     /** @brief Parent group was collapsed, update. */
151     void groupStateChanged(bool collapsed);
152     /** @brief Show / hide up / down buttons. */
153     void adjustButtons(int ix, int max);
154
155 public slots:
156     void slotSyncEffectsPos(int pos);
157     void slotEnable(bool enable, bool updateMainStatus = true);
158     void slotResetEffect();
159
160 private slots:
161     void slotSwitch();
162     void slotShow(bool show);
163     void slotDeleteEffect();
164     void slotEffectUp();
165     void slotEffectDown();
166     void slotSaveEffect();
167     void slotCreateGroup();
168     void slotCreateRegion();
169     void slotUnGroup();
170     /** @brief A sub effect parameter was changed */
171     void slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/);
172
173 private:
174     ParameterContainer *m_paramWidget;
175     QList <CollapsibleEffect *> m_subParamWidgets;
176     QDomElement m_effect;
177     QDomElement m_original_effect;
178     QList <QDomElement> m_subEffects;
179     bool m_lastEffect;
180     int m_in;
181     int m_out;
182     QMenu *m_menu;
183     QPoint m_clickPoint;
184     EffectInfo m_info;
185     /** @brief True if this is a region effect, which behaves in a special way, like a group. */
186     bool m_regionEffect;
187     /** @brief The add group action. */
188     QAction *m_groupAction;
189     /** @brief Check if collapsed state changed and inform MLT. */
190     void updateCollapsedState();
191     
192 protected:
193     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
194     virtual void mouseReleaseEvent( QMouseEvent *event );
195     virtual void dragEnterEvent(QDragEnterEvent *event);
196     virtual void dragLeaveEvent(QDragLeaveEvent *event);
197     virtual void dropEvent(QDropEvent *event);
198     
199 signals:
200     void parameterChanged(const QDomElement, const QDomElement, int);
201     void syncEffectsPos(int);
202     void effectStateChanged(bool, int ix = -1, bool updateMainStatus = true);
203     void deleteEffect(const QDomElement);
204     void activateEffect(int);
205     void checkMonitorPosition(int);
206     void seekTimeline(int);
207     /** @brief Start an MLT filter job on this clip. */
208     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
209     /** @brief An effect was reset, trigger param reload. */
210     void resetEffect(int ix);
211     /** @brief Ask for creation of a group. */
212     void createGroup(int ix);
213     void unGroup(CollapsibleEffect *);
214     void createRegion(int, KUrl);
215     void deleteGroup(QDomDocument);
216 };
217
218
219 #endif
220