]> git.sesse.net Git - kdenlive/blob - src/effectstack/effectstackview2.h
Fix drag & drop of effects and groups in effect stack:
[kdenlive] / src / effectstack / effectstackview2.h
1 /***************************************************************************
2                           effecstackview2.h  -  description
3                              -------------------
4     begin                : Feb 15 2008
5     copyright            : (C) 2008 by Marco Gittler (g.marco@freenet.de)
6     copyright            : (C) 2012 by Jean-Baptiste Mardelle (jb@kdenlive.org) 
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 /**
19  * @class EffectStackView2
20  * @brief View part of the EffectStack
21  * @author Marco Gittler
22  */
23
24 #ifndef EFFECTSTACKVIEW2_H
25 #define EFFECTSTACKVIEW2_H
26
27 #include "ui_effectstack2_ui.h"
28 #include "effectstackedit.h"
29 #include "collapsibleeffect.h"
30 #include "collapsiblegroup.h"
31
32 class EffectsList;
33 class ClipItem;
34 class MltVideoProfile;
35 class Monitor;
36
37
38 class EffectStackView2 : public QWidget
39 {
40     Q_OBJECT
41
42 public:
43     EffectStackView2(Monitor *monitor, QWidget *parent = 0);
44     virtual ~EffectStackView2();
45
46     /** @brief Raises @param dock if a clip is loaded. */
47     void raiseWindow(QWidget* dock);
48
49     /** @brief return the index of the track displayed in effect stack
50      ** @param ok set to true if we are looking at a track's effects, otherwise false. */
51     int isTrackMode(bool *ok) const;
52
53     /** @brief Clears the list of effects and updates the buttons accordingly. */
54     void clear();
55
56     /** @brief Passes updates on @param profile and @param t on to the effect editor. */
57     void updateProjectFormat(MltVideoProfile profile, Timecode t);
58
59     /** @brief Tells the effect editor to update its timecode format. */
60     void updateTimecodeFormat();
61     
62     /** @brief Used to trigger drag effects. */
63     virtual bool eventFilter( QObject * o, QEvent * e );
64     
65     CollapsibleEffect *getEffectByIndex(int ix);
66     
67     /** @brief Delete currently selected effect. */
68     void deleteCurrentEffect();
69     
70     /** @brief Palette was changed, update style. */
71     void updatePalette();
72     
73     /** @brief Process dropped xml effect. */
74     void processDroppedEffect(QDomElement e, QDropEvent *event);
75
76 protected:
77     virtual void mouseMoveEvent(QMouseEvent * event);
78     virtual void mouseReleaseEvent(QMouseEvent * event);
79     virtual void resizeEvent ( QResizeEvent * event );
80     virtual void dragEnterEvent(QDragEnterEvent *event);
81     virtual void dropEvent(QDropEvent *event);
82   
83 private:
84     Ui::EffectStack2_UI m_ui;
85     ClipItem* m_clipref;
86     QList <CollapsibleEffect*> m_effects;
87     EffectsList m_currentEffectList;
88     
89     /** @brief Contains infos about effect like is it a track effect, which monitor displays it,... */
90     EffectMetaInfo m_effectMetaInfo;
91     
92     /** @brief The last mouse click position, used to detect drag events. */
93     QPoint m_clickPoint;
94
95     /** @brief The track index of currently edited track. */
96     int m_trackindex;
97
98     /** If in track mode: Info of the edited track to be able to access its duration. */
99     TrackInfo m_trackInfo;
100     
101     /** @brief The effect currently being dragged, NULL if no drag happening. */
102     CollapsibleEffect *m_draggedEffect;
103     
104     /** @brief The effect currently being dragged, NULL if no drag happening. */
105     CollapsibleGroup *m_draggedGroup;
106     
107     /** @brief The current number of groups. */
108     int m_groupIndex;
109
110     /** @brief Sets the list of effects according to the clip's effect list. */
111     void setupListView();
112     
113     /** @brief Build the drag info and start it. */
114     void startDrag();
115     
116     /** @brief Connect an effect to its signals. */
117     void connectEffect(CollapsibleEffect *currentEffect);
118     /** @brief Connect a group to its signals. */
119     void connectGroup(CollapsibleGroup *group);
120
121 public slots:
122     /** @brief Sets the clip whose effect list should be managed.
123     * @param c Clip whose effect list should be managed */
124     void slotClipItemSelected(ClipItem* c);
125
126     void slotTrackItemSelected(int ix, const TrackInfo info);
127    
128     /** @brief Check if the mouse wheel events should be used for scrolling the widget view. */
129     void slotCheckWheelEventFilter();
130
131 private slots:
132
133     /** @brief Emits seekTimeline with position = clipstart + @param pos. */
134     void slotSeekTimeline(int pos);
135
136
137     /* @brief Define the region filter for current effect.
138     void slotRegionChanged();*/
139
140     /** @brief Checks whether the monitor scene has to be displayed. */
141     void slotCheckMonitorPosition(int renderPos);
142
143     void slotUpdateEffectParams(const QDomElement old, const QDomElement e, int ix);
144
145     /** @brief Move an effect in the stack.
146      * @param index The effect index in the stack
147      * @param up true if we want to move effect up, false for down */
148     void slotMoveEffectUp(int index, bool up);
149
150     /** @brief Delete an effect in the stack. */
151     void slotDeleteEffect(const QDomElement effect);
152     
153     /** @brief Delete all effect in a group. */
154     void slotDeleteGroup(QDomDocument doc);
155
156     /** @brief Pass position changes of the timeline cursor to the effects to keep their local timelines in sync. */
157     void slotRenderPos(int pos);
158
159     /** @brief Called whenever an effect is enabled / disabled by user. */
160     void slotUpdateEffectState(bool disable, int index, bool updateMainStatus);
161
162     void slotSetCurrentEffect(int ix);
163     
164     /** @brief Triggers a filter job on this clip. */
165     void slotStartFilterJob(const QString&filterName, const QString&filterParams, const QString&finalFilterName, const QString&consumer, const QString&consumerParams, const QString&properties);
166     
167     /** @brief Reset an effect to its default values. */
168     void slotResetEffect(int ix);
169     
170     /** @brief Create a group containing effect with ix index. */
171     void slotCreateGroup(int ix);
172     
173     /** @brief Create a region effect with ix index. */
174     void slotCreateRegion(int ix, KUrl url);
175     
176     /** @brief Move an effect.
177       ** @param currentIndexes the list of effect indexes to move in stack layout
178       ** @param newIndex the position where the effects will be moved
179       ** @param groupIndex the index of the group if any (-1 if none)
180       ** @param groupName the name of the group to paste the effect
181       */
182     void slotMoveEffect(QList <int> currentIndexes, int newIndex, int groupIndex, QString groupName = QString());
183     
184     /** @brief Remove effects from a group */
185     void slotUnGroup(CollapsibleGroup* group);
186     
187     /** @brief Add en effect to selected clip */
188     void slotAddEffect(QDomElement effect);
189     
190     /** @brief Enable / disable all effects for the clip */
191     void slotCheckAll(int state);
192     
193     /** @brief Update check all button status */
194     void slotUpdateCheckAllButton();
195     
196     /** @brief Display additionnal effect info */
197     void slotShowComments();
198     
199     /** @brief An effect group was renamed, update effects info */
200     void slotRenameGroup(CollapsibleGroup *group);
201
202 signals:
203     void removeEffect(ClipItem*, int, QDomElement);
204     /**  Parameters for an effect changed, update the filter in playlist */
205     void updateEffect(ClipItem*, int, QDomElement, QDomElement, int,bool);
206     /** An effect in stack was moved, we need to regenerate
207         all effects for this clip in the playlist */
208     void refreshEffectStack(ClipItem *);
209     /** Enable or disable an effect */
210     void changeEffectState(ClipItem*, int, int, bool);
211     /** An effect in stack was moved */
212     void changeEffectPosition(ClipItem*, int, QList <int>, int);
213     /** an effect was saved, reload list */
214     void reloadEffects();
215     /** An effect with position parameter was changed, seek */
216     void seekTimeline(int);
217     /** The region effect for current effect was changed */
218     void updateClipRegion(ClipItem*, int, QString);
219     void displayMessage(const QString&, int);
220     void showComments(bool show);
221     void startFilterJob(ItemInfo info, const QString &clipId, const QString &filterName, const QString &filterParams, const QString&finalFilterName, const QString &consumer, const QString &consumerParams, const QString &properties);
222     void addEffect(ClipItem*,QDomElement);
223 };
224
225 #endif