File indexing completed on 2024-06-23 04:26:18
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KIS_ANIMATION_UTILS_H 0008 #define __KIS_ANIMATION_UTILS_H 0009 0010 #include "kis_types.h" 0011 0012 #include <boost/operators.hpp> 0013 #include <QModelIndexList> 0014 0015 #include <kritaanimationdocker_export.h> 0016 0017 0018 namespace KisAnimUtils 0019 { 0020 KUndo2Command* createKeyframeCommand(KisImageSP image, KisNodeSP node, const QString &channelId, int time, bool copy, KUndo2Command *parentCommand = 0); 0021 void createKeyframeLazy(KisImageSP image, KisNodeSP node, const QString &channel, int time, bool copy); 0022 0023 struct KRITAANIMATIONDOCKER_EXPORT FrameItem : public boost::equality_comparable<FrameItem> 0024 { 0025 FrameItem() : time(-1) {} 0026 FrameItem(KisNodeSP _node, const QString &_channel, int _time) : node(_node), channel(_channel), time(_time) {} 0027 0028 bool operator==(const FrameItem &rhs) const { 0029 return rhs.node == node && rhs.channel == channel && rhs.time == time; 0030 } 0031 0032 KisNodeSP node; 0033 QString channel; 0034 int time; 0035 }; 0036 0037 KRITAANIMATIONDOCKER_EXPORT QDebug operator<<(QDebug dbg, const FrameItem &item); 0038 0039 inline uint qHash(const FrameItem &item) 0040 { 0041 return ::qHash(item.node.data()) + ::qHash(item.channel) + ::qHash(item.time); 0042 } 0043 0044 0045 typedef QVector<FrameItem> FrameItemList; 0046 typedef std::pair<FrameItem, FrameItem> FrameMovePair; 0047 typedef QVector<FrameMovePair> FrameMovePairList; 0048 0049 0050 void removeKeyframes(KisImageSP image, const FrameItemList &frames); 0051 void removeKeyframe(KisImageSP image, KisNodeSP node, const QString &channel, int time); 0052 void resetChannels(KisImageSP image, KisNodeSP node, const QList<QString> &channelIDs); 0053 void resetChannel(KisImageSP image, KisNodeSP node, const QString &channelID); 0054 0055 void sortPointsForSafeMove(QModelIndexList *points, const QPoint &offset); 0056 0057 KUndo2Command* createMoveKeyframesCommand(const FrameItemList &srcFrames, const FrameItemList &dstFrames, 0058 bool copy, bool moveEmpty, KUndo2Command *parentCommand = 0); 0059 0060 0061 /** 0062 * @brief implements safe moves of the frames (even if there are cycling move dependencies) 0063 * @param movePairs the jobs for the moves 0064 * @param copy shows if the frames should be copied or not 0065 * @param moveEmpty allows an empty frame to replace a populated one 0066 * @param parentCommand the command that should be a parent of the created command 0067 * @return a created undo command 0068 */ 0069 KRITAANIMATIONDOCKER_EXPORT 0070 KUndo2Command* createMoveKeyframesCommand(const FrameMovePairList &movePairs, 0071 bool copy, bool moveEmptyFrames, KUndo2Command *parentCommand = 0); 0072 0073 KUndo2Command* createCloneKeyframesCommand(const FrameMovePairList &srcDstPairs, 0074 KUndo2Command *parentCommand); 0075 0076 void makeClonesUnique(KisImageSP image, const FrameItemList &frames); 0077 0078 bool supportsContentFrames(KisNodeSP node); 0079 0080 extern const QString lazyFrameCreationActionName; 0081 extern const QString dropFramesActionName; 0082 0083 extern const QString newLayerActionName; 0084 extern const QString pinExistingLayerActionName; 0085 extern const QString removeLayerActionName; 0086 0087 extern const QString addOpacityKeyframeActionName; 0088 extern const QString addTransformKeyframeActionName; 0089 extern const QString removeOpacityKeyframeActionName; 0090 extern const QString removeTransformKeyframeActionName; 0091 }; 0092 0093 0094 #endif /* __KIS_ANIMATION_UTILS_H */