Commit de2e2736 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Deprecate KisPaintLayer::add/DeleteKeyframe

All the work should be done by accessing a keyframe channel
parent f2c2de8b
......@@ -256,22 +256,4 @@ void KisPaintLayer::setOnionSkinEnabled(bool state)
nodeProperties().setProperty("onionskin", state);
}
void KisPaintLayer::addNewFrame(int time, bool blank, KUndo2Command *parentCommand)
{
if (blank) {
m_d->contentChannel->addKeyframe(time, parentCommand);
} else {
KisKeyframe *keyframe = m_d->contentChannel->activeKeyframeAt(time);
m_d->contentChannel->copyKeyframe(keyframe, time, parentCommand);
}
}
void KisPaintLayer::deleteKeyfame(int time, KUndo2Command *parentCommand)
{
KisKeyframe *key = m_d->contentChannel->keyframeAt(time);
if (!key) return;
m_d->contentChannel->deleteKeyframe(key, parentCommand);
}
#include "kis_paint_layer.moc"
......@@ -92,9 +92,6 @@ public:
KisDocumentSectionModel::PropertyList sectionModelProperties() const;
void setSectionModelProperties(const KisDocumentSectionModel::PropertyList &properties);
void addNewFrame(int time, bool blank, KUndo2Command *parentCommand);
void deleteKeyfame(int time, KUndo2Command *parentCommand);
public:
QRect extent() const;
......
......@@ -193,7 +193,9 @@ void KisImageAnimationInterfaceTest::testAnimationCompositionBug()
layer1->paintDevice()->fill(rect, KoColor(Qt::red, layer1->paintDevice()->colorSpace()));
layer2->paintDevice()->fill(QRect(128,128,128,128), KoColor(Qt::black, layer2->paintDevice()->colorSpace()));
layer2->addNewFrame(10, true, &parentCommand);
KisKeyframeChannel *rasterChannel = layer2->getKeyframeChannel(KisKeyframeChannel::Content.id());
rasterChannel->addKeyframe(10, &parentCommand);
p.image->refreshGraph();
m_image = p.image;
......
......@@ -118,7 +118,8 @@ void KisPaintLayerTest::testKeyframing()
KUndo2Command parentCommand;
layer->addNewFrame(7, true, &parentCommand);
KisKeyframeChannel *rasterChannel = layer->getKeyframeChannel(KisKeyframeChannel::Content.id());
rasterChannel->addKeyframe(7, &parentCommand);
QCOMPARE(contentChannel->keyframeCount(), 2);
QVERIFY(contentChannel->keyframeAt(0) != contentChannel->keyframeAt(7));
......
......@@ -23,7 +23,6 @@
#include <klocale.h>
#include <KoIcon.h>
#include "KisViewManager.h"
#include "kis_paint_layer.h"
#include "kis_action_manager.h"
#include "kis_image_animation_interface.h"
#include "kis_animation_player.h"
......@@ -31,6 +30,7 @@
#include "kis_time_range.h"
#include "kundo2command.h"
#include "kis_post_execution_undo_adapter.h"
#include "kis_keyframe_channel.h"
......@@ -143,11 +143,11 @@ void AnimationDocker::slotAddBlankFrame()
KisNodeSP node = m_canvas->viewManager()->activeNode();
if (!node) return;
if (node->inherits("KisPaintLayer")) {
KisPaintLayer *layer = qobject_cast<KisPaintLayer*>(node.data());
KisKeyframeChannel *rasterChannel = node->getKeyframeChannel(KisKeyframeChannel::Content.id());
if (rasterChannel) {
KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Add Keyframe"));
layer->addNewFrame(m_canvas->image()->animationInterface()->currentTime(), true, cmd);
int time = m_canvas->image()->animationInterface()->currentTime();
rasterChannel->addKeyframe(time, cmd);
m_canvas->image()->postExecutionUndoAdapter()->addCommand(toQShared(cmd));
}
}
......@@ -159,11 +159,13 @@ void AnimationDocker::slotAddDuplicateFrame()
KisNodeSP node = m_canvas->viewManager()->activeNode();
if (!node) return;
if (node->inherits("KisPaintLayer")) {
KisPaintLayer *layer = qobject_cast<KisPaintLayer*>(node.data());
KisKeyframeChannel *rasterChannel = node->getKeyframeChannel(KisKeyframeChannel::Content.id());
if (rasterChannel) {
KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Add Keyframe"));
layer->addNewFrame(m_canvas->image()->animationInterface()->currentTime(), false, cmd);
int time = m_canvas->image()->animationInterface()->currentTime();
KisKeyframe *keyframe = rasterChannel->activeKeyframeAt(time);
rasterChannel->copyKeyframe(keyframe, time, cmd);
m_canvas->image()->postExecutionUndoAdapter()->addCommand(toQShared(cmd));
}
}
......@@ -175,12 +177,16 @@ void AnimationDocker::slotDeleteKeyframe()
KisNodeSP node = m_canvas->viewManager()->activeNode();
if (!node) return;
if (node->inherits("KisPaintLayer")) {
KisPaintLayer *layer = qobject_cast<KisPaintLayer*>(node.data());
KisKeyframeChannel *rasterChannel = node->getKeyframeChannel(KisKeyframeChannel::Content.id());
if (rasterChannel) {
KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Add Keyframe"));
int time = m_canvas->image()->animationInterface()->currentTime();
KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Delete Keyframe"));
layer->deleteKeyfame(m_canvas->image()->animationInterface()->currentTime(), cmd);
m_canvas->image()->postExecutionUndoAdapter()->addCommand(toQShared(cmd));
KisKeyframe *keyframe = rasterChannel->keyframeAt(time);
if (keyframe) {
rasterChannel->deleteKeyframe(keyframe, cmd);
m_canvas->image()->postExecutionUndoAdapter()->addCommand(toQShared(cmd));
}
}
}
......
......@@ -9,6 +9,8 @@
#include "kis_image_animation_interface.h"
#include "KoColor.h"
#include "kis_time_range.h"
#include "kis_keyframe_channel.h"
void KisAnimationExporterTest::testAnimationExport()
{
......@@ -20,8 +22,10 @@ void KisAnimationExporterTest::testAnimationExport()
KUndo2Command parentCommand;
p.layer->addNewFrame(1, true, &parentCommand);
p.layer->addNewFrame(2, true, &parentCommand);
KisKeyframeChannel *rasterChannel = p.layer->getKeyframeChannel(KisKeyframeChannel::Content.id());
rasterChannel->addKeyframe(1, &parentCommand);
rasterChannel->addKeyframe(2, &parentCommand);
p.image->animationInterface()->setRange(KisTimeRange::fromTime(0, 2));
KisPaintDeviceSP dev = p.layer->paintDevice();
......
......@@ -25,6 +25,8 @@
#include "kis_image_animation_interface.h"
#include "opengl/kis_opengl_image_textures.h"
#include "kis_time_range.h"
#include "kis_keyframe_channel.h"
void verifyRangeIsCachedStatus(KisAnimationFrameCacheSP cache, int start, int end, KisAnimationFrameCache::CacheStatus status)
{
......@@ -49,11 +51,13 @@ void KisAnimationFrameCacheTest::testCache()
KUndo2Command parentCommand;
layer2->addNewFrame(10, true, &parentCommand);
layer2->addNewFrame(20, true, &parentCommand);
layer2->addNewFrame(30, true, &parentCommand);
KisKeyframeChannel *rasterChannel2 = layer2->getKeyframeChannel(KisKeyframeChannel::Content.id());
rasterChannel2->addKeyframe(10, &parentCommand);
rasterChannel2->addKeyframe(20, &parentCommand);
rasterChannel2->addKeyframe(30, &parentCommand);
layer3->addNewFrame(17, true, &parentCommand);
KisKeyframeChannel *rasterChannel3 = layer2->getKeyframeChannel(KisKeyframeChannel::Content.id());
rasterChannel3->addKeyframe(17, &parentCommand);
KisOpenGLImageTexturesSP glTex = KisOpenGLImageTextures::getImageTextures(image, 0, KoColorConversionTransformation::IntentPerceptual, KoColorConversionTransformation::Empty);
KisAnimationFrameCacheSP cache = new KisAnimationFrameCache(glTex);
......
......@@ -260,14 +260,16 @@ void KisKraSaverTest::testRoundTripAnimation()
KUndo2Command parentCommand;
layer1->addNewFrame(10, true, &parentCommand);
KisKeyframeChannel *rasterChannel = layer1->getKeyframeChannel(KisKeyframeChannel::Content.id());
rasterChannel->addKeyframe(10, &parentCommand);
image->animationInterface()->switchCurrentTimeAsync(10);
image->waitForDone();
layer1->paintDevice()->fill(QRect(200, 50, 10, 10), KoColor(Qt::black, cs));
layer1->paintDevice()->move(25, 15);
layer1->paintDevice()->setDefaultPixel(KoColor(Qt::green, cs).data());
layer1->addNewFrame(20, true, &parentCommand);
rasterChannel->addKeyframe(20, &parentCommand);
image->animationInterface()->switchCurrentTimeAsync(20);
image->waitForDone();
layer1->paintDevice()->fill(QRect(150, 200, 30, 30), KoColor(Qt::black, cs));
......
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