Warning, file /multimedia/kdenlive/src/definitions.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2007 Jean-Baptiste Mardelle <jb@kdenlive.org> 0003 0004 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include "utils/gentime.h" 0010 0011 #include "kdenlive_debug.h" 0012 0013 #include <QDomElement> 0014 #include <QHash> 0015 #include <QPersistentModelIndex> 0016 #include <QString> 0017 #include <cassert> 0018 #include <memory> 0019 0020 const int MAXCLIPDURATION = 15000; 0021 0022 namespace Kdenlive { 0023 0024 enum MonitorId { NoMonitor = 0x01, ClipMonitor = 0x02, ProjectMonitor = 0x04, RecordMonitor = 0x08, StopMotionMonitor = 0x10, RenderMonitor = 0x20 }; 0025 0026 const int DefaultThumbHeight = 100; 0027 } // namespace Kdenlive 0028 0029 enum class GroupType { 0030 Normal, 0031 Selection, // in that case, the group is used to emulate a selection 0032 AVSplit, // in that case, the group links the audio and video of the same clip 0033 Leaf // This is a leaf (clip or composition) 0034 }; 0035 0036 const QString groupTypeToStr(GroupType t); 0037 GroupType groupTypeFromStr(const QString &s); 0038 0039 enum class ObjectType { TimelineClip, TimelineComposition, TimelineTrack, TimelineMix, TimelineSubtitle, BinClip, Master, NoItem }; 0040 using ObjectId = std::pair<ObjectType, int>; 0041 0042 enum class MixAlignment { AlignNone, AlignLeft, AlignRight, AlignCenter }; 0043 0044 enum OperationType { 0045 None = 0, 0046 WaitingForConfirm, 0047 MoveOperation, 0048 ResizeStart, 0049 ResizeEnd, 0050 RollingStart, 0051 RollingEnd, 0052 RippleStart, 0053 RippleEnd, 0054 FadeIn, 0055 FadeOut, 0056 TransitionStart, 0057 TransitionEnd, 0058 MoveGuide, 0059 KeyFrame, 0060 Seek, 0061 Spacer, 0062 RubberSelection, 0063 ScrollTimeline, 0064 ZoomTimeline 0065 }; 0066 0067 namespace PlaylistState { 0068 Q_NAMESPACE 0069 enum ClipState { VideoOnly = 1, AudioOnly = 2, Disabled = 3, Unknown = 4 }; 0070 Q_ENUM_NS(ClipState) 0071 } // namespace PlaylistState 0072 0073 namespace FileStatus { 0074 Q_NAMESPACE 0075 enum ClipStatus { StatusReady = 0, StatusProxy, StatusMissing, StatusWaiting, StatusDeleting, StatusProxyOnly }; 0076 Q_ENUM_NS(ClipStatus) 0077 } // namespace PlaylistState 0078 0079 // returns a pair corresponding to (video, audio) 0080 std::pair<bool, bool> stateToBool(PlaylistState::ClipState state); 0081 PlaylistState::ClipState stateFromBool(std::pair<bool, bool> av); 0082 0083 namespace TimelineMode { 0084 enum EditMode { NormalEdit = 0, OverwriteEdit = 1, InsertEdit = 2 }; 0085 } 0086 0087 namespace AssetListType { 0088 Q_NAMESPACE 0089 enum AssetType { Preferred, Video, Audio, Custom, CustomAudio, Template, TemplateAudio, Favorites, AudioComposition, VideoShortComposition, VideoComposition, AudioTransition, VideoTransition, Text, Hidden = -1 }; 0090 Q_ENUM_NS(AssetType) 0091 } 0092 0093 namespace ClipType { 0094 Q_NAMESPACE 0095 enum ProducerType { 0096 Unknown = 0, 0097 Audio = 1, 0098 Video = 2, 0099 AV = 3, 0100 Color = 4, 0101 Image = 5, 0102 Text = 6, 0103 SlideShow = 7, 0104 Virtual = 8, 0105 Playlist = 9, 0106 WebVfx = 10, 0107 TextTemplate = 11, 0108 QText = 12, 0109 Composition = 13, 0110 Track = 14, 0111 Qml = 15, 0112 Animation = 16 0113 }; 0114 Q_ENUM_NS(ProducerType) 0115 } // namespace ClipType 0116 0117 enum ProjectItemType { ProjectClipType = 0, ProjectFolderType, ProjectSubclipType }; 0118 0119 enum GraphicsRectItem { AVWidget = 70000, LabelWidget, TransitionWidget, GroupWidget }; 0120 0121 namespace ToolType { 0122 Q_NAMESPACE 0123 enum ProjectTool { 0124 SelectTool = 0, 0125 RazorTool = 1, 0126 SpacerTool = 2, 0127 RippleTool = 3, 0128 RollTool = 4, 0129 SlipTool = 5, 0130 SlideTool = 6, 0131 MulticamTool = 7 0132 }; 0133 Q_ENUM_NS(ProjectTool) 0134 } 0135 0136 enum MonitorSceneType { 0137 MonitorSceneNone = 0, 0138 MonitorSceneDefault, 0139 MonitorSceneGeometry, 0140 MonitorSceneCorners, 0141 MonitorSceneRoto, 0142 MonitorSceneSplit, 0143 MonitorSceneTrimming, 0144 MonitorSplitTrack 0145 }; 0146 0147 enum MessageType { DefaultMessage, ProcessingJobMessage, OperationCompletedMessage, InformationMessage, ErrorMessage, MltError, TooltipMessage }; 0148 0149 namespace BinMessage { 0150 enum BinCategory { NoMessage = 0, ProfileMessage, StreamsMessage, InformationMessage }; 0151 } 0152 0153 enum TrackType { AudioTrack = 0, VideoTrack = 1, AnyTrack = 2, SubtitleTrack = 3 }; 0154 0155 enum CacheType { SystemCacheRoot = -1, CacheRoot = 0, CacheBase = 1, CachePreview = 2, CacheProxy = 3, CacheAudio = 4, CacheThumbs = 5 }; 0156 0157 enum TrimMode { NormalTrim, RippleTrim, RollingTrim, SlipTrim, SlideTrim }; 0158 0159 class TrackInfo 0160 { 0161 0162 public: 0163 TrackType type; 0164 QString trackName; 0165 bool isMute; 0166 bool isBlind; 0167 bool isLocked; 0168 int duration; 0169 /*EffectsList effectsList; 0170 TrackInfo() 0171 : type(VideoTrack) 0172 , isMute(0) 0173 , isBlind(0) 0174 , isLocked(0) 0175 , duration(0) 0176 , effectsList(true) 0177 { 0178 }*/ 0179 }; 0180 0181 struct requestClipInfo 0182 { 0183 QDomElement xml; 0184 QString clipId; 0185 int imageHeight; 0186 bool replaceProducer; 0187 0188 bool operator==(const requestClipInfo &a) const { return clipId == a.clipId; } 0189 }; 0190 0191 typedef QMap<QString, QString> stringMap; 0192 typedef QMap<int, QMap<int, QByteArray>> audioByteArray; 0193 using audioShortVector = QVector<qint16>; 0194 0195 class ItemInfo 0196 { 0197 public: 0198 /** startPos is the position where the clip starts on the track */ 0199 GenTime startPos; 0200 /** endPos is the duration where the clip ends on the track */ 0201 GenTime endPos; 0202 /** cropStart is the position where the sub-clip starts, relative to the clip's 0 position */ 0203 GenTime cropStart; 0204 /** cropDuration is the duration of the clip */ 0205 GenTime cropDuration; 0206 /** Track number */ 0207 int track{0}; 0208 ItemInfo() = default; 0209 bool isValid() const { return startPos != endPos; } 0210 bool contains(GenTime pos) const 0211 { 0212 if (startPos == endPos) { 0213 return true; 0214 } 0215 return (pos <= endPos && pos >= startPos); 0216 } 0217 bool operator==(const ItemInfo &a) const { return startPos == a.startPos && endPos == a.endPos && track == a.track && cropStart == a.cropStart; } 0218 }; 0219 0220 class TransitionInfo 0221 { 0222 public: 0223 /** startPos is the position where the clip starts on the track */ 0224 GenTime startPos; 0225 /** endPos is the duration where the clip ends on the track */ 0226 GenTime endPos; 0227 /** the track on which the transition is (b_track)*/ 0228 int b_track{0}; 0229 /** the track on which the transition is applied (a_track)*/ 0230 int a_track{0}; 0231 /** Does the user request for a special a_track */ 0232 bool forceTrack{false}; 0233 TransitionInfo() = default; 0234 }; 0235 0236 class CommentedTime 0237 { 0238 public: 0239 CommentedTime(); 0240 CommentedTime(const GenTime &time, QString comment, int markerType = 0); 0241 CommentedTime(const QString &hash, const GenTime &time); 0242 0243 QString comment() const; 0244 GenTime time() const; 0245 /** @brief Returns a string containing infos needed to store marker info. string equals marker type + QLatin1Char(':') + marker comment */ 0246 QString hash() const; 0247 void setComment(const QString &comm); 0248 void setTime(const GenTime &t); 0249 void setMarkerType(int t); 0250 int markerType() const; 0251 0252 /* Implementation of > operator; Works identically as with basic types. */ 0253 bool operator>(const CommentedTime &op) const; 0254 /* Implementation of < operator; Works identically as with basic types. */ 0255 bool operator<(const CommentedTime &op) const; 0256 /* Implementation of >= operator; Works identically as with basic types. */ 0257 bool operator>=(const CommentedTime &op) const; 0258 /* Implementation of <= operator; Works identically as with basic types. */ 0259 bool operator<=(const CommentedTime &op) const; 0260 /* Implementation of == operator; Works identically as with basic types. */ 0261 bool operator==(const CommentedTime &op) const; 0262 /* Implementation of != operator; Works identically as with basic types. */ 0263 bool operator!=(const CommentedTime &op) const; 0264 0265 private: 0266 GenTime m_time; 0267 QString m_comment; 0268 int m_type{0}; 0269 }; 0270 0271 class SubtitledTime 0272 { 0273 public: 0274 SubtitledTime(); 0275 SubtitledTime(const GenTime &start, QString sub, const GenTime &end); 0276 0277 QString subtitle() const; 0278 GenTime start() const; 0279 GenTime end() const; 0280 0281 void setSubtitle(const QString &sub); 0282 void setEndTime(const GenTime &end); 0283 0284 /* Implementation of > operator; Works identically as with basic types. */ 0285 bool operator>(const SubtitledTime &op) const; 0286 /* Implementation of < operator; Works identically as with basic types. */ 0287 bool operator<(const SubtitledTime &op) const; 0288 /* Implementation of == operator; Works identically as with basic types. */ 0289 bool operator==(const SubtitledTime &op) const; 0290 /* Implementation of != operator; Works identically as with basic types. */ 0291 bool operator!=(const SubtitledTime &op) const; 0292 0293 private: 0294 GenTime m_starttime; 0295 QString m_subtitle; 0296 GenTime m_endtime; 0297 }; 0298 0299 QDebug operator<<(QDebug qd, const ItemInfo &info); 0300 0301 // we provide hash function for qstring and QPersistentModelIndex 0302 namespace std { 0303 template <> struct hash<QPersistentModelIndex> 0304 { 0305 std::size_t operator()(const QPersistentModelIndex &k) const { return qHash(k); } 0306 }; 0307 } // namespace std 0308 0309 // The following is a hack that allows one to use shared_from_this in the case of a multiple inheritance. 0310 // Credit: https://stackoverflow.com/questions/14939190/boost-shared-from-this-and-multiple-inheritance 0311 template <typename T> struct enable_shared_from_this_virtual; 0312 0313 class enable_shared_from_this_virtual_base : public std::enable_shared_from_this<enable_shared_from_this_virtual_base> 0314 { 0315 using base_type = std::enable_shared_from_this<enable_shared_from_this_virtual_base>; 0316 template <typename T> friend struct enable_shared_from_this_virtual; 0317 0318 std::shared_ptr<enable_shared_from_this_virtual_base> shared_from_this() { return base_type::shared_from_this(); } 0319 std::shared_ptr<enable_shared_from_this_virtual_base const> shared_from_this() const { return base_type::shared_from_this(); } 0320 }; 0321 0322 template <typename T> struct enable_shared_from_this_virtual : virtual enable_shared_from_this_virtual_base 0323 { 0324 using base_type = enable_shared_from_this_virtual_base; 0325 0326 public: 0327 std::shared_ptr<T> shared_from_this() 0328 { 0329 std::shared_ptr<T> result(base_type::shared_from_this(), static_cast<T *>(this)); 0330 return result; 0331 } 0332 0333 std::shared_ptr<T const> shared_from_this() const 0334 { 0335 std::shared_ptr<T const> result(base_type::shared_from_this(), static_cast<T const *>(this)); 0336 return result; 0337 } 0338 }; 0339 0340 // This is a small trick to have a QAbstractItemModel with shared_from_this enabled without multiple inheritance 0341 // Be careful, if you use this class, you have to make sure to init weak_this_ when you construct a shared_ptr to your object 0342 template <class T> class QAbstractItemModel_shared_from_this : public QAbstractItemModel 0343 { 0344 protected: 0345 QAbstractItemModel_shared_from_this() 0346 : QAbstractItemModel() 0347 { 0348 } 0349 0350 public: 0351 std::shared_ptr<T> shared_from_this() 0352 { 0353 std::shared_ptr<T> p(weak_this_); 0354 assert(p.get() == this); 0355 return p; 0356 } 0357 0358 std::shared_ptr<T const> shared_from_this() const 0359 { 0360 std::shared_ptr<T const> p(weak_this_); 0361 assert(p.get() == this); 0362 return p; 0363 } 0364 0365 public: // actually private, but avoids compiler template friendship issues 0366 mutable std::weak_ptr<T> weak_this_; 0367 };