Commit 2d4b7f09 authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Allow querying KisKeyframeChannel next/previous keyframe by time

parent 9626fbef
......@@ -185,7 +185,7 @@ int KisRepeatFrame::firstInstanceOf(int originalTime) const
const int first = this->time() + timeWithinCycle;
const KisKeyframeSP next = channel()->nextKeyframe(*this);
const KisKeyframeSP next = channel()->nextKeyframe(time());
if (next && next->time() < first) return -1;
return first;
......
......@@ -477,10 +477,10 @@ KisKeyframeSP KisKeyframeChannel::firstKeyframe() const
KisKeyframeSP KisKeyframeChannel::nextKeyframe(KisKeyframeSP keyframe) const
{
return nextKeyframe(*keyframe);
return nextKeyframe(keyframe->time());
}
KisKeyframeSP KisKeyframeChannel::nextKeyframe(const KisKeyframeBase &keyframe) const
KisKeyframeSP KisKeyframeChannel::nextKeyframe(int time) const
{
KeyframesMap::const_iterator i = KisCollectionUtils::firstAfter(m_d->keys, time);
if (i == m_d->keys.constEnd()) return KisKeyframeSP(0);
......@@ -489,10 +489,10 @@ KisKeyframeSP KisKeyframeChannel::nextKeyframe(const KisKeyframeBase &keyframe)
KisKeyframeSP KisKeyframeChannel::previousKeyframe(KisKeyframeSP keyframe) const
{
return previousKeyframe(*keyframe);
return previousKeyframe(keyframe->time());
}
KisKeyframeSP KisKeyframeChannel::previousKeyframe(const KisKeyframeBase &keyframe) const
KisKeyframeSP KisKeyframeChannel::previousKeyframe(int time) const
{
KeyframesMap::const_iterator i = KisCollectionUtils::lastBefore(m_d->keys, time);
if (i == m_d->keys.constEnd()) return KisKeyframeSP(0);
......@@ -527,7 +527,7 @@ KisKeyframeBaseSP KisKeyframeChannel::activeItemAt(int time) const
KisKeyframeBaseSP KisKeyframeChannel::nextItem(const KisKeyframeBase &item) const
{
const KisKeyframeSP keyframe = nextKeyframe(item);
const KisKeyframeSP keyframe = nextKeyframe(item.time());
auto repeatIter = KisCollectionUtils::firstAfter(m_d->repeats, item.time());
const auto repeat = (repeatIter != m_d->repeats.constEnd()) ? repeatIter.value() : QSharedPointer<KisRepeatFrame>();
......@@ -539,7 +539,7 @@ KisKeyframeBaseSP KisKeyframeChannel::nextItem(const KisKeyframeBase &item) cons
KisKeyframeBaseSP KisKeyframeChannel::previousItem(const KisKeyframeBase &item) const
{
const KisKeyframeSP keyframe = previousKeyframe(item);
const KisKeyframeSP keyframe = previousKeyframe(item.time());
auto repeatIter = KisCollectionUtils::lastBefore(m_d->repeats, item.time());
const auto repeat = (repeatIter != m_d->repeats.constEnd()) ? repeatIter.value() : QSharedPointer<KisRepeatFrame>();
......@@ -998,7 +998,7 @@ KisVisibleKeyframeIterator& KisVisibleKeyframeIterator::operator--()
}
}
m_keyframe = m_channel->previousKeyframe(*m_keyframe);
m_keyframe = m_channel->previousKeyframe(m_keyframe->time());
if (!m_keyframe) return invalidate();
m_time = m_keyframe->time();
......@@ -1017,7 +1017,7 @@ KisVisibleKeyframeIterator& KisVisibleKeyframeIterator::operator++()
}
}
m_keyframe = m_channel->nextKeyframe(*m_keyframe);
m_keyframe = m_channel->nextKeyframe(m_keyframe->time());
if (!m_keyframe) return invalidate();
m_time = m_keyframe->time();
......
......@@ -90,8 +90,8 @@ public:
KisKeyframeSP firstKeyframe() const;
KisKeyframeSP nextKeyframe(KisKeyframeSP keyframe) const;
KisKeyframeSP previousKeyframe(KisKeyframeSP keyframe) const;
KisKeyframeSP nextKeyframe(const KisKeyframeBase &keyframe) const;
KisKeyframeSP previousKeyframe(const KisKeyframeBase &keyframe) const;
KisKeyframeSP nextKeyframe(int time) const;
KisKeyframeSP previousKeyframe(int time) const;
KisKeyframeSP lastKeyframe() const;
KisKeyframeBaseSP itemAt(int time) const;
......
......@@ -78,11 +78,11 @@ public:
// Calculate changed area as the union of the current and previous keyframe.
// This makes sure there are no artifacts left over from the previous frame
// where the new one doesn't cover the area.
KisKeyframeSP neighbor = ch->previousKeyframe(*this);
KisKeyframeSP neighbor = ch->previousKeyframe(time());
// Using the *next* keyframe at the start of the timeline avoids artifacts
// when deleting or moving the first key
if (neighbor.isNull()) neighbor = ch->nextKeyframe(*this);
if (neighbor.isNull()) neighbor = ch->nextKeyframe(time());
QRect rect = ch_d->paintDevice->framesInterface()->frameBounds(frameId);
......
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