Improvements to composition duration on drop.

Related to #503
parent 379efc4e
......@@ -101,7 +101,7 @@
<entry name="transition_duration" type="String">
<label>Default transition duration.</label>
<default>00:00:01:00</default>
<default>00:00:03:00</default>
</entry>
<entry name="disable_effect_parameters" type="Bool">
......
......@@ -341,15 +341,15 @@ Rectangle {
var track = Logic.getTrackIdFromPos(drag.y + scrollView.flickableItem.contentY)
if (track !=-1) {
var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor)
frame = controller.suggestSnapPoint(frame, Math.floor(root.snapping))
if (clipBeingDroppedId >= 0){
if (controller.isAudioTrack(track)) {
// Don't allow moving composition to an audio track
track = controller.getCompositionTrackId(clipBeingDroppedId)
}
controller.requestCompositionMove(clipBeingDroppedId, track, frame, true, false)
controller.suggestCompositionMove(clipBeingDroppedId, track, frame, root.consumerPosition, Math.floor(root.snapping))
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
} else if (!controller.isAudioTrack(track)) {
frame = controller.suggestSnapPoint(frame, Math.floor(root.snapping))
clipBeingDroppedData = drag.getDataAsString('kdenlive/composition')
clipBeingDroppedId = timeline.insertComposition(track, frame, clipBeingDroppedData , false)
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
......@@ -445,7 +445,7 @@ Rectangle {
if (track >= 0 && track < tracksRepeater.count) {
timeline.activeTrack = tracksRepeater.itemAt(track).trackInternalId
var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor)
if (clipBeingDroppedId >= 0){
if (clipBeingDroppedId >= 0) {
fakeFrame = controller.suggestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, root.consumerPosition, Math.floor(root.snapping))
fakeTrack = timeline.activeTrack
//controller.requestClipMove(clipBeingDroppedId, timeline.activeTrack, frame, true, false, false)
......
......@@ -353,36 +353,45 @@ int TimelineController::insertNewComposition(int tid, int clipId, int offset, co
int clip_duration = m_model->getClipPlaytime(clipId);
int endPos = minimumPos + clip_duration;
int position = minimumPos;
int duration = qMin(pCore->currentDoc()->getFramePos(KdenliveSettings::transition_duration()), m_model->getTrackById_const(tid)->suggestCompositionLength(position));
int duration = qMin(clip_duration, pCore->currentDoc()->getFramePos(KdenliveSettings::transition_duration()));
int lowerVideoTrackId = m_model->getPreviousVideoTrackIndex(tid);
bool revert = offset > clip_duration / 2;
int bottomId = 0;
if (lowerVideoTrackId > 0) {
int bottomId = m_model->getTrackById_const(lowerVideoTrackId)->getClipByPosition(position + offset);
if (bottomId > 0) {
QPair<int, int> bottom(m_model->m_allClips[bottomId]->getPosition(), m_model->m_allClips[bottomId]->getPlaytime());
if (bottom.first > minimumPos) {
// Lower clip is after top clip
if (position + offset > bottom.first) {
int test_duration = m_model->getTrackById_const(tid)->suggestCompositionLength(bottom.first);
if (test_duration > 0) {
offset -= (bottom.first - position);
position = bottom.first;
duration = test_duration;
revert = position > minimumPos;
}
}
} else if (position >= bottom.first) {
// Lower clip is before or at same pos as top clip
int test_duration = m_model->getTrackById_const(lowerVideoTrackId)->suggestCompositionLength(position);
bottomId = m_model->getTrackById_const(lowerVideoTrackId)->getClipByPosition(position + offset);
}
if (bottomId <= 0) {
// No video track underneath
if (offset < duration && duration < 2 * clip_duration) {
// Composition dropped close to start, keep default composition duration
} else if (clip_duration - offset < duration * 1.2 && duration < 2 * clip_duration) {
// Composition dropped close to end, keep default composition duration
position = endPos - duration;
} else {
// Use full clip length for duration
duration = m_model->getTrackById_const(tid)->suggestCompositionLength(position);
}
} else {
duration = qMin(duration, m_model->getTrackById_const(tid)->suggestCompositionLength(position));
QPair<int, int> bottom(m_model->m_allClips[bottomId]->getPosition(), m_model->m_allClips[bottomId]->getPlaytime());
if (bottom.first > minimumPos) {
// Lower clip is after top clip
if (position + offset > bottom.first) {
int test_duration = m_model->getTrackById_const(tid)->suggestCompositionLength(bottom.first);
if (test_duration > 0) {
duration = qMin(test_duration, clip_duration);
offset -= (bottom.first - position);
position = bottom.first;
duration = test_duration;
revert = position > minimumPos;
}
}
} else {
qDebug()<<"///// NO CLIP FOUND BELOW!!!";
} else if (position >= bottom.first) {
// Lower clip is before or at same pos as top clip
int test_duration = m_model->getTrackById_const(lowerVideoTrackId)->suggestCompositionLength(position);
if (test_duration > 0) {
duration = qMin(test_duration, clip_duration);
}
}
} else {
qDebug()<<"///// NO TRACK FOUND BELOW!!!";
}
if (duration < 0) {
duration = pCore->currentDoc()->getFramePos(KdenliveSettings::transition_duration());
......
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