Commit 202c2c1c authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

time remap: fix keyframe timecode editing, add pitch correction

parent b7fdc38b
......@@ -1197,8 +1197,8 @@ TimeRemap::TimeRemap(QWidget *parent)
QSignalBlocker bk2(m_out);
m_in->setEnabled(selection.first >= 0);
m_out->setEnabled(selection.first >= 0);
m_in->setValue(selection.first);
m_out->setValue(selection.second);
m_in->setValue(selection.first - m_view->m_inFrame);
m_out->setValue(selection.second - m_view->m_inFrame);
QSignalBlocker bk3(speedBefore);
QSignalBlocker bk4(speedAfter);
speedBefore->setEnabled(speeds.first > 0);
......@@ -1208,10 +1208,10 @@ TimeRemap::TimeRemap(QWidget *parent)
});
connect(m_view, &RemapView::updateKeyframes, this, &TimeRemap::updateKeyframes);
connect(m_in, &TimecodeDisplay::timeCodeUpdated, [this]() {
m_view->updateInPos(m_in->getValue());
m_view->updateInPos(m_in->getValue() + m_view->m_inFrame);
});
connect(m_out, &TimecodeDisplay::timeCodeUpdated, [this]() {
m_view->updateOutPos(m_out->getValue());
m_view->updateOutPos(m_out->getValue() + m_view->m_inFrame);
});
connect(m_view, &RemapView::atKeyframe, button_add, [&](bool atKeyframe) {
button_add->setIcon(atKeyframe ? QIcon::fromTheme(QStringLiteral("list-remove")) : QIcon::fromTheme(QStringLiteral("list-add")));
......@@ -1233,9 +1233,11 @@ TimeRemap::TimeRemap(QWidget *parent)
connect(button_next, &QToolButton::clicked, m_view, &RemapView::goNext);
connect(button_prev, &QToolButton::clicked, m_view, &RemapView::goPrev);
connect(move_next, &QCheckBox::toggled, m_view, &RemapView::toggleMoveNext);
connect(pitch_compensate, &QCheckBox::toggled, this, &TimeRemap::switchPitch);
connect(m_view, &RemapView::updateMaxDuration, [this](int duration) {
m_out->setRange(m_out->minimum(), INT_MAX);
m_in->setRange(m_in->minimum(), duration - 1);
int min = m_in->minimum();
m_out->setRange(0, INT_MAX);
m_in->setRange(0, duration - 1);
});
setEnabled(false);
}
......@@ -1255,8 +1257,8 @@ void TimeRemap::checkClipUpdate(const QModelIndex &topLeft, const QModelIndex &b
int min = pCore->getItemIn({ObjectType::TimelineClip,m_cid});
int max = min + m_lastLength;
m_view->m_startPos = pCore->getItemPosition({ObjectType::TimelineClip,m_cid});
m_in->setRange(min, max - 1);
m_out->setRange(min, INT_MAX);
m_in->setRange(0, m_lastLength - 1);
m_out->setRange(0, INT_MAX);
m_view->setDuration(nullptr, m_lastLength);
m_view->update();
} else if (roles.contains(TimelineModel::StartRole) && m_cid == id && !m_view->movingKeyframe()) {
......@@ -1296,8 +1298,8 @@ void TimeRemap::selectedClip(int cid)
m_lastLength = pCore->getItemDuration({ObjectType::TimelineClip,cid});
int max = min + m_lastLength;
m_view->m_startPos = pCore->getItemPosition({ObjectType::TimelineClip,cid});
m_in->setRange(min, max - 1);
m_out->setRange(min, INT_MAX);
m_in->setRange(0, m_lastLength - 1);
m_out->setRange(0, INT_MAX);
std::shared_ptr<Mlt::Producer> prod = model->getClipProducer(cid);
m_view->setDuration(prod, m_lastLength);
qDebug()<<"===== GOT PRODUCER TYPE: "<<prod->parent().type();
......@@ -1327,6 +1329,7 @@ void TimeRemap::selectedClip(int cid)
}
QString mapData(fromLink->get("map"));
m_view->loadKeyframes(mapData);
pitch_compensate->setChecked(fromLink->get_int("pitch") == 1);
keyframesLoaded = true;
setEnabled(true);
break;
......@@ -1377,7 +1380,7 @@ void TimeRemap::setClip(std::shared_ptr<ProjectClip> clip, int in, int out)
if (clip != nullptr) {
int min = in == -1 ? 0 : in;
int max = out == -1 ? clip->getFramePlaytime() : out;
m_in->setRange(min, max);
m_in->setRange(0, max - min);
m_out->setRange(min, INT_MAX);
m_view->m_startPos = 0;
m_view->setBinClipDuration(clip, max - min);
......@@ -1463,6 +1466,7 @@ void TimeRemap::updateKeyframes(bool resize)
if (m_view->m_remapLink) {
qDebug()<<"====== OK; PROCESSING REMAP UPDATE";
m_view->m_remapLink->set("map", kfData.toUtf8().constData());
switchPitch();
if (m_splitRemap) {
m_splitRemap->set("map", kfData.toUtf8().constData());
}
......@@ -1482,6 +1486,14 @@ void TimeRemap::updateKeyframes(bool resize)
}
}
void TimeRemap::switchPitch()
{
m_view->m_remapLink->set("pitch", pitch_compensate->isChecked() ? 1 : 0);
if (m_splitRemap) {
m_splitRemap->set("pitch", pitch_compensate->isChecked() ? 1 : 0);
}
}
TimeRemap::~TimeRemap()
{
//delete m_previewTimer;
......
......@@ -150,6 +150,7 @@ public:
private slots:
void updateKeyframes(bool resize = true);
void checkClipUpdate(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int>& roles);
void switchPitch();
private:
std::shared_ptr<Mlt::Link> m_splitRemap;
......
......@@ -6,25 +6,51 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>394</height>
<width>399</width>
<height>346</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0">
<widget class="QToolButton" name="button_prev">
<item row="4" column="0" colspan="5">
<widget class="QGroupBox" name="time_box">
<property name="title">
<string>Time</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Source time</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="inLayout"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Output time</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="outLayout"/>
</item>
</layout>
</widget>
</item>
<item row="8" column="4">
<widget class="QToolButton" name="button_del">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="go-previous">
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
<iconset theme="edit-delete">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
......@@ -41,44 +67,6 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Source clip</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Output</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QToolButton" name="button_next">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<widget class="QCheckBox" name="move_next">
<property name="text">
<string>Preserve speed of next keyframes</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="button_add">
<property name="text">
......@@ -93,16 +81,6 @@
</property>
</widget>
</item>
<item row="7" column="4">
<widget class="QToolButton" name="button_del">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="edit-delete"/>
</property>
</widget>
</item>
<item row="5" column="0" colspan="5">
<widget class="QGroupBox" name="speed_box">
<property name="title">
......@@ -140,33 +118,11 @@
</layout>
</widget>
</item>
<item row="4" column="0" colspan="5">
<widget class="QGroupBox" name="time_box">
<property name="title">
<string>Time</string>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Output</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Source time</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="inLayout"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Output time</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="outLayout"/>
</item>
</layout>
</widget>
</item>
<item row="3" column="3" colspan="2">
......@@ -192,9 +148,54 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QToolButton" name="button_prev">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="go-previous">
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Source clip</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QToolButton" name="button_next">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<layout class="QVBoxLayout" name="remapLayout"/>
</item>
<item row="8" column="0" colspan="4">
<widget class="QCheckBox" name="move_next">
<property name="text">
<string>Preserve speed of next keyframes</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2" colspan="3">
<widget class="QCheckBox" name="source_seek">
<property name="text">
......@@ -205,6 +206,19 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QCheckBox" name="pitch_compensate">
<property name="text">
<string>Pitch compensation</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
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