]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.h
Some ui love for new effect stack
[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     /** @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
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 slotResetEffect();
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     bool m_isGroup;
175     bool m_active;
176     QMenu *m_menu;
177     QPoint m_clickPoint;
178     int m_index;
179     EffectInfo m_info;
180     
181     void updateGroupIndex(int groupIndex);
182     
183 protected:
184     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
185     virtual void mousePressEvent ( QMouseEvent * event );
186     virtual void enterEvent( QEvent * event );
187     virtual void leaveEvent( QEvent * event );
188     virtual void dragEnterEvent(QDragEnterEvent *event);
189     virtual void dragLeaveEvent(QDragLeaveEvent *event);
190     virtual void dropEvent(QDropEvent *event);
191     
192 signals:
193     void parameterChanged(const QDomElement, const QDomElement, int);
194     void syncEffectsPos(int);
195     void effectStateChanged(bool, int ix = -1);
196     void deleteEffect(const QDomElement);
197     void changeEffectPosition(int, bool);
198     void activateEffect(int);
199     void checkMonitorPosition(int);
200     void seekTimeline(int);
201     /** @brief Start an MLT filter job on this clip. */
202     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
203     /** @brief An effect was saved, trigger effect list reload. */
204     void reloadEffects();
205     /** @brief An effect was reset, trigger param reload. */
206     void resetEffect(int ix);
207     /** @brief Ask for creation of a group. */
208     void createGroup(int ix);
209     void moveEffect(int current_pos, int new_pos, CollapsibleEffect *target);
210     void unGroup(CollapsibleEffect *);
211     void addEffect(QDomElement e);
212 };
213
214
215 #endif
216