]> git.sesse.net Git - kdenlive/blob - src/trackpanelclipmovefunction.h
8d40e2233c95b74ea71a531b1b3f002fb795dcb9
[kdenlive] / src / trackpanelclipmovefunction.h
1 /***************************************************************************
2                           TrackPanelClipMoveFunction.h  -  description
3                              -------------------
4     begin                : Sun May 18 2003
5     copyright            : (C) 2003 by Jason Wood
6     email                : jasonwood@blueyonder.co.uk
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 #ifndef TRACKPANELCLIPMOVEFUNCTION_H
18 #define TRACKPANELCLIPMOVEFUNCTION_H
19
20 #include "qcursor.h"
21
22 #include "trackpanelfunction.h"
23
24 class QMouseEvent;
25
26 class KdenliveDoc;
27 class DocumentTrack;
28
29 /**
30 Abstract Base Class for track panel functionality decorators. This and it's
31 derived classes allow different behaviours to be added to panels as required.
32
33 @author Jason Wood
34 */ class TrackPanelClipMoveFunction:public TrackPanelFunction
35 {
36   Q_OBJECT public:
37     TrackPanelClipMoveFunction(TrackView * view);
38
39     virtual ~ TrackPanelClipMoveFunction();
40
41         /**
42         Returns true if the specified position should cause this function to activate,
43         otherwise returns false.
44         */
45     virtual bool mouseApplies(DocumentTrack *,
46         QMouseEvent * event) const;
47
48         /**
49         Returns a relevant mouse cursor for the given mouse position
50         */
51     virtual QCursor getMouseCursor(DocumentTrack *, QMouseEvent * event);
52
53         /**
54         A mouse button has been pressed. Returns true if we want to handle this event
55         */
56     virtual bool mousePressed(DocumentTrack * panel,
57         QMouseEvent * event);
58
59         /**
60         Processes Mouse double click.*/
61     virtual bool mouseDoubleClicked(DocumentTrack * panel, QMouseEvent *);
62
63         /**
64         Mouse Release Events in the track view area. Returns true if we have finished
65         an operation now.
66         */
67     virtual bool mouseReleased(DocumentTrack *, QMouseEvent *);
68
69         /**
70         Processes Mouse Move events in the track view area. Returns true if we are
71         continuing with the drag.*/
72     virtual bool mouseMoved(DocumentTrack * panel, QMouseEvent * event);
73
74         /**
75         Process drag events
76         */
77
78     virtual bool dragEntered(DocumentTrack * panel, QDragEnterEvent *);
79     virtual bool dragMoved(DocumentTrack *, QDragMoveEvent *);
80     virtual bool dragLeft(DocumentTrack *, QDragLeaveEvent *);
81     virtual bool dragDropped(DocumentTrack * panel, QDropEvent *);
82
83   private:
84     TrackView * m_view;
85     KdenliveDoc *m_document;
86     TrackViewClip *m_clipUnderMouse;
87     bool m_dragging;
88     bool m_firststep;
89
90         /**
91         This variable should be set to true if we have initiated a drag which
92         is going to be moving, rather than adding, clips.
93
94         set to false otherwise. The purpose of this variable is to prevent the
95         selection group from being re-created on drag entry if we are only
96         moving it - this prevents a copy of the clips from being created.
97         */
98     bool m_startedClipMove;
99
100         /**
101         This list is used to group clips together when they are being dragged away from the
102         timeline, or are being dragged onto the timeline. It gives a home to clips that have not yet
103         been placed.
104         */
105     //DocClipRefList m_selection;
106     //DocClipRefList m_selection_to_add;
107
108         /**
109         This is the "master" Clip - the clip that is actively being dragged by the mouse.
110         All other clips move in relation to the master clip.
111         */
112     TrackViewClip *m_masterClip;
113
114         /**
115         When dragging a clip, this is the time offset that should be applied to where
116         the mouse cursor to find the beginning of the master clip.
117         */
118     GenTime m_clipOffset;
119
120         /** A snap to grid object used for calculating snap-to-grid calculations. */
121     //SnapToGrid m_snapToGrid;
122
123         /** Moves all selected clips to a new position. The new start position is that for the master clip,
124          all other clips are moved in relation to it. Returns true on success, false on failure.*/
125     bool moveSelectedClips(int newTrack, GenTime start);
126
127         /** Adds a Clipgroup to the tracks in the timeline. It there are some currently selected clips and
128         we add new clips with this method, the previously selected clips are dselected. */
129     //void addClipsToTracks(DocClipRefList & clips, int track, GenTime value,bool selected);
130
131         /** set up the snap-to-grid class */
132     void setupSnapToGrid();
133
134         /** Find the index of the document track underneath the specified point on the track. */
135     int trackUnderPoint(const QPoint & pos);
136
137         /** Initiates a drag operation on the selected clip, setting the master clip to clipUnderMouse,
138         and specifying the time that the mouse is currently pointing at. */
139     //void initiateDrag(DocClipRef * clipUnderMouse, GenTime mouseTime);
140
141         /**
142         True if we are currently in the process of adding clips to the timeline.
143         False otherwise.
144         */
145     bool m_addingClips;
146
147
148         /**
149         A moveClipCommand action, used to record clip movement for undo/redo functionality.
150         */
151      //Command::KMoveClipsCommand * m_moveClipsCommand;
152         /**
153         This command is used to record clip deletion for undo/redo functionality.
154         */
155     //KMacroCommand *m_deleteClipsCommand;
156
157 #warning - The following method is a bad example for programming design.
158         /** Returns a command that would create those clips in the document that are currently selected.
159         */
160     //KMacroCommand *createAddClipsCommand();
161
162         /** Returns true if the x,y position is over a clip (and therefore, the move function applies) */
163     bool mouseApplies(const QPoint & pos) const;
164
165     signals:
166         //void checkTransition(DocClipRef*);
167 };
168
169 #endif