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
24 #include "abstractcollapsiblewidget.h"
26 #include "keyframeedit.h"
28 #include <QDomElement>
29 #include <QToolButton>
37 struct EffectMetaInfo {
38 MltVideoProfile profile;
45 enum WIPE_DIRECTON { UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3, CENTER = 4 };
50 int startTransparency;
54 class MySpinBox : public QSpinBox
59 MySpinBox(QWidget * parent = 0);
62 virtual void focusInEvent(QFocusEvent*);
63 virtual void focusOutEvent(QFocusEvent*);
66 class ParameterContainer : public QObject
71 ParameterContainer(QDomElement effect, ItemInfo info, EffectMetaInfo *metaInfo, QWidget * parent = 0);
72 ~ParameterContainer();
73 void updateTimecodeFormat();
74 void updateProjectFormat(MltVideoProfile profile, Timecode t);
75 void updateParameter(const QString &key, const QString &value);
78 void slotCollectAllParameters();
79 void slotStartFilterJobAction();
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);
92 QList<QWidget*> m_uiItems;
93 QMap<QString, QWidget*> m_valueItems;
95 KeyframeEdit *m_keyframeEditor;
96 GeometryWidget *m_geometryWidget;
97 EffectMetaInfo *m_metaInfo;
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);
114 * @class CollapsibleEffect
115 * @brief A dialog for editing markers and guides.
116 * @author Jean-Baptiste Mardelle
119 class CollapsibleEffect : public AbstractCollapsibleWidget
124 CollapsibleEffect(QDomElement effect, QDomElement original_effect, ItemInfo info, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent = 0);
125 ~CollapsibleEffect();
126 static QMap<QString, QImage> iconCache;
129 void setupWidget(ItemInfo info, EffectMetaInfo *metaInfo);
130 void updateTimecodeFormat();
131 void setActive(bool activate);
132 /** @brief Install event filter so that scrolling with mouse wheel does not change parameter value. */
133 virtual bool eventFilter( QObject * o, QEvent * e );
134 /** @brief Update effect GUI to reflect parameted changes. */
135 void updateWidget(ItemInfo info, QDomElement effect, EffectMetaInfo *metaInfo);
136 QDomElement effect() const;
137 int groupIndex() const;
138 bool isGroup() const;
139 int effectIndex() const;
140 void setGroupIndex(int ix);
141 void setGroupName(const QString &groupName);
142 /** @brief Remove this effect from its group. */
143 void removeFromGroup();
144 QString infoString() const;
145 bool isActive() const;
146 /** @brief Should the wheel event be sent to parent widget for scrolling. */
147 bool filterWheelEvent;
148 /** @brief Return the stylesheet required for effect parameters. */
149 static const QString getStyleSheet();
150 /** @brief Parent group was collapsed, update. */
151 void groupStateChanged(bool collapsed);
154 void slotSyncEffectsPos(int pos);
155 void slotEnable(bool enable, bool updateMainStatus = true);
156 void slotResetEffect();
160 void slotShow(bool show);
161 void slotDeleteEffect();
163 void slotEffectDown();
164 void slotSaveEffect();
165 void slotCreateGroup();
166 void slotCreateRegion();
168 /** @brief A sub effect parameter was changed */
169 void slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/);
172 ParameterContainer *m_paramWidget;
173 QList <CollapsibleEffect *> m_subParamWidgets;
174 QDomElement m_effect;
175 QDomElement m_original_effect;
176 QList <QDomElement> m_subEffects;
183 /** @brief True if this is a region effect, which behaves in a special way, like a group. */
185 /** @brief Check if collapsed state changed and inform MLT. */
186 void updateCollapsedState();
189 virtual void mouseDoubleClickEvent ( QMouseEvent * event );
190 virtual void mouseReleaseEvent( QMouseEvent *event );
191 virtual void dragEnterEvent(QDragEnterEvent *event);
192 virtual void dragLeaveEvent(QDragLeaveEvent *event);
193 virtual void dropEvent(QDropEvent *event);
196 void parameterChanged(const QDomElement, const QDomElement, int);
197 void syncEffectsPos(int);
198 void effectStateChanged(bool, int ix = -1, bool updateMainStatus = true);
199 void deleteEffect(const QDomElement);
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 reset, trigger param reload. */
206 void resetEffect(int ix);
207 /** @brief Ask for creation of a group. */
208 void createGroup(int ix);
209 void unGroup(CollapsibleEffect *);
210 void createRegion(int, KUrl);
211 void deleteGroup(QDomDocument);