]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.h
2804cbe10bc56d0d713d86258f6612d73dcd7bb5
[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     /** @brief Install event filter so that scrolling with mouse wheel does not change parameter value. */
131     virtual bool eventFilter( QObject * o, QEvent * e );
132     /** @brief Update effect GUI to reflect parameted changes. */
133     void updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo);
134     QDomElement effect() const;
135     int groupIndex() const;
136     bool isGroup() const;
137     int effectIndex() const;
138     void setGroupIndex(int ix);
139     void setGroupName(const QString &groupName);
140     /** @brief Remove this effect from its group. */
141     void removeFromGroup();
142     QString infoString() const;
143     bool isActive() const;
144     /** @brief Should the wheel event be sent to parent widget for scrolling. */
145     bool filterWheelEvent;
146     
147     /** @brief Return the stylesheet required for effect parameters. */
148     static const QString getStyleSheet(QPalette p);
149
150 public slots:
151     void slotSyncEffectsPos(int pos);
152     void slotEnable(bool enable);
153     void slotResetEffect();
154
155 private slots:
156     void slotSwitch();
157     void slotShow(bool show);
158     void slotDeleteEffect();
159     void slotEffectUp();
160     void slotEffectDown();
161     void slotSaveEffect();
162     void slotCreateGroup();
163     void slotUnGroup();
164
165 private:
166     ParameterContainer *m_paramWidget;
167     QList <CollapsibleEffect *> m_subParamWidgets;
168     QDomElement m_effect;
169     QDomElement m_original_effect;
170     QList <QDomElement> m_subEffects;
171     bool m_lastEffect;
172     int m_in;
173     int m_out;
174     QMenu *m_menu;
175     QPoint m_clickPoint;
176     EffectInfo m_info;
177     
178 protected:
179     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
180     virtual void mousePressEvent ( QMouseEvent * event );
181     virtual void dragEnterEvent(QDragEnterEvent *event);
182     virtual void dragLeaveEvent(QDragLeaveEvent *event);
183     virtual void dropEvent(QDropEvent *event);
184     
185 signals:
186     void parameterChanged(const QDomElement, const QDomElement, int);
187     void syncEffectsPos(int);
188     void effectStateChanged(bool, int ix = -1);
189     void deleteEffect(const QDomElement);
190     void changeEffectPosition(int, bool);
191     void activateEffect(int);
192     void checkMonitorPosition(int);
193     void seekTimeline(int);
194     /** @brief Start an MLT filter job on this clip. */
195     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
196     /** @brief An effect was saved, trigger effect list reload. */
197     void reloadEffects();
198     /** @brief An effect was reset, trigger param reload. */
199     void resetEffect(int ix);
200     /** @brief Ask for creation of a group. */
201     void createGroup(int ix);
202     void moveEffect(int current_pos, int new_pos, int groupIndex, QString groupName);
203     void unGroup(CollapsibleEffect *);
204     void addEffect(QDomElement e);
205 };
206
207
208 #endif
209