Various fixes for motion tracker

parent fe386cd8
......@@ -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) {
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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();
......
......@@ -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;
}
......
......@@ -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;
......
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