Commit 0c87cda1 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix crash on remap clip selection, add button to delete remap effect

parent 4df1f424
......@@ -161,7 +161,7 @@ void RemapView::setDuration(std::shared_ptr<Mlt::Producer> service, int duration
m_service = service;
}
bool keyframeAdded = false;
if (m_duration > 0 && m_service && m_keyframes.isEmpty()) {
if (m_duration > 0 && m_service && !m_keyframes.isEmpty()) {
if (duration > m_duration) {
// The clip was resized, ensure we have a keyframe at the end of the clip will freeze at last keyframe
QMap<int, int>::const_iterator it = m_keyframes.constEnd();
......@@ -1222,6 +1222,13 @@ TimeRemap::TimeRemap(QWidget *parent)
connect(speedAfter, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, [&](double speed) {
m_view->updateAfterSpeed(speed);
});
connect(button_del, &QToolButton::clicked, [this]() {
if (m_cid > -1) {
std::shared_ptr<TimelineItemModel> model = pCore->window()->getCurrentTimeline()->controller()->getModel();
model->requestClipTimeRemap(m_cid, false);
selectedClip(-1);
}
});
connect(button_add, &QToolButton::clicked, m_view, &RemapView::addKeyframe);
connect(button_next, &QToolButton::clicked, m_view, &RemapView::goNext);
connect(button_prev, &QToolButton::clicked, m_view, &RemapView::goPrev);
......
......@@ -530,7 +530,7 @@ void ClipModel::refreshProducerFromBin(int trackId)
refreshProducerFromBin(trackId, m_currentState, stream, 0, hasPitch, m_subPlaylistIndex == 1, isChain());
}
bool ClipModel::useTimeRemapProducer(Fun &undo, Fun &redo)
bool ClipModel::useTimeRemapProducer(bool enable, Fun &undo, Fun &redo)
{
if (m_endlessResize) {
// no timewarp for endless producers
......@@ -539,8 +539,8 @@ bool ClipModel::useTimeRemapProducer(Fun &undo, Fun &redo)
std::function<bool(void)> local_undo = []() { return true; };
std::function<bool(void)> local_redo = []() { return true; };
int audioStream = getIntProperty(QStringLiteral("audio_index"));
auto operation = useTimeRemapProducer_lambda(true, audioStream);
auto reverse = useTimeRemapProducer_lambda(false, audioStream);
auto operation = useTimeRemapProducer_lambda(enable, audioStream);
auto reverse = useTimeRemapProducer_lambda(!enable, audioStream);
if (operation()) {
UPDATE_UNDO_REDO(operation, reverse, local_undo, local_redo);
UPDATE_UNDO_REDO(local_redo, local_undo, undo, redo);
......
......@@ -200,7 +200,7 @@ protected:
/** @brief Lambda that merely changes the speed (in and out are untouched) */
Fun useTimewarpProducer_lambda(double speed, int stream, bool pitchCompensate);
bool useTimeRemapProducer(Fun &undo, Fun &redo);
bool useTimeRemapProducer(bool enable, Fun &undo, Fun &redo);
/** @brief Lambda that merely changes the speed (in and out are untouched) */
Fun useTimeRemapProducer_lambda(bool enable, int audioStream);
......
......@@ -4781,17 +4781,17 @@ bool TimelineModel::requestClipTimeWarp(int clipId, double speed, bool pitchComp
return success;
}
bool TimelineModel::requestClipTimeRemap(int clipId)
bool TimelineModel::requestClipTimeRemap(int clipId, bool enable)
{
if (!m_allClips[clipId]->isChain()) {
if (!enable || !m_allClips[clipId]->isChain()) {
Fun undo = []() { return true; };
Fun redo = []() { return true; };
int splitId = m_groups->getSplitPartner(clipId);
bool result = true;
if (splitId > -1) {
result = requestClipTimeRemap(splitId, undo, redo);
result = requestClipTimeRemap(splitId, enable, undo, redo);
}
result = result && requestClipTimeRemap(clipId, undo, redo);
result = result && requestClipTimeRemap(clipId, enable, undo, redo);
if (result) {
PUSH_UNDO(undo, redo, i18n("Enable time remap"));
return true;
......@@ -4807,7 +4807,7 @@ std::shared_ptr<Mlt::Producer> TimelineModel::getClipProducer(int clipId)
return m_allClips[clipId]->getProducer();
}
bool TimelineModel::requestClipTimeRemap(int clipId, Fun &undo, Fun &redo)
bool TimelineModel::requestClipTimeRemap(int clipId, bool enable, Fun &undo, Fun &redo)
{
QWriteLocker locker(&m_lock);
std::function<bool(void)> local_undo = []() { return true; };
......@@ -4820,8 +4820,7 @@ bool TimelineModel::requestClipTimeRemap(int clipId, Fun &undo, Fun &redo)
success = success && getTrackById(trackId)->requestClipDeletion(clipId, true, true, local_undo, local_redo, false, false);
}
if (success) {
qDebug()<<"==== REMAPING CLIP: "<<clipId;
success = m_allClips[clipId]->useTimeRemapProducer(local_undo, local_redo);
success = m_allClips[clipId]->useTimeRemapProducer(enable, local_undo, local_redo);
}
if (trackId != -1) {
success = success && getTrackById(trackId)->requestClipInsertion(clipId, oldPos, true, true, local_undo, local_redo);
......
......@@ -692,8 +692,8 @@ public:
/** @brief Same function as above, but doesn't check for paired audio and accumulate undo/redo
*/
bool requestClipTimeWarp(int clipId, double speed, bool pitchCompensate, bool changeDuration, Fun &undo, Fun &redo);
bool requestClipTimeRemap(int clipId);
bool requestClipTimeRemap(int clipId, Fun &undo, Fun &redo);
bool requestClipTimeRemap(int clipId, bool enable = true);
bool requestClipTimeRemap(int clipId, bool enable, Fun &undo, Fun &redo);
std::shared_ptr<Mlt::Producer> getClipProducer(int clipId);
void replugClip(int clipId);
......
......@@ -6,58 +6,62 @@
<rect>
<x>0</x>
<y>0</y>
<width>319</width>
<height>327</height>
<width>428</width>
<height>394</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<item row="3" column="0">
<widget class="QToolButton" name="button_prev">
<property name="text">
<string>Source clip</string>
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QCheckBox" name="source_seek">
<property name="text">
<string>Seek monitor</string>
<property name="icon">
<iconset theme="go-previous">
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset>
</property>
<property name="checked">
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<layout class="QVBoxLayout" name="remapLayout"/>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>39</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Output</string>
<string>Source clip</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<widget class="QCheckBox" name="output_seek">
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Seek monitor</string>
</property>
<property name="checked">
<bool>true</bool>
<string>Output</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QToolButton" name="button_prev">
<item row="3" column="1">
<widget class="QToolButton" name="button_next">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="go-previous">
<iconset theme="go-next">
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset>
</property>
<property name="autoRaise">
......@@ -65,16 +69,12 @@
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QToolButton" name="button_next">
<item row="7" column="0" colspan="4">
<widget class="QCheckBox" name="move_next">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="go-next">
<normaloff>../../../../.designer/backup</normaloff>../../../../.designer/backup</iconset>
<string>Preserve speed of next keyframes</string>
</property>
<property name="autoRaise">
<property name="checked">
<bool>true</bool>
</property>
</widget>
......@@ -93,49 +93,17 @@
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>20</height>
</size>
<item row="7" column="4">
<widget class="QToolButton" name="button_del">
<property name="text">
<string>...</string>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="4">
<widget class="QGroupBox" name="time_box">
<property name="title">
<string>Time</string>
<property name="icon">
<iconset theme="edit-delete"/>
</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="5" column="0" colspan="4">
<item row="5" column="0" colspan="5">
<widget class="QGroupBox" name="speed_box">
<property name="title">
<string>Speed</string>
......@@ -172,23 +140,65 @@
</layout>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<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="3" column="3" colspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>39</height>
<width>28</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0" colspan="4">
<widget class="QCheckBox" name="move_next">
<item row="2" column="2" colspan="3">
<widget class="QCheckBox" name="output_seek">
<property name="text">
<string>Preserve speed of next keyframes</string>
<string>Seek monitor</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="5">
<layout class="QVBoxLayout" name="remapLayout"/>
</item>
<item row="0" column="2" colspan="3">
<widget class="QCheckBox" name="source_seek">
<property name="text">
<string>Seek monitor</string>
</property>
<property name="checked">
<bool>true</bool>
......
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