Commit 3278b0b2 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Correctly update the layer with onion skins when a new frame added/removed

parent e10300ba
......@@ -143,6 +143,8 @@ QRect KisOnionSkinCompositor::calculateFullExtent(const KisPaintDeviceSP device)
QRect rect;
KisRasterKeyframeChannel *channel = device->keyframeChannel();
if (!channel) return rect;
KisKeyframeSP keyframe = channel->firstKeyframe();
while (keyframe) {
......
......@@ -281,12 +281,15 @@ void KisPaintLayer::setOnionSkinEnabled(bool state)
}
nodeProperties().setProperty("onionskin", state);
m_d->contentChannel->setOnionSkinsEnabled(state);
baseNodeChangedCallback();
}
void KisPaintLayer::slotExternalUpdateOnionSkins()
{
if (!onionSkinEnabled()) return;
const QRect dirtyRect =
KisOnionSkinCompositor::instance()->calculateFullExtent(m_d->paintDevice);
......
......@@ -24,16 +24,19 @@
#include "kis_paint_device_frames_interface.h"
#include "kis_time_range.h"
#include "kundo2command.h"
#include "kis_onion_skin_compositor.h"
struct KisRasterKeyframeChannel::Private
{
Private(KisPaintDeviceWSP paintDevice)
: paintDevice(paintDevice)
: paintDevice(paintDevice),
onionSkinsEnabled(false)
{}
KisPaintDeviceWSP paintDevice;
QMap<int, QString> frameFilenames;
bool onionSkinsEnabled;
};
KisRasterKeyframeChannel::KisRasterKeyframeChannel(const KoID &id, const KisNodeWSP node, const KisPaintDeviceWSP paintDevice)
......@@ -139,6 +142,12 @@ QRect KisRasterKeyframeChannel::affectedRect(KisKeyframeSP key)
rect |= m_d->paintDevice->framesInterface()->frameBounds(key->value());
if (m_d->onionSkinsEnabled) {
const QRect dirtyOnionSkinsRect =
KisOnionSkinCompositor::instance()->calculateFullExtent(m_d->paintDevice);
rect |= dirtyOnionSkinsRect;
}
return rect;
}
......@@ -240,3 +249,13 @@ void KisRasterKeyframeChannel::setScalarValue(KisKeyframeSP keyframe, qreal valu
Q_UNUSED(value);
Q_UNUSED(parentCommand);
}
void KisRasterKeyframeChannel::setOnionSkinsEnabled(bool value)
{
m_d->onionSkinsEnabled = value;
}
bool KisRasterKeyframeChannel::onionSkinsEnabled() const
{
return m_d->onionSkinsEnabled;
}
......@@ -60,6 +60,9 @@ public:
QDomElement toXML(QDomDocument doc, const QString &layerFilename);
void loadXML(const QDomElement &channelNode);
void setOnionSkinsEnabled(bool value);
bool onionSkinsEnabled() const;
protected:
KisKeyframeSP createKeyframe(int time, const KisKeyframeSP copySrc, KUndo2Command *parentCommand);
bool canDeleteKeyframe(KisKeyframeSP key);
......
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