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