]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.h
38d893e76450efbdb9ec163fb69e698b0bbc973e
[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     void removeGroup(int ix, QVBoxLayout *layout);
140     QString infoString() const;
141     bool isActive() const;
142     /** @brief Should the wheel event be sent to parent widget for scrolling. */
143     bool filterWheelEvent;
144     
145     /** @brief Return the stylesheet required for effect parameters. */
146     static const QString getStyleSheet(QPalette p);
147
148 public slots:
149     void slotSyncEffectsPos(int pos);
150     void slotEnable(bool enable);
151
152 private slots:
153     void slotSwitch();
154     void slotShow(bool show);
155     void slotDeleteEffect();
156     void slotEffectUp();
157     void slotEffectDown();
158     void slotSaveEffect();
159     void slotResetEffect();
160     void slotCreateGroup();
161     void slotUnGroup();
162
163 private:
164     ParameterContainer *m_paramWidget;
165     QList <CollapsibleEffect *> m_subParamWidgets;
166     QDomElement m_effect;
167     QDomElement m_original_effect;
168     QList <QDomElement> m_subEffects;
169     bool m_lastEffect;
170     int m_in;
171     int m_out;
172     QMenu *m_menu;
173     QPoint m_clickPoint;
174     EffectInfo m_info;
175     
176     void updateGroupIndex(int groupIndex);
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