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