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