Commands.h 4.33 KB
Newer Older
1
2
3
4
5
6
/*****************************************************************************
 * Commands.h: Contains all the implementation of VLMC commands.
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
7
 *          Ludovic Fauvet <etix@l0cal.com>
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

24
25
#ifndef COMMANDS_H
#define COMMANDS_H
26
27

#include <QUndoCommand>
28
#include <QObject>
29
#include <QVector>
30
31
32
#include "UndoStack.h"
#include "MainWorkflow.h"
#include "Clip.h"
33
#include "WorkflowRenderer.h"
34
35
36
37
38

#define NEW_COMMAND(x)      class   x : public QUndoCommand

namespace Commands
{
39
    void        trigger( QUndoCommand* command );
40
41
42

    namespace   MainWorkflow
    {
43
44
        struct ClipActionInfo
        {
45
46
47
48
            Clip*                       clip;
            quint32                     trackNumber;
            qint64                      pos;
            ::MainWorkflow::TrackType   trackType;
49
50
        };

51
52
53
        NEW_COMMAND( AddClip )
        {
            public:
54
                AddClip( ::MainWorkflow* workflow, Clip* clip, unsigned int trackNumber, qint64 pos, ::MainWorkflow::TrackType trackType );
55
56
                virtual void    redo();
                virtual void    undo();
57
            private:
58
59
60
61
62
                ::MainWorkflow*             m_workflow;
                Clip*                       m_clip;
                unsigned int                m_trackNumber;
                qint64                      m_pos;
                ::MainWorkflow::TrackType   m_trackType;
63
        };
64
65
66
67
68

        NEW_COMMAND( MoveClip )
        {
            public:
                MoveClip( ::MainWorkflow* workflow, const QUuid& uuid,
69
                        unsigned int oldTrack, qint64 oldPos, unsigned int newTrack,
70
                        qint64 newPos, ::MainWorkflow::TrackType trackType );
71
72
                virtual void    redo();
                virtual void    undo();
73
74

            private:
75
76
77
78
79
80
81
82
                ::MainWorkflow*             m_workflow;
                QUuid                       m_uuid;
                unsigned int                m_oldTrack;
                unsigned int                m_newTrack;
                qint64                      m_pos;
                qint64                      m_oldPos;
                bool                        m_undoRedoAction;
                ::MainWorkflow::TrackType   m_trackType;
83
        };
84

85
        NEW_COMMAND( RemoveClips )
86
87
        {
            public:
88
                RemoveClips( WorkflowRenderer* renderer, const QVector<ClipActionInfo>& clipsInfos );
89
90
                virtual void redo();
                virtual void undo();
91
92

            private:
93
94
                WorkflowRenderer*               m_renderer;
                QVector<ClipActionInfo>         m_clips;
95
        };
96
97
98
99
100

        NEW_COMMAND( ResizeClip )
        {
            public:
                ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
101
                            qint64 newBegin, qint64 newEnd,
102
                            ::MainWorkflow::TrackType trackType );
103
104
                virtual void    redo();
                virtual void    undo();
105
106
            private:
                ::MainWorkflow*             m_mainWorkflow;
107
108
109
110
                qint64                      m_oldBegin;
                qint64                      m_oldEnd;
                qint64                      m_newBegin;
                qint64                      m_newEnd;
111
                Clip*                       m_clip;
112
                ::MainWorkflow::TrackType   m_trackType;
Hugo Beauzee-Luyssen's avatar
Hugo Beauzee-Luyssen committed
113
        };
114
115
116
    }
}

117
#endif // COMMANDS_H