]> git.sesse.net Git - kdenlive/blob - src/definitions.h
Merging of scopes manager by Granjow (final merge)
[kdenlive] / src / definitions.h
1 /***************************************************************************
2  *   Copyright (C) 2007 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 DEFINITIONS_H
22 #define DEFINITIONS_H
23
24 #include "gentime.h"
25 #include "effectslist.h"
26
27 #include <KLocale>
28
29 #include <QTreeWidgetItem>
30  #include <QtCore/QString>
31
32 const int MAXCLIPDURATION = 15000;
33
34 namespace Kdenlive {
35   const QString clipMonitor("clipMonitor");
36   const QString recordMonitor("recordMonitor");
37   const QString projectMonitor("projectMonitor");
38   const QString stopmotionMonitor("stopmotionMonitor");
39 }
40
41 enum OPERATIONTYPE { NONE = 0, MOVE = 1, RESIZESTART = 2, RESIZEEND = 3, FADEIN = 4, FADEOUT = 5, TRANSITIONSTART = 6, TRANSITIONEND = 7, MOVEGUIDE = 8, KEYFRAME = 9, SEEK = 10, SPACER = 11, RUBBERSELECTION = 12};
42 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9 };
43
44 enum PROJECTITEMTYPE { PROJECTCLIPTYPE = QTreeWidgetItem::UserType, PROJECTFOLDERTYPE, PROJECTSUBCLIPTYPE };
45
46 enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET  , GROUPWIDGET};
47
48 enum PROJECTTOOL { SELECTTOOL = 0 , RAZORTOOL = 1 , SPACERTOOL = 2 };
49
50 enum TRANSITIONTYPE {
51     /** TRANSITIONTYPE: between 0-99: video trans, 100-199: video+audio trans, 200-299: audio trans */
52     LUMA_TRANSITION = 0,
53     COMPOSITE_TRANSITION = 1,
54     PIP_TRANSITION = 2,
55     LUMAFILE_TRANSITION = 3,
56     MIX_TRANSITION = 200
57 };
58
59 enum MessageType {
60     DefaultMessage,
61     OperationCompletedMessage,
62     InformationMessage,
63     ErrorMessage,
64     MltError
65 };
66
67 enum TRACKTYPE { AUDIOTRACK = 0, VIDEOTRACK = 1 };
68
69 enum CLIPJOBSTATUS { NOJOB = 0, JOBWAITING = -1, JOBWORKING = -2, JOBDONE = -3, JOBCRASHED = -4, JOBABORTED = -5};
70
71 struct TrackInfo {
72     TRACKTYPE type;
73     QString trackName;
74     bool isMute;
75     bool isBlind;
76     bool isLocked;
77     EffectsList effectsList;
78     int duration;
79 };
80
81 typedef QMap<QString, QString> stringMap;
82 typedef QMap <int, QMap <int, QByteArray> > audioByteArray;
83
84 struct ItemInfo {
85     /** startPos is the position where the clip starts on the track */
86     GenTime startPos;
87     /** endPos is the duration where the clip ends on the track */
88     GenTime endPos;
89     /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */
90     GenTime cropStart;
91     /** cropDuration is the duration of the clip */
92     GenTime cropDuration;
93     int track;
94 };
95
96 struct MltVideoProfile {
97     QString path;
98     QString description;
99     int frame_rate_num;
100     int frame_rate_den;
101     int width;
102     int height;
103     bool progressive;
104     int sample_aspect_num;
105     int sample_aspect_den;
106     int display_aspect_num;
107     int display_aspect_den;
108     int colorspace;
109     bool operator==(const MltVideoProfile& point) const
110     {
111         if (!description.isEmpty() && point.description  == description) return true;
112         return      point.frame_rate_num == frame_rate_num &&
113                     point.frame_rate_den  == frame_rate_den  &&
114                     point.width == width &&
115                     point.height == height &&
116                     point.progressive == progressive &&
117                     point.sample_aspect_num == sample_aspect_num &&
118                     point.sample_aspect_den == sample_aspect_den &&
119                     point.display_aspect_den == display_aspect_den &&
120                     point.colorspace == colorspace;
121     }
122     bool operator!=(const MltVideoProfile &other) const {
123         return !(*this == other);
124     }
125 };
126
127
128 class EffectParameter
129 {
130 public:
131     EffectParameter(const QString &name, const QString &value): m_name(name), m_value(value) {}
132     QString name()   const          {
133         return m_name;
134     }
135     QString value() const          {
136         return m_value;
137     }
138     void setValue(const QString &value) {
139         m_value = value;
140     }
141
142 private:
143     QString m_name;
144     QString m_value;
145 };
146
147 /** Use our own list for effect parameters so that they are not sorted in any ways, because
148     some effects like sox need a precise order
149 */
150 class EffectsParameterList: public QList < EffectParameter >
151 {
152 public:
153     EffectsParameterList(): QList < EffectParameter >() {}
154     bool hasParam(const QString &name) const {
155         for (int i = 0; i < size(); i++)
156             if (at(i).name() == name) return true;
157         return false;
158     }
159     QString paramValue(const QString &name, QString defaultValue = QString()) const {
160         for (int i = 0; i < size(); i++) {
161             if (at(i).name() == name) return at(i).value();
162         }
163         return defaultValue;
164     }
165     void addParam(const QString &name, const QString &value) {
166         if (name.isEmpty()) return;
167         append(EffectParameter(name, value));
168     }
169     void removeParam(const QString &name) {
170         for (int i = 0; i < size(); i++)
171             if (at(i).name() == name) {
172                 removeAt(i);
173                 break;
174             }
175     }
176 };
177
178 class CommentedTime
179 {
180 public:
181     CommentedTime(): t(GenTime(0)) {}
182     CommentedTime(const GenTime &time, QString comment)
183         : t(time), c(comment) { }
184
185     QString comment()   const          {
186         return (c.isEmpty() ? i18n("Marker") : c);
187     }
188     GenTime time() const          {
189         return t;
190     }
191     void    setComment(QString comm) {
192         c = comm;
193     }
194
195     /* Implementation of > operator; Works identically as with basic types. */
196     bool operator>(CommentedTime op) const {
197         return t > op.time();
198     }
199     /* Implementation of < operator; Works identically as with basic types. */
200     bool operator<(CommentedTime op) const {
201         return t < op.time();
202     }
203     /* Implementation of >= operator; Works identically as with basic types. */
204     bool operator>=(CommentedTime op) const {
205         return t >= op.time();
206     }
207     /* Implementation of <= operator; Works identically as with basic types. */
208     bool operator<=(CommentedTime op) const {
209         return t <= op.time();
210     }
211     /* Implementation of == operator; Works identically as with basic types. */
212     bool operator==(CommentedTime op) const {
213         return t == op.time();
214     }
215     /* Implementation of != operator; Works identically as with basic types. */
216     bool operator!=(CommentedTime op) const {
217         return t != op.time();
218     }
219
220 private:
221     GenTime t;
222     QString c;
223
224
225 };
226
227
228 #endif