]> git.sesse.net Git - kdenlive/blob - src/definitions.h
Clip markers can now have a category that is shown as a color.
[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 #include <QDebug>
29
30 #include <QTreeWidgetItem>
31  #include <QtCore/QString>
32
33 const int MAXCLIPDURATION = 15000;
34
35 namespace Kdenlive {
36   enum MONITORID { noMonitor, clipMonitor, projectMonitor, recordMonitor, stopmotionMonitor, dvdMonitor };
37   /*const QString clipMonitor("clipMonitor");
38   const QString recordMonitor("recordMonitor");
39   const QString projectMonitor("projectMonitor");
40   const QString stopmotionMonitor("stopmotionMonitor");*/
41 }
42
43 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};
44 enum CLIPTYPE { UNKNOWN = 0, AUDIO = 1, VIDEO = 2, AV = 3, COLOR = 4, IMAGE = 5, TEXT = 6, SLIDESHOW = 7, VIRTUAL = 8, PLAYLIST = 9 };
45
46 enum PROJECTITEMTYPE { PROJECTCLIPTYPE = QTreeWidgetItem::UserType, PROJECTFOLDERTYPE, PROJECTSUBCLIPTYPE };
47
48 enum GRAPHICSRECTITEM { AVWIDGET = 70000 , LABELWIDGET , TRANSITIONWIDGET  , GROUPWIDGET};
49
50 enum PROJECTTOOL { SELECTTOOL = 0 , RAZORTOOL = 1 , SPACERTOOL = 2 };
51
52 enum TRANSITIONTYPE {
53     /** TRANSITIONTYPE: between 0-99: video trans, 100-199: video+audio trans, 200-299: audio trans */
54     LUMA_TRANSITION = 0,
55     COMPOSITE_TRANSITION = 1,
56     PIP_TRANSITION = 2,
57     LUMAFILE_TRANSITION = 3,
58     MIX_TRANSITION = 200
59 };
60
61 enum MessageType {
62     DefaultMessage,
63     OperationCompletedMessage,
64     InformationMessage,
65     ErrorMessage,
66     MltError
67 };
68
69 enum TRACKTYPE { AUDIOTRACK = 0, VIDEOTRACK = 1 };
70
71 enum CLIPJOBSTATUS { NOJOB = 0, JOBWAITING = -1, JOBWORKING = -2, JOBDONE = -3, JOBCRASHED = -4, JOBABORTED = -5};
72
73 class TrackInfo {
74 public:
75     TRACKTYPE type;
76     QString trackName;
77     bool isMute;
78     bool isBlind;
79     bool isLocked;
80     EffectsList effectsList;
81     int duration;
82     TrackInfo() :
83         type(VIDEOTRACK),
84         isMute(0),
85         isBlind(0),
86         isLocked(0),
87         duration(0) {};
88 };
89
90 typedef QMap<QString, QString> stringMap;
91 typedef QMap <int, QMap <int, QByteArray> > audioByteArray;
92
93 class ItemInfo {
94 public:
95     /** startPos is the position where the clip starts on the track */
96     GenTime startPos;
97     /** endPos is the duration where the clip ends on the track */
98     GenTime endPos;
99     /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */
100     GenTime cropStart;
101     /** cropDuration is the duration of the clip */
102     GenTime cropDuration;
103     int track;
104     ItemInfo() : track(0) {};
105 };
106
107 class TransitionInfo {
108 public:
109 /** startPos is the position where the clip starts on the track */
110     GenTime startPos;
111     /** endPos is the duration where the clip ends on the track */
112     GenTime endPos;
113     /** the track on which the transition is (b_track)*/
114     int b_track;
115     /** the track on which the transition is applied (a_track)*/
116     int a_track;
117     /** Does the user request for a special a_track */
118     bool forceTrack;
119     TransitionInfo() :
120         b_track(0),
121         a_track(0),
122         forceTrack(0) {};
123 };
124
125 class MltVideoProfile {
126 public:
127     QString path;
128     QString description;
129     int frame_rate_num;
130     int frame_rate_den;
131     int width;
132     int height;
133     bool progressive;
134     int sample_aspect_num;
135     int sample_aspect_den;
136     int display_aspect_num;
137     int display_aspect_den;
138     int colorspace;
139     MltVideoProfile() :
140         frame_rate_num(0),
141         frame_rate_den(0),
142         width(0),
143         height(0),
144         progressive(0),
145         sample_aspect_num(0),
146         sample_aspect_den(0),
147         display_aspect_num(0),
148         display_aspect_den(0),
149         colorspace(0) {};
150     bool operator==(const MltVideoProfile& point) const
151     {
152         if (!description.isEmpty() && point.description  == description) return true;
153         return      point.frame_rate_num == frame_rate_num &&
154                     point.frame_rate_den  == frame_rate_den  &&
155                     point.width == width &&
156                     point.height == height &&
157                     point.progressive == progressive &&
158                     point.sample_aspect_num == sample_aspect_num &&
159                     point.sample_aspect_den == sample_aspect_den &&
160                     point.display_aspect_den == display_aspect_den &&
161                     point.colorspace == colorspace;
162     }
163     bool operator!=(const MltVideoProfile &other) const {
164         return !(*this == other);
165     }
166 };
167
168 /**)
169  * @class EffectInfo
170  * @brief A class holding some meta info for effects widgets, like state (collapsed or not, ...)
171  * @author Jean-Baptiste Mardelle
172  */
173
174 class EffectInfo
175 {
176 public:
177     EffectInfo() {isCollapsed = false; groupIndex = -1; groupIsCollapsed = false;}
178     bool isCollapsed;
179     bool groupIsCollapsed;
180     int groupIndex;
181     QString groupName;
182     QString toString() const {
183         QStringList data;
184         // effect collapsed state: 0 = effect not collapsed, 1 = effect collapsed, 
185         // 2 = group collapsed - effect not, 3 = group and effect collapsed
186         int collapsedState = (int) isCollapsed;
187         if (groupIsCollapsed) collapsedState += 2;
188         data << QString::number(collapsedState) << QString::number(groupIndex) << groupName;
189         return data.join("/");
190     }
191     void fromString(QString value) {
192         if (value.isEmpty()) return;
193         QStringList data = value.split("/");
194         isCollapsed = data.at(0).toInt() == 1 || data.at(0).toInt() == 3;
195         groupIsCollapsed = data.at(0).toInt() >= 2;
196         if (data.count() > 1) groupIndex = data.at(1).toInt();
197         if (data.count() > 2) groupName = data.at(2);
198     }
199 };
200
201 class EffectParameter
202 {
203 public:
204     EffectParameter(const QString &name, const QString &value): m_name(name), m_value(value) {}
205     QString name()   const          {
206         return m_name;
207     }
208     QString value() const          {
209         return m_value;
210     }
211     void setValue(const QString &value) {
212         m_value = value;
213     }
214
215 private:
216     QString m_name;
217     QString m_value;
218 };
219
220 /** Use our own list for effect parameters so that they are not sorted in any ways, because
221     some effects like sox need a precise order
222 */
223 class EffectsParameterList: public QList < EffectParameter >
224 {
225 public:
226     EffectsParameterList(): QList < EffectParameter >() {}
227     bool hasParam(const QString &name) const {
228         for (int i = 0; i < size(); i++)
229             if (at(i).name() == name) return true;
230         return false;
231     }
232     void setParamValue(const QString &name, const QString &value) {
233         bool found = false;
234         for (int i = 0; i < size(); i++)
235             if (at(i).name() == name) {
236                 // update value
237                 replace(i, EffectParameter(name, value));
238                 found = true;
239             }
240         if (!found) addParam(name, value);
241     }
242         
243     QString paramValue(const QString &name, QString defaultValue = QString()) const {
244         for (int i = 0; i < size(); i++) {
245             if (at(i).name() == name) return at(i).value();
246         }
247         return defaultValue;
248     }
249     void addParam(const QString &name, const QString &value) {
250         if (name.isEmpty()) return;
251         append(EffectParameter(name, value));
252     }
253     void removeParam(const QString &name) {
254         for (int i = 0; i < size(); i++)
255             if (at(i).name() == name) {
256                 removeAt(i);
257                 break;
258             }
259     }
260 };
261
262 class CommentedTime
263 {
264 public:
265     CommentedTime(): t(GenTime(0)), type(0) {}
266     CommentedTime(const GenTime &time, QString comment, int markerType = 0)
267         : t(time), c(comment), type(markerType) { }
268
269     QString comment()   const          {
270         return (c.isEmpty() ? i18n("Marker") : c);
271     }
272     GenTime time() const          {
273         return t;
274     }
275     void    setComment(QString comm) {
276         c = comm;
277     }
278     void setMarkerType(int t) {
279         type = t;
280     }
281     int markerType() const {
282         return type;
283     }
284     static QColor markerColor(int type) {
285         switch (type) {
286           case 0:
287               return Qt::red;
288               break;
289           case 1:
290               return Qt::blue;
291               break;
292           case 2:
293               return Qt::green;
294               break;
295           case 3:
296               return Qt::yellow;
297               break;
298           default:
299               return Qt::cyan;
300               break;
301         }
302     };
303
304     /* Implementation of > operator; Works identically as with basic types. */
305     bool operator>(CommentedTime op) const {
306         return t > op.time();
307     }
308     /* Implementation of < operator; Works identically as with basic types. */
309     bool operator<(CommentedTime op) const {
310         return t < op.time();
311     }
312     /* Implementation of >= operator; Works identically as with basic types. */
313     bool operator>=(CommentedTime op) const {
314         return t >= op.time();
315     }
316     /* Implementation of <= operator; Works identically as with basic types. */
317     bool operator<=(CommentedTime op) const {
318         return t <= op.time();
319     }
320     /* Implementation of == operator; Works identically as with basic types. */
321     bool operator==(CommentedTime op) const {
322         return t == op.time();
323     }
324     /* Implementation of != operator; Works identically as with basic types. */
325     bool operator!=(CommentedTime op) const {
326         return t != op.time();
327     }
328
329 private:
330     GenTime t;
331     QString c;
332     int type;
333
334
335
336 };
337
338 QDebug operator << (QDebug qd, const ItemInfo &info);
339
340
341 #endif