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);
152 /** @brief Show / hide up / down buttons. */
153 void adjustButtons(int ix, int max);
156 void slotSyncEffectsPos(int pos);
157 void slotEnable(bool enable, bool updateMainStatus = true);
158 void slotResetEffect();
162 void slotShow(bool show);
163 void slotDeleteEffect();
165 void slotEffectDown();
166 void slotSaveEffect();
167 void slotCreateGroup();
168 void slotCreateRegion();
170 /** @brief A sub effect parameter was changed */
171 void slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/);
174 ParameterContainer *m_paramWidget;
175 QList <CollapsibleEffect *> m_subParamWidgets;
176 QDomElement m_effect;
177 QDomElement m_original_effect;
178 QList <QDomElement> m_subEffects;
185 /** @brief True if this is a region effect, which behaves in a special way, like a group. */
187 /** @brief The add group action. */
188 QAction *m_groupAction;
189 /** @brief Check if collapsed state changed and inform MLT. */
190 void updateCollapsedState();
193 virtual void mouseDoubleClickEvent ( QMouseEvent * event );
194 virtual void mouseReleaseEvent( QMouseEvent *event );
195 virtual void dragEnterEvent(QDragEnterEvent *event);
196 virtual void dragLeaveEvent(QDragLeaveEvent *event);
197 virtual void dropEvent(QDropEvent *event);
200 void parameterChanged(const QDomElement, const QDomElement, int);
201 void syncEffectsPos(int);
202 void effectStateChanged(bool, int ix = -1, bool updateMainStatus = true);
203 void deleteEffect(const QDomElement);
204 void activateEffect(int);
205 void checkMonitorPosition(int);
206 void seekTimeline(int);
207 /** @brief Start an MLT filter job on this clip. */
208 void startFilterJob(QString filterName, QString filterParams, QString finalFilterName, QString consumer, QString consumerParams, QString properties);
209 /** @brief An effect was reset, trigger param reload. */
210 void resetEffect(int ix);
211 /** @brief Ask for creation of a group. */
212 void createGroup(int ix);
213 void unGroup(CollapsibleEffect *);
214 void createRegion(int, KUrl);
215 void deleteGroup(QDomDocument);