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

When selecting a bin clip from timeline, take care of speed in zone selection.

BUG: 425417
parent 7a9a9a03
......@@ -1986,6 +1986,7 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone, b
if (activateMonitor) {
if (frame > -1) {
m_monitor->slotSeek(frame);
m_monitor->refreshMonitorIfActive();
} else {
m_monitor->slotActivateMonitor();
}
......
......@@ -3239,14 +3239,36 @@ void MainWindow::slotClipInProjectTree()
ObjectId id(ObjectType::TimelineClip, ids.constFirst());
int start = pCore->getItemIn(id);
int duration = pCore->getItemDuration(id);
QPoint zone(start, start + duration);
qDebug() << " - - selecting clip on monitor, zone: " << zone;
int pos = m_projectMonitor->position();
int itemPos = pCore->getItemPosition(id);
if (pos >= itemPos && pos < itemPos + duration) {
pos -= (itemPos - start);
} else {
pos = -1;
bool containsPos = (pos >= itemPos && pos < itemPos + duration);
double speed = pCore->getClipSpeed(id.second);
if (containsPos) {
pos -= itemPos - start;
}
if (!qFuzzyCompare(speed, 1.)) {
if (speed > 0.) {
// clip has a speed effect, adjust zone
start = qRound(start * speed);
duration = qRound(duration * speed);
if (containsPos) {
pos = qRound(pos * speed);
}
} else if (speed < 0.) {
int max = getMainTimeline()->controller()->clipMaxDuration(id.second);
if (max > 0) {
int invertedPos = itemPos + duration - m_projectMonitor->position();
start = qRound((max - (start + duration)) * -speed);
duration = qRound(duration * -speed);
if (containsPos) {
pos = start + qRound(invertedPos * -speed);
}
}
}
}
QPoint zone(start, start + duration);
if (!containsPos) {
pos = start;
}
pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), true, pos, zone);
}
......
......@@ -4286,3 +4286,10 @@ void TimelineController::updateMasterZones(QVariantList zones)
emit masterZonesChanged();
}
int TimelineController::clipMaxDuration(int cid)
{
if (!m_model->isClip(cid)) {
return -1;
}
return m_model->m_allClips[cid]->getMaxDuration();
}
......@@ -622,6 +622,8 @@ public:
void showRulerEffectZone(QPair <int, int>inOut, bool checked);
/** @brief Set the list of master effect zones */
void updateMasterZones(QVariantList zones);
/** @brief get Maximum duration of a clip */
int clipMaxDuration(int cid);
public slots:
void resetView();
......
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