Krita Source Code Documentation
Loading...
Searching...
No Matches
KisAutoKey Namespace Reference

Classes

class  AutoKeyFrameStateHolder
 

Enumerations

enum  AutoCreateKeyframeFlag { None = 0x0 , AllowBlankMode = 0x1 , SupportsLod = 0x2 }
 
enum  Mode { NONE , BLANK , DUPLICATE }
 

Functions

Mode activeMode ()
 
void initHolder ()
 
void testingSetActiveMode (Mode mode)
 
KUndo2CommandtryAutoCreateDuplicatedFrame (KisPaintDeviceSP device, AutoCreateKeyframeFlags flags=None)
 create a new duplicated keyframe if auto-keyframe mode is on
 

Variables

QScopedPointer< AutoKeyFrameStateHolders_holder
 

Enumeration Type Documentation

◆ AutoCreateKeyframeFlag

Enumerator
None 
AllowBlankMode 
SupportsLod 

Definition at line 34 of file KisAnimAutoKey.h.

34 {
35 None = 0x0,
36 AllowBlankMode = 0x1,
37 SupportsLod = 0x2
38};

◆ Mode

Enumerator
NONE 
BLANK 
DUPLICATE 

Definition at line 24 of file KisAnimAutoKey.h.

24 {
25 NONE, // AutoKey is disabled. Keyframes must be created manually.
26 BLANK, // AutoKey creates an empty/blank frame. Acts like DUPLICATE when not
27 // applicable (i.e.: filters, transforms, etc.).
28 DUPLICATE // AutoKey will duplicate the active frame.
29};
@ NONE

Function Documentation

◆ activeMode()

KRITAIMAGE_EXPORT Mode KisAutoKey::activeMode ( )

Definition at line 75 of file KisAnimAutoKey.cpp.

76{
77 return s_holder->mode();
78}
QScopedPointer< AutoKeyFrameStateHolder > s_holder

References s_holder.

◆ initHolder()

void KisAutoKey::initHolder ( )

Definition at line 68 of file KisAnimAutoKey.cpp.

68 {
69 if (!s_holder) {
71 }
72}

References s_holder.

◆ testingSetActiveMode()

KRITAIMAGE_EXPORT void KisAutoKey::testingSetActiveMode ( Mode mode)

Definition at line 133 of file KisAnimAutoKey.cpp.

134{
135 s_holder->testingSetActiveMode(mode);
136}

References s_holder.

◆ tryAutoCreateDuplicatedFrame()

KRITAIMAGE_EXPORT KUndo2Command * KisAutoKey::tryAutoCreateDuplicatedFrame ( KisPaintDeviceSP device,
AutoCreateKeyframeFlags flags = None )

create a new duplicated keyframe if auto-keyframe mode is on

Parameters
devicea paint device of the layer to be processed
Returns
an undo command if the keyframe has been duplicated

Use the same color label as previous keyframe, the duplicate action duplicates the label automatically, but addKeyframe not

Definition at line 80 of file KisAnimAutoKey.cpp.

80 {
81 KUndo2Command* undo = nullptr;
83
84 const bool isLodNMode = device->defaultBounds()->currentLevelOfDetail() > 0;
85
86 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(!isLodNMode || flags & SupportsLod, undo);
87
88 const KisAutoKey::Mode autoKeyMode = KisAutoKey::activeMode();
89 if (autoKeyMode == KisAutoKey::NONE) return undo;
90
91 KisRasterKeyframeChannel *channel = device->keyframeChannel();
92 if (!channel) return undo;
93
94 const int activeKeyframe = channel->activeKeyframeTime();
95 const int targetKeyframe = device->defaultBounds()->currentTime();
96
97 if (activeKeyframe == targetKeyframe) return undo;
98
99 if (isLodNMode) {
100 if (flags & AllowBlankMode && autoKeyMode == KisAutoKey::BLANK) {
101 const QRect originalDirtyRect = device->exactBounds();
102 KisTransaction transaction(device);
103 device->clear();
104 device->setDirty(originalDirtyRect);
105 undo = transaction.endAndTake();
106 }
107 // for KisAutoKey::DUPLICATE mode we do nothing and just reuse
108 // the LoDN device
109 } else {
110 undo = new KUndo2Command;
111
112 if (flags & AllowBlankMode && autoKeyMode == KisAutoKey::BLANK) {
113 channel->addKeyframe(targetKeyframe, undo);
114
117
118 KisKeyframeSP newKeyframe = channel->keyframeAt(targetKeyframe);
119 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(newKeyframe, undo);
120
121 KisKeyframeSP oldKeyframe = channel->keyframeAt(activeKeyframe);
122 KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(oldKeyframe, undo);
123
124 newKeyframe->setColorLabel(oldKeyframe->colorLabel());
125 } else {
126 channel->copyKeyframe(activeKeyframe, targetKeyframe, undo);
127 }
128 }
129
130 return undo;
131}
virtual int currentLevelOfDetail() const =0
virtual int currentTime() const =0
KisKeyframeSP keyframeAt(int time) const
Get a keyframe at specified time. Used primarily when the value of a given keyframe is needed.
static void copyKeyframe(const KisKeyframeChannel *sourceChannel, int sourceTime, KisKeyframeChannel *targetChannel, int targetTime, KUndo2Command *parentUndoCmd=nullptr)
Copy a keyframe across channel(s) at the specified times.
void addKeyframe(int time, KUndo2Command *parentUndoCmd=nullptr)
Add a new keyframe to the channel at the specified time.
int activeKeyframeTime(int time) const
Get the time of the active keyframe. Useful for snapping any time to that of the most recent keyframe...
KisRasterKeyframeChannel * keyframeChannel() const
void setDirty(const QRect &rc)
virtual void clear()
QRect exactBounds() const
KisDefaultBoundsBaseSP defaultBounds() const
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129
QAction * undo(const QObject *recvr, const char *slot, QObject *parent)

References KisKeyframeChannel::activeKeyframeTime(), activeMode(), KisKeyframeChannel::addKeyframe(), AllowBlankMode, BLANK, KisPaintDevice::clear(), KisKeyframeChannel::copyKeyframe(), KisDefaultBoundsBase::currentLevelOfDetail(), KisDefaultBoundsBase::currentTime(), KisPaintDevice::defaultBounds(), KisTransaction::endAndTake(), KisPaintDevice::exactBounds(), KisKeyframeChannel::keyframeAt(), KisPaintDevice::keyframeChannel(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, NONE, KisPaintDevice::setDirty(), and SupportsLod.

Variable Documentation

◆ s_holder

QScopedPointer<AutoKeyFrameStateHolder> KisAutoKey::s_holder

Definition at line 67 of file KisAnimAutoKey.cpp.