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

Fix marker position on clip cuts with speed effect.

Don't allow a speed of 0.
Related to #193
parent f37c1d8e
Pipeline #3682 passed with stage
in 23 minutes and 53 seconds
......@@ -31,22 +31,22 @@ ClipSnapModel::ClipSnapModel() = default;
void ClipSnapModel::addPoint(int position)
{
m_snapPoints.insert(position);
if (position <= m_inPoint || position >= m_outPoint) {
if (position <= m_inPoint * m_speed || position >= m_outPoint * m_speed) {
return;
}
if (auto ptr = m_registeredSnap.lock()) {
ptr->addPoint(m_speed < 0 ? m_outPoint + m_position + (position - m_inPoint) / m_speed : m_position + (position - m_inPoint) / m_speed);
ptr->addPoint(m_speed < 0 ? m_outPoint + m_position + position / m_speed - m_inPoint : m_position + position / m_speed - m_inPoint);
}
}
void ClipSnapModel::removePoint(int position)
{
m_snapPoints.erase(position);
if (position <= m_inPoint || position >= m_outPoint) {
if (position <= m_inPoint * m_speed || position >= m_outPoint * m_speed) {
return;
}
if (auto ptr = m_registeredSnap.lock()) {
ptr->removePoint(m_speed < 0 ? m_outPoint + m_position + (position - m_inPoint) / m_speed : m_position + (position - m_inPoint) / m_speed);
ptr->removePoint(m_speed < 0 ? m_outPoint + m_position + position / m_speed - m_inPoint : m_position + position / m_speed - m_inPoint);
}
}
......@@ -73,7 +73,7 @@ void ClipSnapModel::addAllSnaps()
if (auto ptr = m_registeredSnap.lock()) {
for (const auto &snap : m_snapPoints) {
if (snap >= m_inPoint * m_speed && snap < m_outPoint * m_speed) {
ptr->addPoint(m_speed < 0 ? m_outPoint + m_position + (snap - m_inPoint) / m_speed : m_position + (snap - m_inPoint) / m_speed);
ptr->addPoint(m_speed < 0 ? m_outPoint + m_position + snap / m_speed - m_inPoint : m_position + snap / m_speed- m_inPoint);
}
}
}
......@@ -84,7 +84,7 @@ void ClipSnapModel::removeAllSnaps()
if (auto ptr = m_registeredSnap.lock()) {
for (const auto &snap : m_snapPoints) {
if (snap >= m_inPoint * m_speed && snap < m_outPoint * m_speed) {
ptr->removePoint(m_speed < 0 ? m_outPoint + m_position + (snap - m_inPoint) / m_speed : m_position + (snap - m_inPoint) / m_speed);
ptr->removePoint(m_speed < 0 ? m_outPoint + m_position + snap / m_speed - m_inPoint : m_position + snap / m_speed- m_inPoint);
}
}
}
......
#include "speeddialog.h"
#include "ui_speeddialog_ui.h"
#include <QPushButton>
SpeedDialog::SpeedDialog(QWidget *parent, double speed, double minSpeed, double maxSpeed, bool reversed)
: QDialog(parent)
......@@ -11,9 +12,13 @@ SpeedDialog::SpeedDialog(QWidget *parent, double speed, double minSpeed, double
ui->doubleSpinBox->setMinimum(minSpeed);
ui->doubleSpinBox->setMaximum(maxSpeed);
ui->doubleSpinBox->setValue(speed);
ui->doubleSpinBox->selectAll();
if (reversed) {
ui->checkBox->setChecked(true);
}
connect(ui->doubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [&] (double value) {
ui->buttonBox->button((QDialogButtonBox::Ok))->setEnabled(!qFuzzyIsNull(value));
});
}
SpeedDialog::~SpeedDialog()
......
......@@ -410,7 +410,7 @@ Rectangle {
id: markerBase
width: 1
height: parent.height
x: clipRoot.speed < 0 ? clipRoot.clipDuration * timeScale + (model.frame - (clipRoot.maxDuration - clipRoot.outPoint)) * timeScale / clipRoot.speed : (model.frame - clipRoot.inPoint) * timeScale / clipRoot.speed;
x: clipRoot.speed < 0 ? clipRoot.clipDuration * timeScale + (model.frame / clipRoot.speed - (clipRoot.maxDuration - clipRoot.outPoint)) * timeScale : (model.frame / clipRoot.speed - clipRoot.inPoint) * timeScale;
color: model.color
}
Rectangle {
......
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