Commit 031cfb1b authored by Dmitry Kazakov's avatar Dmitry Kazakov

Allow overwriting frames when move and copy them

Fixes T1100
parent 894789e7
......@@ -56,9 +56,9 @@ struct KisKeyframeChannel::InsertFrameCommand : public KUndo2Command
private:
void doSwap(bool insert) {
if (insert) {
m_channel->insertKeyframeImpl(m_keyframe);
m_channel->insertKeyframeLogical(m_keyframe);
} else {
m_channel->deleteKeyframeImpl(m_keyframe);
m_channel->deleteKeyframeLogical(m_keyframe);
}
}
......@@ -132,7 +132,7 @@ KisKeyframeSP KisKeyframeChannel::addKeyframe(int time, KUndo2Command *parentCom
return insertKeyframe(time, KisKeyframeSP(), parentCommand);
}
void KisKeyframeChannel::deleteKeyframeImpl(KisKeyframeSP keyframe)
void KisKeyframeChannel::deleteKeyframeLogical(KisKeyframeSP keyframe)
{
QRect rect = affectedRect(keyframe);
KisTimeRange range = affectedFrames(keyframe->time());
......@@ -145,7 +145,7 @@ void KisKeyframeChannel::deleteKeyframeImpl(KisKeyframeSP keyframe)
}
bool KisKeyframeChannel::deleteKeyframe(KisKeyframeSP keyframe, KUndo2Command *parentCommand)
bool KisKeyframeChannel::deleteKeyframeImpl(KisKeyframeSP keyframe, KUndo2Command *parentCommand, bool recreate)
{
LAZY_INITIALIZE_PARENT_COMMAND(parentCommand);
......@@ -155,13 +155,18 @@ bool KisKeyframeChannel::deleteKeyframe(KisKeyframeSP keyframe, KUndo2Command *p
cmd->redo();
destroyKeyframe(keyframe, parentCommand);
if (keyframe->time() == 0) {
if (recreate && keyframe->time() == 0) {
addKeyframe(0, parentCommand);
}
return true;
}
bool KisKeyframeChannel::deleteKeyframe(KisKeyframeSP keyframe, KUndo2Command *parentCommand)
{
return deleteKeyframeImpl(keyframe, parentCommand, true);
}
void KisKeyframeChannel::moveKeyframeImpl(KisKeyframeSP keyframe, int newTime)
{
KIS_ASSERT_RECOVER_RETURN(keyframe);
......@@ -191,7 +196,9 @@ bool KisKeyframeChannel::moveKeyframe(KisKeyframeSP keyframe, int newTime, KUndo
LAZY_INITIALIZE_PARENT_COMMAND(parentCommand);
KisKeyframeSP other = keyframeAt(newTime);
if (other) return false;
if (other) {
deleteKeyframeImpl(other, parentCommand, false);
}
const int srcTime = keyframe->time();
......@@ -379,7 +386,7 @@ const KisKeyframeChannel::KeyframesMap& KisKeyframeChannel::constKeys() const
return m_d->keys;
}
void KisKeyframeChannel::insertKeyframeImpl(KisKeyframeSP keyframe)
void KisKeyframeChannel::insertKeyframeLogical(KisKeyframeSP keyframe)
{
const int time = keyframe->time();
......@@ -395,7 +402,9 @@ void KisKeyframeChannel::insertKeyframeImpl(KisKeyframeSP keyframe)
KisKeyframeSP KisKeyframeChannel::insertKeyframe(int time, const KisKeyframeSP copySrc, KUndo2Command *parentCommand)
{
KisKeyframeSP keyframe = keyframeAt(time);
if (keyframe) return keyframe;
if (keyframe) {
deleteKeyframeImpl(keyframe, parentCommand, false);
}
Q_ASSERT(parentCommand);
keyframe = createKeyframe(time, copySrc, parentCommand);
......
......@@ -117,8 +117,9 @@ protected:
virtual void saveKeyframe(KisKeyframeSP keyframe, QDomElement keyframeElement, const QString &layerFilename) = 0;
private:
void insertKeyframeImpl(KisKeyframeSP keyframe);
void deleteKeyframeImpl(KisKeyframeSP keyframe);
void insertKeyframeLogical(KisKeyframeSP keyframe);
void deleteKeyframeLogical(KisKeyframeSP keyframe);
bool deleteKeyframeImpl(KisKeyframeSP keyframe, KUndo2Command *parentCommand, bool recreate);
void moveKeyframeImpl(KisKeyframeSP keyframe, int newTime);
struct InsertFrameCommand;
......
......@@ -161,11 +161,6 @@ namespace KisAnimationUtils {
if (!content) continue;
KisKeyframeSP dstKeyframe = content->keyframeAt(dstTime);
if (dstKeyframe) {
content->deleteKeyframe(dstKeyframe, cmd.data());
}
KisKeyframeSP srcKeyframe = content->keyframeAt(srcTime);
if (srcKeyframe) {
if (copy) {
......
......@@ -841,7 +841,7 @@ void TimelineFramesModel::setScrubState(bool active)
m_d->scrubInProgress = false;
if (m_d->scrubStartFrame > 0 &&
if (m_d->scrubStartFrame >= 0 &&
m_d->scrubStartFrame != m_d->activeFrameIndex) {
scrubTo(m_d->activeFrameIndex, false);
......
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