]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.h
Use new parametercontainer widget for transitions
[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 "timecode.h"
28 #include "keyframeedit.h"
29
30 #include <QDomElement>
31 #include <QToolButton>
32
33 class QFrame;
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, int index, QWidget * parent = 0);
72     ~ParameterContainer();
73     void updateTimecodeFormat();
74     void updateProjectFormat(MltVideoProfile profile, Timecode t);
75     int index() const;
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     int m_index;
93     QList<QWidget*> m_uiItems;
94     QMap<QString, QWidget*> m_valueItems;
95     Timecode m_timecode;
96     KeyframeEdit *m_keyframeEditor;
97     GeometryWidget *m_geometryWidget;
98     EffectMetaInfo *m_metaInfo;
99     QDomElement m_effect;
100     QVBoxLayout *m_vbox;
101
102 signals:
103     void parameterChanged(const QDomElement, const QDomElement, int);
104     void syncEffectsPos(int);
105     void effectStateChanged(bool);
106     void checkMonitorPosition(int);
107     void seekTimeline(int);
108     void showComments(bool);    
109     /** @brief Start an MLT filter job on this clip. */
110     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
111     
112 };
113
114 /**)
115  * @class CollapsibleEffect
116  * @brief A dialog for editing markers and guides.
117  * @author Jean-Baptiste Mardelle
118  */
119
120 class CollapsibleEffect : public QWidget, public Ui::CollapsibleWidget_UI
121 {
122     Q_OBJECT
123
124 public:
125     CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, int ix, EffectMetaInfo *metaInfo, bool lastEffect, bool isGroup = false, QWidget * parent = 0);
126     ~CollapsibleEffect();
127     static QMap<QString, QImage> iconCache;
128     void setupWidget(ItemInfo info, int index, EffectMetaInfo *metaInfo);
129     void updateTimecodeFormat();
130     void setActive(bool activate, bool focused = false);
131     virtual bool eventFilter( QObject * o, QEvent * e );
132     /** @brief Update effect GUI to reflect parameted changes. */
133     void updateWidget(ItemInfo info, int index, QDomElement effect, EffectMetaInfo *metaInfo);
134     QDomElement effect() const;
135     void addGroupEffect(CollapsibleEffect *effect);
136     int index() const;
137     int groupIndex() const;
138     bool isGroup() const;
139     int effectIndex() const;
140     void setGroupIndex(int ix);
141     void removeGroup(int ix, QVBoxLayout *layout);
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 public slots:
148     void slotSyncEffectsPos(int pos);
149     void slotEnable(bool enable);
150
151 private slots:
152     void slotSwitch();
153     void slotShow(bool show);
154     void slotDeleteEffect();
155     void slotEffectUp();
156     void slotEffectDown();
157     void slotSaveEffect();
158     void slotResetEffect();
159     void slotCreateGroup();
160     void slotUnGroup();
161
162 private:
163     ParameterContainer *m_paramWidget;
164     QList <CollapsibleEffect *> m_subParamWidgets;
165     QDomElement m_effect;
166     QDomElement m_original_effect;
167     QList <QDomElement> m_subEffects;
168     bool m_lastEffect;    
169     int m_in;
170     int m_out;
171     bool m_isGroup;
172     bool m_active;
173     QMenu *m_menu;
174     QPoint m_clickPoint;
175     int m_index;
176     EffectInfo m_info;
177     
178     void updateGroupIndex(int groupIndex);
179     
180 protected:
181     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
182     virtual void mousePressEvent ( QMouseEvent * event );
183     virtual void enterEvent( QEvent * event );
184     virtual void leaveEvent( QEvent * event );
185     virtual void dragEnterEvent(QDragEnterEvent *event);
186     virtual void dragLeaveEvent(QDragLeaveEvent *event);
187     virtual void dropEvent(QDropEvent *event);
188     
189 signals:
190     void parameterChanged(const QDomElement, const QDomElement, int);
191     void syncEffectsPos(int);
192     void effectStateChanged(bool, int ix = -1);
193     void deleteEffect(const QDomElement);
194     void changeEffectPosition(int, bool);
195     void activateEffect(int);
196     void checkMonitorPosition(int);
197     void seekTimeline(int);
198     /** @brief Start an MLT filter job on this clip. */
199     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
200     /** @brief An effect was saved, trigger effect list reload. */
201     void reloadEffects();
202     /** @brief An effect was reset, trigger param reload. */
203     void resetEffect(int ix);
204     /** @brief Ask for creation of a group. */
205     void createGroup(int ix);
206     void moveEffect(int current_pos, int new_pos, CollapsibleEffect *target);
207     void unGroup(CollapsibleEffect *);
208     void addEffect(QDomElement e);
209 };
210
211
212 #endif
213