Commit 187a5f77 authored by Nicolas Carion's avatar Nicolas Carion

Bring back reverse clip feature. Fix #63

parent 06dc14bc
......@@ -620,7 +620,7 @@ std::shared_ptr<Mlt::Producer> ProjectClip::getTimelineProducer(int clipId, Play
qDebug() << "warp LENGTH before" << warpProducer->get_length();
int original_length = originalProducer()->get_length();
// this is a workaround to cope with Mlt erroneous rounding
warpProducer->set("length", double(original_length) / speed);
warpProducer->set("length", double(original_length) / std::abs(speed));
}
qDebug() << "warp LENGTH" << warpProducer->get_length();
......
set(kdenlive_SRCS
${kdenlive_SRCS}
timeline2/model/builders/meltBuilder.cpp
timeline2/model/clipmodel.cpp
timeline2/model/compositionmodel.cpp
timeline2/model/groupsmodel.cpp
timeline2/model/snapmodel.cpp
timeline2/model/timelinefunctions.cpp
timeline2/model/timelineitemmodel.cpp
timeline2/model/timelinemodel.cpp
timeline2/model/timelinefunctions.cpp
timeline2/model/trackmodel.cpp
timeline2/model/snapmodel.cpp
timeline2/model/builders/meltBuilder.cpp
timeline2/view/dialogs/clipdurationdialog.cpp
timeline2/view/dialogs/spacerdialog.cpp
timeline2/view/dialogs/speeddialog.cpp
timeline2/view/dialogs/trackdialog.cpp
timeline2/view/dialogs/clipdurationdialog.cpp
timeline2/view/previewmanager.cpp
timeline2/view/timelinetabs.cpp
timeline2/view/timelinecontroller.cpp
timeline2/view/timelinewidget.cpp
timeline2/view/qml/timelineitems.cpp
timeline2/view/qmltypes/thumbnailprovider.cpp
timeline2/view/timelinecontroller.cpp
timeline2/view/timelinetabs.cpp
timeline2/view/timelinewidget.cpp
PARENT_SCOPE)
......@@ -371,10 +371,10 @@ void ClipModel::refreshProducerFromBin(PlaylistState::ClipState state, double sp
int out = getOut();
qDebug() << "refresh " << speed << m_speed << in << out;
if (!qFuzzyCompare(speed, m_speed) && !qFuzzyCompare(speed, 0.)) {
in = in * m_speed / speed;
in = in * std::abs(m_speed / speed);
out = in + getPlaytime() - 1;
// prevent going out of the clip's range
out = std::min(out, int(double(m_producer->get_length()) * m_speed / speed) - 1);
out = std::min(out, int(double(m_producer->get_length()) * std::abs(m_speed / speed)) - 1);
m_speed = speed;
qDebug() << "changing speed" << in << out << m_speed;
}
......@@ -408,7 +408,7 @@ bool ClipModel::useTimewarpProducer(double speed, Fun &undo, Fun &redo)
std::function<bool(void)> local_redo = []() { return true; };
double previousSpeed = getSpeed();
int oldDuration = getPlaytime();
int newDuration = int(double(oldDuration) * previousSpeed / speed);
int newDuration = int(double(oldDuration) * std::abs(previousSpeed / speed));
int oldOut = getOut();
int oldIn = getIn();
auto operation = useTimewarpProducer_lambda(speed);
......
#include "speeddialog.h"
#include "ui_speeddialog_ui.h"
SpeedDialog::SpeedDialog(QWidget *parent, double speed, double minSpeed, double maxSpeed, bool reversed)
: QDialog(parent)
, ui(new Ui::SpeedDialog)
{
ui->setupUi(this);
setWindowTitle(i18n("Clip Speed"));
ui->doubleSpinBox->setDecimals(2);
ui->doubleSpinBox->setMinimum(minSpeed);
ui->doubleSpinBox->setMaximum(maxSpeed);
ui->doubleSpinBox->setValue(speed);
if (reversed) {
ui->checkBox->setChecked(true);
}
}
SpeedDialog::~SpeedDialog()
{
delete ui;
}
double SpeedDialog::getValue() const
{
double val = ui->doubleSpinBox->value();
if (ui->checkBox->checkState() == Qt::Checked) {
val *= -1;
}
return val;
}
#ifndef SPEEDDIALOG_H
#define SPEEDDIALOG_H
#include <QDialog>
namespace Ui {
class SpeedDialog;
}
class SpeedDialog : public QDialog
{
Q_OBJECT
public:
explicit SpeedDialog(QWidget *parent, double speed, double minSpeed, double maxSpeed, bool reversed);
~SpeedDialog();
double getValue() const;
private:
Ui::SpeedDialog *ui;
};
#endif // SPEEDDIALOG_H
......@@ -29,6 +29,7 @@
#include "bin/projectitemmodel.h"
#include "core.h"
#include "dialogs/spacerdialog.h"
#include "dialogs/speeddialog.h"
#include "doc/kdenlivedoc.h"
#include "effects/effectsrepository.hpp"
#include "effects/effectstack/model/effectstackmodel.hpp"
......@@ -1751,10 +1752,13 @@ void TimelineController::changeItemSpeed(int clipId, double speed)
minSpeed = std::max(minSpeed, minSpeed2);
maxSpeed = std::min(maxSpeed, maxSpeed2);
}
speed = QInputDialog::getDouble(QApplication::activeWindow(), i18n("Clip Speed"), i18n("Percentage"), speed, minSpeed, maxSpeed, 2, &ok);
if (!ok) {
// speed = QInputDialog::getDouble(QApplication::activeWindow(), i18n("Clip Speed"), i18n("Percentage"), speed, minSpeed, maxSpeed, 2, &ok);
QScopedPointer<SpeedDialog> d(new SpeedDialog(QApplication::activeWindow(), std::abs(speed), minSpeed, maxSpeed, speed < 0));
if (d->exec() != QDialog::Accepted) {
return;
}
speed = d->getValue();
qDebug() << "requesting speed " << speed;
}
m_model->requestClipTimeWarp(clipId, speed);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SpeedDialog</class>
<widget class="QDialog" name="SpeedDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>399</width>
<height>309</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>240</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>40</x>
<y>40</y>
<width>326</width>
<height>171</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Speed</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Reverse clip</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SpeedDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SpeedDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
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