Commit 96333af4 authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Add command to move multiple keyframes at once

This allows the moves to be validated as one operation. In particular,
animation cycle ranges can be updated based on moved or overwritten
parent 2d4b7f09
......@@ -27,6 +27,13 @@ KisAnimationCycle::KisAnimationCycle(KisKeyframeChannel *channel, KisKeyframeSP
, m_lastSourceKeyframe(lastKeyframe)
KisAnimationCycle::KisAnimationCycle(const KisAnimationCycle &cycle, KisKeyframeSP firstKeyframe, KisKeyframeSP lastKeyframe)
: KisKeyframeBase(, firstKeyframe->time())
, m_firstSourceKeyframe(firstKeyframe)
, m_lastSourceKeyframe(lastKeyframe)
, m_repeats(cycle.m_repeats)
KisKeyframeSP KisAnimationCycle::firstSourceKeyframe() const
return m_firstSourceKeyframe;
......@@ -30,6 +30,8 @@ class KRITAIMAGE_EXPORT KisAnimationCycle : public KisKeyframeBase {
KisAnimationCycle(KisKeyframeChannel *channel, KisKeyframeSP firstKeyframe, KisKeyframeSP lastKeyframe);
KisAnimationCycle(const KisAnimationCycle &cycle, KisKeyframeSP firstKeyframe, KisKeyframeSP lastKeyframe);
KisKeyframeSP firstSourceKeyframe() const;
KisKeyframeSP lastSourceKeyframe() const;
KisTimeSpan originalRange() const;
......@@ -553,6 +553,11 @@ KisVisibleKeyframeIterator KisKeyframeChannel::visibleKeyframesFrom(int time) co
return KisVisibleKeyframeIterator(visibleKeyframeAt(time));
QList<QSharedPointer<KisAnimationCycle>> KisKeyframeChannel::cycles() const
return m_d->cycles.values();
KisTimeSpan KisKeyframeChannel::cycledRangeAt(int time) const
QSharedPointer<KisRepeatFrame> repeat = activeRepeatAt(time);
......@@ -101,6 +101,8 @@ public:
KisVisibleKeyframeIterator visibleKeyframesFrom(int time) const;
QList<QSharedPointer<KisAnimationCycle>> cycles() const;
* Finds the original range of the cycle defined or repeated at the given time.
* @arg time a time at any frame within the original cycle or any repeat of it.
......@@ -199,6 +201,7 @@ private:
void addCycle(QSharedPointer<KisAnimationCycle> cycle);
void removeCycle(QSharedPointer<KisAnimationCycle> cycle);
friend class KisMoveKeyframesCommand;
friend class KisMoveFrameCommand;
friend class KisReplaceKeyframeCommand;
friend class KisSwapFramesCommand;
This diff is collapsed.
......@@ -21,6 +21,23 @@
#include "kundo2command.h"
#include "kritaimage_export.h"
namespace KisKeyframeCommands
struct KRITAIMAGE_EXPORT KeyframeMove
KisKeyframeBaseSP keyframe;
int oldTime, newTime;
KeyframeMove() = default;
KeyframeMove(KisKeyframeBaseSP keyframe, int newTime);
* Returns either a new command for operations needed to move the keyframes or null if the operation is invalid against the current state of the channel
KRITAIMAGE_EXPORT KUndo2CommandSP tryMoveKeyframes(KisKeyframeChannel *channel, QVector<KeyframeMove> moves, KUndo2Command *parentCommand);
class KRITAIMAGE_EXPORT KisReplaceKeyframeCommand : public KUndo2Command
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment