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#include "parametercontainer.h"
25#include "abstractcollapsiblewidget.h"
26#include "timecode.h"
27
28
29#include <QDomElement>
30#include <QToolButton>
31
32class QLabel;
33
34
35/**)
36 * @class CollapsibleEffect
37 * @brief A dialog for editing markers and guides.
38 * @author Jean-Baptiste Mardelle
39 */
40
41class CollapsibleEffect : public AbstractCollapsibleWidget
42{
43 Q_OBJECT
44
45public:
46 explicit CollapsibleEffect(const QDomElement &effect, const QDomElement &original_effect, const ItemInfo &info, EffectMetaInfo *metaInfo, bool lastEffect, QWidget * parent = 0);
47 ~CollapsibleEffect();
48 QLabel *title;
49
50 void setupWidget(const ItemInfo &info, EffectMetaInfo *metaInfo);
51 void updateTimecodeFormat();
52 void setActive(bool activate);
53 /** @brief Install event filter so that scrolling with mouse wheel does not change parameter value. */
54 virtual bool eventFilter( QObject * o, QEvent * e );
55 /** @brief Update effect GUI to reflect parameted changes. */
56 void updateWidget(const ItemInfo &info, const QDomElement &effect, EffectMetaInfo *metaInfo);
57 QDomElement effect() const;
58 int groupIndex() const;
59 bool isGroup() const;
60 int effectIndex() const;
61 void setGroupIndex(int ix);
62 void setGroupName(const QString &groupName);
63 /** @brief Remove this effect from its group. */
64 void removeFromGroup();
65 QString infoString() const;
66 bool isActive() const;
67 /** @brief Should the wheel event be sent to parent widget for scrolling. */
68 bool filterWheelEvent;
69 /** @brief Parent group was collapsed, update. */
70 void groupStateChanged(bool collapsed);
71 /** @brief Show / hide up / down buttons. */
72 void adjustButtons(int ix, int max);
73 /** @brief Returns true of this effect requires an on monitor adjustable effect scene. */
74 bool needsMonitorEffectScene() const;
75 /** @brief Set clip in / out points. */
76 void setRange(int inPoint , int outPoint);
77 /** @brief Import keyframes from a clip's data. */
78 void setKeyframes(const QString &data, int maximum);
79
80public slots:
81 void slotSyncEffectsPos(int pos);
82 void slotDisable(bool disable, bool emitInfo = true);
83 void slotResetEffect();
84
85private slots:
86 void slotSwitch();
87 void slotShow(bool show);
88 void slotDeleteEffect();
89 void slotEffectUp();
90 void slotEffectDown();
91 void slotSaveEffect();
92 void slotCreateGroup();
93 void slotCreateRegion();
94 void slotUnGroup();
95 /** @brief A sub effect parameter was changed */
96 void slotUpdateRegionEffectParams(const QDomElement /*old*/, const QDomElement /*e*/, int /*ix*/);
97 /** @brief Dis/enable effect before processing an operation (color picker) */
98 void slotDisableEffect(bool disable);
99
100private:
101 ParameterContainer *m_paramWidget;
102 QList <CollapsibleEffect *> m_subParamWidgets;
103 QDomElement m_effect;
104 QDomElement m_original_effect;
105 QList <QDomElement> m_subEffects;
106 bool m_lastEffect;
107 QMenu *m_menu;
108 QPoint m_clickPoint;
109 EffectInfo m_info;
110 /** @brief True if this is a region effect, which behaves in a special way, like a group. */
111 bool m_regionEffect;
112 /** @brief The add group action. */
113 QAction *m_groupAction;
114 /** @brief Check if collapsed state changed and inform MLT. */
115 void updateCollapsedState();
116
117protected:
118 virtual void mouseDoubleClickEvent ( QMouseEvent * event );
119 virtual void mouseReleaseEvent( QMouseEvent *event );
120 virtual void dragEnterEvent(QDragEnterEvent *event);
121 virtual void dragLeaveEvent(QDragLeaveEvent *event);
122 virtual void dropEvent(QDropEvent *event);
123
124signals:
125 void parameterChanged(const QDomElement &, const QDomElement&, int);
126 void syncEffectsPos(int);
127 void effectStateChanged(bool, int ix, bool effectNeedsMonitorScene);
128 void deleteEffect(const QDomElement &);
129 void activateEffect(int);
130 void checkMonitorPosition(int);
131 void seekTimeline(int);
132 /** @brief Start an MLT filter job on this clip. */
133 void startFilterJob(const QString &filterName, const QString &filterParams, const QString &consumer, const QString &consumerParams, const QMap <QString, QString> &extraParams);
134 /** @brief An effect was reset, trigger param reload. */
135 void resetEffect(int ix);
136 /** @brief Ask for creation of a group. */
137 void createGroup(int ix);
138 void unGroup(CollapsibleEffect *);
139 void createRegion(int, const KUrl&);
140 void deleteGroup(const QDomDocument&);
141 void importClipKeyframes();
142};
143
144
145#endif
146
147