1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
21 #ifndef COLLAPSIBLEEFFECT_H
22 #define COLLAPSIBLEEFFECT_H
25 #include "ui_collapsiblewidget_ui.h"
27 #include "abstractcollapsiblewidget.h"
29 #include "keyframeedit.h"
31 #include <QDomElement>
32 #include <QToolButton>
38 struct EffectMetaInfo {
39 MltVideoProfile profile;
46 enum WIPE_DIRECTON { UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3, CENTER = 4 };
51 int startTransparency;
55 class MySpinBox : public QSpinBox
60 MySpinBox(QWidget * parent = 0);
63 virtual void focusInEvent(QFocusEvent*);
64 virtual void focusOutEvent(QFocusEvent*);
67 class ParameterContainer : public QObject
72 ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent = 0);
73 ~ParameterContainer();
74 void updateTimecodeFormat();
75 void updateProjectFormat(MltVideoProfile profile, Timecode t);
76 void updateParameter(const QString &key, const QString &value);
79 void slotCollectAllParameters();
80 void slotStartFilterJobAction();
83 /** @brief Updates parameter @param name according to new value of dependency.
84 * @param name Name of the parameter which will be updated
85 * @param type Type of the parameter which will be updated
86 * @param value Value of the dependency parameter */
87 void meetDependency(const QString& name, QString type, QString value);
88 wipeInfo getWipeInfo(QString value);
89 QString getWipeString(wipeInfo info);
93 QList<QWidget*> m_uiItems;
94 QMap<QString, QWidget*> m_valueItems;
96 KeyframeEdit *m_keyframeEditor;
97 GeometryWidget *m_geometryWidget;
98 EffectMetaInfo *m_metaInfo;
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);
115 * @class CollapsibleEffect
116 * @brief A dialog for editing markers and guides.
117 * @author Jean-Baptiste Mardelle
120 class CollapsibleEffect : public AbstractCollapsibleWidget, public Ui::CollapsibleWidget_UI
125 CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent = 0);
126 ~CollapsibleEffect();
127 static QMap<QString, QImage> iconCache;
128 void setupWidget(ItemInfo info, EffectMetaInfo *metaInfo);
129 void updateTimecodeFormat();
130 void setActive(bool activate);
131 /** @brief Install event filter so that scrolling with mouse wheel does not change parameter value. */
132 virtual bool eventFilter( QObject * o, QEvent * e );
133 /** @brief Update effect GUI to reflect parameted changes. */
134 void updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo);
135 QDomElement effect() const;
136 int groupIndex() const;
137 bool isGroup() const;
138 int effectIndex() const;
139 void setGroupIndex(int ix);
140 void setGroupName(const QString &groupName);
141 /** @brief Remove this effect from its group. */
142 void removeFromGroup();
143 QString infoString() const;
144 bool isActive() const;
145 /** @brief Should the wheel event be sent to parent widget for scrolling. */
146 bool filterWheelEvent;
147 /** @brief Return the stylesheet required for effect parameters. */
148 static const QString getStyleSheet();
149 /** @brief Parent group was collapsed, update. */
150 void groupStateChanged(bool collapsed);
153 void slotSyncEffectsPos(int pos);
154 void slotEnable(bool enable, bool updateMainStatus = true);
155 void slotResetEffect();
159 void slotShow(bool show);
160 void slotDeleteEffect();
162 void slotEffectDown();
163 void slotSaveEffect();
164 void slotCreateGroup();
165 void slotCreateRegion();
167 /** @brief A sub effect parameter was changed */
168 void slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/);
171 ParameterContainer *m_paramWidget;
172 QList <CollapsibleEffect *> m_subParamWidgets;
173 QDomElement m_effect;
174 QDomElement m_original_effect;
175 QList <QDomElement> m_subEffects;
182 /** @brief True if this is a region effect, which behaves in a special way, like a group. */
184 /** @brief Check if collapsed state changed and inform MLT. */
185 void updateCollapsedState();
188 virtual void mouseDoubleClickEvent ( QMouseEvent * event );
189 virtual void mouseReleaseEvent( QMouseEvent *event );
190 virtual void dragEnterEvent(QDragEnterEvent *event);
191 virtual void dragLeaveEvent(QDragLeaveEvent *event);
192 virtual void dropEvent(QDropEvent *event);
195 void parameterChanged(const QDomElement, const QDomElement, int);
196 void syncEffectsPos(int);
197 void effectStateChanged(bool, int ix = -1, bool updateMainStatus = true);
198 void deleteEffect(const QDomElement);
199 void changeEffectPosition(int, bool);
200 void activateEffect(int);
201 void checkMonitorPosition(int);
202 void seekTimeline(int);
203 /** @brief Start an MLT filter job on this clip. */
204 void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
205 /** @brief An effect was saved, trigger effect list reload. */
206 void reloadEffects();
207 /** @brief An effect was reset, trigger param reload. */
208 void resetEffect(int ix);
209 /** @brief Ask for creation of a group. */
210 void createGroup(int ix);
211 void moveEffect(QList <int> current_pos, int new_pos, int groupIndex, QString groupName);
212 void unGroup(CollapsibleEffect *);
213 void addEffect(QDomElement e);
214 void createRegion(int, KUrl);
215 void deleteGroup(QDomDocument);