]> git.sesse.net Git - kdenlive/blob - src/effectstack/collapsibleeffect.h
Fix enabling / disabling all effects in a clip & effect info text
[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 #include "effectstackedit.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 class MySpinBox : public QSpinBox
47 {
48     Q_OBJECT
49
50 public:
51     MySpinBox(QWidget * parent = 0);
52     
53 protected:
54     virtual void focusInEvent(QFocusEvent*);
55     virtual void focusOutEvent(QFocusEvent*);
56 };
57
58 class ParameterContainer : public QObject
59 {
60     Q_OBJECT
61
62 public:
63     ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, int index, QWidget * parent = 0);
64     ~ParameterContainer();
65     void updateTimecodeFormat();
66     void updateProjectFormat(MltVideoProfile profile, Timecode t);
67     int index() const;
68
69 private slots:
70     void slotCollectAllParameters();
71     void slotStartFilterJobAction();
72
73 private:
74         /** @brief Updates parameter @param name according to new value of dependency.
75     * @param name Name of the parameter which will be updated
76     * @param type Type of the parameter which will be updated
77     * @param value Value of the dependency parameter */
78     void meetDependency(const QString& name, QString type, QString value);
79     wipeInfo getWipeInfo(QString value);
80     QString getWipeString(wipeInfo info);
81     
82     int m_in;
83     int m_out;
84     int m_index;
85     QList<QWidget*> m_uiItems;
86     QMap<QString, QWidget*> m_valueItems;
87     Timecode m_timecode;
88     KeyframeEdit *m_keyframeEditor;
89     GeometryWidget *m_geometryWidget;
90     EffectMetaInfo *m_metaInfo;
91     QDomElement m_effect;
92     QVBoxLayout *m_vbox;
93
94 signals:
95     void parameterChanged(const QDomElement, const QDomElement, int);
96     void syncEffectsPos(int);
97     void effectStateChanged(bool);
98     void checkMonitorPosition(int);
99     void seekTimeline(int);
100     void showComments(bool);    
101     /** @brief Start an MLT filter job on this clip. */
102     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
103     
104 };
105
106 /**)
107  * @class CollapsibleEffect
108  * @brief A dialog for editing markers and guides.
109  * @author Jean-Baptiste Mardelle
110  */
111
112 class CollapsibleEffect : public QWidget, public Ui::CollapsibleWidget_UI
113 {
114     Q_OBJECT
115
116 public:
117     CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, int ix, EffectMetaInfo *metaInfo, bool lastEffect, bool isGroup = false, QWidget * parent = 0);
118     ~CollapsibleEffect();
119     static QMap<QString, QImage> iconCache;
120     void setupWidget(ItemInfo info, int index, EffectMetaInfo *metaInfo);
121     void updateTimecodeFormat();
122     void setActive(bool activate, bool focused = false);
123     virtual bool eventFilter( QObject * o, QEvent * e );
124     /** @brief Update effect GUI to reflect parameted changes. */
125     void updateWidget(ItemInfo info, int index, QDomElement effect, EffectMetaInfo *metaInfo);
126     QDomElement effect() const;
127     void addGroupEffect(CollapsibleEffect *effect);
128     int index() const;
129     int groupIndex() const;
130     bool isGroup() const;
131     int effectIndex() const;
132     void setGroupIndex(int ix);
133     void removeGroup(int ix, QVBoxLayout *layout);
134     QString infoString() const;
135     bool isActive() const;
136     /** @brief Should the wheel event be sent to parent widget for scrolling. */
137     bool filterWheelEvent;
138
139 public slots:
140     void slotSyncEffectsPos(int pos);
141     void slotEnable(bool enable);
142
143 private slots:
144     void slotSwitch();
145     void slotShow(bool show);
146     void slotDeleteEffect();
147     void slotEffectUp();
148     void slotEffectDown();
149     void slotSaveEffect();
150     void slotResetEffect();
151     void slotCreateGroup();
152     void slotUnGroup();
153
154 private:
155     ParameterContainer *m_paramWidget;
156     QList <CollapsibleEffect *> m_subParamWidgets;
157     QDomElement m_effect;
158     QDomElement m_original_effect;
159     QList <QDomElement> m_subEffects;
160     bool m_lastEffect;    
161     int m_in;
162     int m_out;
163     bool m_isGroup;
164     bool m_active;
165     QMenu *m_menu;
166     QPoint m_clickPoint;
167     int m_index;
168     EffectInfo m_info;
169     
170     void updateGroupIndex(int groupIndex);
171     
172 protected:
173     virtual void mouseDoubleClickEvent ( QMouseEvent * event );
174     virtual void mousePressEvent ( QMouseEvent * event );
175     virtual void enterEvent( QEvent * event );
176     virtual void leaveEvent( QEvent * event );
177     virtual void dragEnterEvent(QDragEnterEvent *event);
178     virtual void dragLeaveEvent(QDragLeaveEvent *event);
179     virtual void dropEvent(QDropEvent *event);
180     
181 signals:
182     void parameterChanged(const QDomElement, const QDomElement, int);
183     void syncEffectsPos(int);
184     void effectStateChanged(bool, int ix = -1);
185     void deleteEffect(const QDomElement);
186     void changeEffectPosition(int, bool);
187     void activateEffect(int);
188     void checkMonitorPosition(int);
189     void seekTimeline(int);
190     /** @brief Start an MLT filter job on this clip. */
191     void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
192     /** @brief An effect was saved, trigger effect list reload. */
193     void reloadEffects();
194     /** @brief An effect was reset, trigger param reload. */
195     void resetEffect(int ix);
196     /** @brief Ask for creation of a group. */
197     void createGroup(int ix);
198     void moveEffect(int current_pos, int new_pos, CollapsibleEffect *target);
199     void unGroup(CollapsibleEffect *);
200     void addEffect(QDomElement e);
201 };
202
203
204 #endif
205