Commit 4a2e40dd authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Time Remap: don't allow keyframe after last frame of source clip

parent df66189b
Pipeline #124308 passed with stage
in 5 minutes and 6 seconds
......@@ -190,9 +190,10 @@ void RemapView::setBinClipDuration(std::shared_ptr<ProjectClip> clip, int durati
m_currentKeyframe = m_currentKeyframeOriginal = {-1,-1};
}
void RemapView::setDuration(std::shared_ptr<Mlt::Producer> service, int duration)
void RemapView::setDuration(std::shared_ptr<Mlt::Producer> service, int duration, int sourceDuration)
{
m_clip = nullptr;
m_sourceDuration = sourceDuration;
if (duration < 0) {
// reset
m_service = nullptr;
......@@ -492,6 +493,13 @@ void RemapView::mouseMoveEvent(QMouseEvent *event)
int delta = realPos - m_currentKeyframe.second;
// Check that the move is possible
QMapIterator<int, int> i(m_selectedKeyframes);
while (i.hasNext()) {
i.next();
if (i.value() + delta > m_sourceDuration) {
return;
}
}
i.toFront();
QMap<int,int>updated;
while (i.hasNext()) {
i.next();
......@@ -1686,7 +1694,7 @@ void TimeRemap::selectedClip(int cid)
m_in->setRange(0, m_view->m_maxLength - prod->get_in());
//m_in->setRange(0, m_lastLength - 1);
m_out->setRange(0, INT_MAX);
m_view->setDuration(prod, m_lastLength);
m_view->setDuration(prod, m_lastLength, prod->parent().get_length());
qDebug()<<"===== GOT PRODUCER TYPE: "<<prod->parent().type();
if (prod->parent().type() == mlt_service_chain_type) {
Mlt::Chain fromChain(prod->parent());
......
......@@ -35,7 +35,7 @@ public:
friend class TimeRemap;
explicit RemapView(QWidget *parent = nullptr);
void setBinClipDuration(std::shared_ptr<ProjectClip> clip, int duration);
void setDuration(std::shared_ptr<Mlt::Producer> service, int duration);
void setDuration(std::shared_ptr<Mlt::Producer> service, int duration, int sourceDuration = 0);
void loadKeyframes(const QString &mapData);
const QString getKeyframesData(QMap<int,int> keyframes = {}) const;
int position() const;
......@@ -81,6 +81,7 @@ public slots:
private:
enum MOVEMODE {NoMove, TopMove, BottomMove, CursorMove, CursorMoveBottom};
int m_duration;
int m_sourceDuration;
int m_lastMaxDuration;
int m_position;
/** @brief the maximum duration of the parent (bin) clip */
......
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