summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-21 19:10:05 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-09-21 21:36:11 (GMT)
commita0ee357c06ee529cecb9c1b1e03ba6d53a6fe5c6 (patch)
tree407a1da2b4bffbe60447d7f78d4c01ca1d91ee31
parentfe386cd8774e950dd51e944b9c404cd5c2750b57 (diff)
Various fixes for motion tracker
-rw-r--r--src/bin/bin.cpp2
-rw-r--r--src/effectstack/widgets/keyframeimport.cpp18
-rw-r--r--src/effectstack/widgets/keyframeimport.h1
-rw-r--r--src/project/jobs/meltjob.cpp2
-rw-r--r--src/timeline/customtrackview.cpp10
-rw-r--r--src/timeline/customtrackview.h2
-rw-r--r--src/timeline/keyframeview.cpp25
-rw-r--r--src/timeline/keyframeview.h2
8 files changed, 49 insertions, 13 deletions
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index a20632a..00d9587 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -2409,7 +2409,7 @@ void Bin::changeEffectState(const QString &id, const QList <int>& indexes, bool
updateMasterEffect(ctl);
m_monitor->refreshMonitorIfActive();
}
-
+
void Bin::editMasterEffect(ClipController *ctl)
{
if (m_gainedFocus) {
diff --git a/src/effectstack/widgets/keyframeimport.cpp b/src/effectstack/widgets/keyframeimport.cpp
index b12aa86..5070f00 100644
--- a/src/effectstack/widgets/keyframeimport.cpp
+++ b/src/effectstack/widgets/keyframeimport.cpp
@@ -124,12 +124,15 @@ KeyframeImport::KeyframeImport(ItemInfo srcInfo, ItemInfo dstInfo, QMap<QString,
ix++;
}
connect(m_sourceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRange()));
+ m_alignCombo = new QComboBox(this);
+ m_alignCombo->addItems(QStringList() << i18n("Align top left") << i18n("Align center") << i18n("Align bottom right"));
lab = new QLabel(i18n("Map "), this);
QLabel *lab2 = new QLabel(i18n(" to "), this);
l1->addWidget(lab);
l1->addWidget(m_sourceCombo);
l1->addWidget(lab2);
l1->addWidget(m_targetCombo);
+ l1->addWidget(m_alignCombo);
l1->addStretch(10);
ix = 0;
QMap<QString, QString>::const_iterator j = m_geometryTargets.constBegin();
@@ -245,6 +248,7 @@ void KeyframeImport::updateDataDisplay()
void KeyframeImport::updateRange()
{
int pos = m_sourceCombo->currentData().toInt();
+ m_alignCombo->setEnabled(pos == 11);
QString rangeText;
if (m_limitRange->isChecked()) {
switch (pos) {
@@ -404,7 +408,19 @@ QString KeyframeImport::selectedData() const
}
// Geometry target
int pos = m_sourceCombo->currentData().toInt();
- return m_keyframeView->getOffsetAnimation(m_inPoint->getPosition(), m_outPoint->getPosition(), m_offsetPoint->getPosition(), m_limitKeyframes->isChecked() ? m_limitNumber->value() : 0, m_profile, m_supportsAnim, pos == 11);
+ QPoint rectOffset;
+ int ix = m_alignCombo->currentIndex();
+ switch (ix) {
+ case 1:
+ rectOffset = QPoint(m_profile.profileSize.width() / 2, m_profile.profileSize.height() / 2);
+ break;
+ case 2:
+ rectOffset = QPoint(m_profile.profileSize.width(), m_profile.profileSize.height());
+ break;
+ default:
+ break;
+ }
+ return m_keyframeView->getOffsetAnimation(m_inPoint->getPosition(), m_outPoint->getPosition(), m_offsetPoint->getPosition(), m_limitKeyframes->isChecked() ? m_limitNumber->value() : 0, m_profile, m_supportsAnim, pos == 11, rectOffset);
}
QString KeyframeImport::selectedTarget() const
diff --git a/src/effectstack/widgets/keyframeimport.h b/src/effectstack/widgets/keyframeimport.h
index 71760cf..3349cec 100644
--- a/src/effectstack/widgets/keyframeimport.h
+++ b/src/effectstack/widgets/keyframeimport.h
@@ -58,6 +58,7 @@ private:
QSpinBox *m_limitNumber;
QComboBox *m_sourceCombo;
QComboBox *m_targetCombo;
+ QComboBox *m_alignCombo;
QLabel *m_sourceRangeLabel;
QList <QPoint> m_maximas;
QDoubleSpinBox m_destMin;
diff --git a/src/project/jobs/meltjob.cpp b/src/project/jobs/meltjob.cpp
index 7ce3181..c076735 100644
--- a/src/project/jobs/meltjob.cpp
+++ b/src/project/jobs/meltjob.cpp
@@ -143,7 +143,7 @@ void MeltJob::startJob()
}
}
- if (out == -1) {
+ if (out == -1 && in == -1) {
m_producer = producer;
} else {
m_producer = producer->cut(in, out);
diff --git a/src/timeline/customtrackview.cpp b/src/timeline/customtrackview.cpp
index 06dc5a3..7668f93 100644
--- a/src/timeline/customtrackview.cpp
+++ b/src/timeline/customtrackview.cpp
@@ -8090,6 +8090,8 @@ void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPo
EditEffectCommand *command = new EditEffectCommand(this, clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true, true);
m_commandStack->push(command);
emit clipItemSelected(clip);
+ } else {
+ emit displayMessage(i18n("Cannot find effect to update %1.", extra.value("finalfilter")), ErrorMessage);
}
}
@@ -8462,7 +8464,7 @@ void CustomTrackView::dropTransitionGeometry(Transition *trans, const QString &g
slotImportClipKeyframes(TransitionWidget, trans->info(), trans->toXML(), data);
}
-void CustomTrackView::dropClipGeometry(ClipItem *clip, const QString &geometry)
+void CustomTrackView::dropClipGeometry(ClipItem *clip, const QString geometry)
{
if (!m_dragItem || m_dragItem != clip) {
clearSelection(false);
@@ -8472,8 +8474,12 @@ void CustomTrackView::dropClipGeometry(ClipItem *clip, const QString &geometry)
updateTimelineSelection();
}
emit clipItemSelected(clip);
+ if (geometry.isEmpty()) {
+ emit displayMessage(i18n("No keyframes to import"), InformationMessage);
+ return;
+ }
QMap <QString, QString> data;
- data.insert(i18n("Dropped Geometry"), geometry);
+ data.insert(geometry.section("=", 0, 0), geometry.section("=", 1));
QDomElement currentEffect = clip->getEffectAtIndex(clip->selectedEffectIndex());
if (currentEffect.isNull()) {
emit displayMessage(i18n("No effect to import keyframes"), InformationMessage);
diff --git a/src/timeline/customtrackview.h b/src/timeline/customtrackview.h
index b16f75c..dd324b6 100644
--- a/src/timeline/customtrackview.h
+++ b/src/timeline/customtrackview.h
@@ -261,7 +261,7 @@ public:
/** @brief Geometry keyframes dropped on a transition, start import */
void dropTransitionGeometry(Transition *trans, const QString &geometry);
/** @brief Geometry keyframes dropped on a clip, start import */
- void dropClipGeometry(ClipItem *trans, const QString &geometry);
+ void dropClipGeometry(ClipItem *trans, const QString geometry);
/** @brief Switch current track lock state */
void switchTrackLock();
void switchAllTrackLock();
diff --git a/src/timeline/keyframeview.cpp b/src/timeline/keyframeview.cpp
index 90abe4d..45885f7 100644
--- a/src/timeline/keyframeview.cpp
+++ b/src/timeline/keyframeview.cpp
@@ -421,7 +421,7 @@ QString KeyframeView::getSingleAnimation(int ix, int in, int out, int offset, in
return result;
}
-QString KeyframeView::getOffsetAnimation(int in, int out, int offset, int limitKeyframes, ProfileInfo profile, bool allowAnimation, bool positionOnly)
+QString KeyframeView::getOffsetAnimation(int in, int out, int offset, int limitKeyframes, ProfileInfo profile, bool allowAnimation, bool positionOnly, QPoint rectOffset)
{
m_keyProperties.set("kdenlive_import", "");
int newduration = out - in + offset;
@@ -433,9 +433,13 @@ QString KeyframeView::getOffsetAnimation(int in, int out, int offset, int limitK
mlt_rect rect = m_keyProperties.anim_get_rect(m_inTimeline.toUtf8().constData(), in, duration);
rect.x = (int) rect.x;
rect.y = (int) rect.y;
- rect.w = pWidth;
- rect.h = pHeight;
- rect.o = 100;
+ if (positionOnly) {
+ rect.x -= rectOffset.x();
+ rect.y -= rectOffset.y();
+ rect.w = pWidth;
+ rect.h = pHeight;
+ rect.o = 100;
+ }
m_keyProperties.anim_set("kdenlive_import", rect, offset, newduration, kftype);
if (limitKeyframes > 0 && m_keyAnim.key_count() > limitKeyframes) {
int step = (out - in) / limitKeyframes;
@@ -444,6 +448,8 @@ QString KeyframeView::getOffsetAnimation(int in, int out, int offset, int limitK
rect.x = (int) rect.x;
rect.y = (int) rect.y;
if (positionOnly) {
+ rect.x -= rectOffset.x();
+ rect.y -= rectOffset.y();
rect.w = pWidth;
rect.h = pHeight;
rect.o = 100;
@@ -458,6 +464,8 @@ QString KeyframeView::getOffsetAnimation(int in, int out, int offset, int limitK
rect.x = (int) rect.x;
rect.y = (int) rect.y;
if (positionOnly) {
+ rect.x -= rectOffset.x();
+ rect.y -= rectOffset.y();
rect.w = pWidth;
rect.h = pHeight;
rect.o = 100;
@@ -755,15 +763,21 @@ const QString KeyframeView::serialize(const QString &name, bool rectAnimation)
QList <QPoint> KeyframeView::loadKeyframes(const QString &data)
{
+ QList <QPoint> result;
m_keyframeType = NoKeyframe;
m_inTimeline = QStringLiteral("imported");
m_keyProperties.set(m_inTimeline.toUtf8().constData(), data.toUtf8().constData());
// We need to initialize with length so that negative keyframes are correctly interpreted
- m_keyProperties.anim_get_double(m_inTimeline.toUtf8().constData(), 0);
+ m_keyProperties.anim_get_rect(m_inTimeline.toUtf8().constData(), 0, duration);
m_keyAnim = m_keyProperties.get_animation(m_inTimeline.toUtf8().constData());
duration = m_keyAnim.length();
// calculate minimas / maximas
int max = m_keyAnim.key_count();
+ if (max == 0) {
+ // invalid geometry
+ result << QPoint() << QPoint() << QPoint() << QPoint();
+ return result;
+ }
int frame = m_keyAnim.key_get_frame(0);
mlt_rect rect = m_keyProperties.anim_get_rect(m_inTimeline.toUtf8().constData(), frame, duration);
QPoint pX(rect.x, rect.x);
@@ -802,7 +816,6 @@ QList <QPoint> KeyframeView::loadKeyframes(const QString &data)
pH.setY(rect.h);
}
}
- QList <QPoint> result;
result << pX << pY << pW << pH;
return result;
}
diff --git a/src/timeline/keyframeview.h b/src/timeline/keyframeview.h
index 0ba591d..5b16715 100644
--- a/src/timeline/keyframeview.h
+++ b/src/timeline/keyframeview.h
@@ -102,7 +102,7 @@ public:
/** @brief Returns a copy of the original anim, with a crop zone (in/out), frame offset, max number of keyframes, and value mapping */
QString getSingleAnimation(int ix, int in, int out, int offset, int limitKeyframes, QPoint maximas, double min, double max);
/** @brief Returns a copy of the original anim, with a crop zone (in/out) and frame offset */
- QString getOffsetAnimation(int in, int out, int offset, int limitKeyframes, ProfileInfo profile, bool allowAnimation, bool positionOnly);
+ QString getOffsetAnimation(int in, int out, int offset, int limitKeyframes, ProfileInfo profile, bool allowAnimation, bool positionOnly, QPoint rectOffset);
private:
Mlt::Properties m_keyProperties;