kis_keyframe_commands.h 3.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef KIS_KEYFRAME_COMMANDS_H
#define KIS_KEYFRAME_COMMANDS_H

#include "kis_keyframe_channel.h"
#include "kundo2command.h"
#include "kritaimage_export.h"

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
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);
}

41 42 43
class KRITAIMAGE_EXPORT KisReplaceKeyframeCommand : public KUndo2Command
{
public:
44
    KisReplaceKeyframeCommand(KisKeyframeChannel *channel, int time, KisKeyframeBaseSP keyframe, KUndo2Command *parentCommand);
45

46 47
    void redo() override;
    void undo() override;
48 49 50 51

private:
    KisKeyframeChannel *m_channel;
    int m_time;
52 53
    KisKeyframeBaseSP m_keyframe;
    KisKeyframeBaseSP m_existingKeyframe;
54 55 56 57 58
};

class KRITAIMAGE_EXPORT KisMoveFrameCommand : public KUndo2Command
{
public:
59
    KisMoveFrameCommand(KisKeyframeChannel *channel, KisKeyframeBaseSP keyframe, int oldTime, int newTime, KUndo2Command *parentCommand);
60

61 62
    void redo() override;
    void undo() override;
63 64 65

private:
    KisKeyframeChannel *m_channel;
66
    KisKeyframeBaseSP m_keyframe;
67 68 69 70
    int m_oldTime;
    int m_newTime;
};

71 72 73
class KRITAIMAGE_EXPORT KisSwapFramesCommand : public KUndo2Command
{
public:
74
    KisSwapFramesCommand(KisKeyframeChannel *channel, KisKeyframeBaseSP lhsFrame, KisKeyframeBaseSP rhsFrame, KUndo2Command *parentCommand);
75 76 77 78 79 80

    void redo() override;
    void undo() override;

private:
    KisKeyframeChannel *m_channel;
81 82
    KisKeyframeBaseSP m_lhsFrame;
    KisKeyframeBaseSP m_rhsFrame;
83 84
};

85 86 87
class KRITAIMAGE_EXPORT KisDefineCycleCommand : public KUndo2Command
{
public:
88
    KisDefineCycleCommand(QSharedPointer<KisAnimationCycle> oldCycle, QSharedPointer<KisAnimationCycle> newCycle, KUndo2Command *parentCommand);
89

90 91
    QSharedPointer<KisAnimationCycle> cycle() const;

92 93 94 95 96
    void redo() override;
    void undo() override;

private:
    KisKeyframeChannel *m_channel;
97 98
    QSharedPointer<KisAnimationCycle> m_oldCycle;
    QSharedPointer<KisAnimationCycle> m_newCycle;
99 100
};

101
#endif