Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
b2e2abb2
Commit
b2e2abb2
authored
Jul 23, 2021
by
Jean-Baptiste Mardelle
Browse files
Fix various mix move issues
parent
9c198b20
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/timeline2/model/timelinemodel.cpp
View file @
b2e2abb2
...
...
@@ -663,17 +663,30 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
Fun
simple_move_mix
=
[]()
{
return
true
;
};
Fun
simple_restore_mix
=
[]()
{
return
true
;
};
QList
<
int
>
allowedClipMixes
;
if
(
!
groupMove
&&
old_trackId
>
-
1
)
{
mixData
=
getTrackById_const
(
old_trackId
)
->
getMixInfo
(
clipId
);
}
bool
hadMix
=
mixData
.
first
.
firstClipId
>
-
1
||
mixData
.
second
.
secondClipId
>
-
1
;
if
(
old_trackId
==
-
1
&&
isTrack
(
previous_track
)
&&
hadMix
&&
previous_track
!=
trackId
)
{
// Clip is moved to another track
bool
mixGroupMove
=
false
;
if
(
mixData
.
first
.
firstClipId
>
0
)
{
allowedClipMixes
<<
mixData
.
first
.
firstClipId
;
if
(
moving_clips
.
contains
(
mixData
.
first
.
firstClipId
))
{
allowedClipMixes
<<
mixData
.
first
.
firstClipId
;
}
else
if
(
finalMove
)
{
removeMixWithUndo
(
clipId
,
local_undo
,
local_redo
);
}
}
if
(
mixData
.
second
.
firstClipId
>
0
)
{
allowedClipMixes
<<
mixData
.
second
.
secondClipId
;
if
(
moving_clips
.
contains
(
mixData
.
second
.
secondClipId
))
{
allowedClipMixes
<<
mixData
.
second
.
secondClipId
;
}
else
if
(
finalMove
)
{
removeMixWithUndo
(
mixData
.
second
.
secondClipId
,
local_undo
,
local_redo
);
}
}
if
(
m_groups
->
isInGroup
(
clipId
))
{
if
(
m_groups
->
isInGroup
(
clipId
)
&&
mixData
.
first
.
firstClipId
>
0
)
{
int
parentGroup
=
m_groups
->
getRootId
(
clipId
);
if
(
parentGroup
>
-
1
)
{
std
::
unordered_set
<
int
>
sub
=
m_groups
->
getLeaves
(
parentGroup
);
...
...
@@ -684,19 +697,18 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
}
if
(
mixGroupMove
)
{
// We are moving a group on another track, delete and re-add
// Get mix properties
std
::
pair
<
QString
,
QVector
<
QPair
<
QString
,
QVariant
>>>
mixParams
=
getTrackById_const
(
previous_track
)
->
getMixParams
(
mixData
.
first
.
secondClipId
);
simple_move_mix
=
[
this
,
previous_track
,
trackId
,
finalMove
,
mixData
,
mixParams
]()
{
// Get mix properties
std
::
pair
<
QString
,
QVector
<
QPair
<
QString
,
QVariant
>>>
mixParams
=
getTrackById_const
(
previous_track
)
->
getMixParams
(
mixData
.
first
.
secondClipId
);
// Remove mix on old track
getTrackById_const
(
previous_track
)
->
syncronizeMixes
(
finalMove
);
// Insert mix on new track
bool
result
=
getTrackById_const
(
trackId
)
->
createMix
(
mixData
.
first
,
mixParams
,
finalMove
);
// Remove mix on old track
getTrackById_const
(
previous_track
)
->
syncronizeMixes
(
finalMove
);
return
result
;
};
simple_restore_mix
=
[
this
,
previous_track
,
trackId
,
finalMove
,
mixData
,
mixParams
]()
{
getTrackById_const
(
trackId
)
->
syncronizeMixes
(
finalMove
);
bool
result
=
getTrackById_const
(
previous_track
)
->
createMix
(
mixData
.
first
,
mixParams
,
finalMove
);
getTrackById_const
(
trackId
)
->
syncronizeMixes
(
finalMove
);
return
result
;
};
}
...
...
@@ -705,14 +717,9 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
if
(
mixData
.
first
.
firstClipId
>
-
1
)
{
if
(
old_trackId
==
trackId
)
{
// We are moving a clip on same track
if
(
finalMove
&&
position
>=
mixData
.
first
.
firstClipInOut
.
second
)
{
if
(
position
>=
mixData
.
first
.
firstClipInOut
.
second
)
{
position
+=
m_allClips
[
clipId
]
->
getMixDuration
()
-
m_allClips
[
clipId
]
->
getMixCutPosition
();
removeMixWithUndo
(
clipId
,
local_undo
,
local_redo
);
if
(
mixData
.
first
.
firstClipId
>
0
)
{
if
(
moving_clips
.
contains
(
mixData
.
first
.
firstClipId
))
{
allowedClipMixes
<<
mixData
.
first
.
firstClipId
;
}
}
}
}
else
{
// Clip moved to another track, delete mix
...
...
@@ -721,11 +728,6 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
}
if
(
mixData
.
second
.
firstClipId
>
-
1
)
{
// We have a mix at clip end
if
(
mixData
.
second
.
firstClipId
>
0
)
{
if
(
moving_clips
.
contains
(
mixData
.
second
.
firstClipId
))
{
allowedClipMixes
<<
mixData
.
second
.
secondClipId
;
}
}
int
clipDuration
=
mixData
.
second
.
firstClipInOut
.
second
-
mixData
.
second
.
firstClipInOut
.
first
;
sync_mix
=
[
this
,
old_trackId
,
finalMove
]()
{
getTrackById_const
(
old_trackId
)
->
syncronizeMixes
(
finalMove
);
...
...
@@ -770,9 +772,6 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
}
}
}
if
(
finalMove
)
{
PUSH_LAMBDA
(
sync_mix
,
local_undo
);
}
if
(
old_trackId
!=
-
1
)
{
if
(
notifyViewOnly
)
{
PUSH_LAMBDA
(
update_model
,
local_undo
);
...
...
@@ -794,10 +793,10 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
sync_mix
();
update_model
();
simple_move_mix
();
PUSH_LAMBDA
(
simple_restore_mix
,
local_undo
);
PUSH_LAMBDA
(
simple_move_mix
,
local_redo
);
if
(
finalMove
)
{
PUSH_LAMBDA
(
sync_mix
,
local_redo
);
PUSH_LAMBDA
(
simple_restore_mix
,
undo
);
PUSH_LAMBDA
(
simple_move_mix
,
local_redo
);
//PUSH_LAMBDA(sync_mix, local_redo);
}
if
(
notifyViewOnly
)
{
PUSH_LAMBDA
(
update_model
,
local_redo
);
...
...
src/timeline2/model/trackmodel.cpp
View file @
b2e2abb2
...
...
@@ -2060,6 +2060,7 @@ bool TrackModel::createMix(MixInfo info, std::pair<QString,QVector<QPair<QString
{
if
(
m_sameCompositions
.
count
(
info
.
secondClipId
)
>
0
)
{
// Clip already has a mix
Q_ASSERT
(
false
);
return
false
;
}
if
(
auto
ptr
=
m_parent
.
lock
())
{
...
...
@@ -2067,8 +2068,9 @@ bool TrackModel::createMix(MixInfo info, std::pair<QString,QVector<QPair<QString
std
::
shared_ptr
<
ClipModel
>
movedClip
(
ptr
->
getClipPtr
(
info
.
secondClipId
));
int
in
=
movedClip
->
getPosition
();
//int out = in + info.firstClipInOut.second - info.secondClipInOut.first;
int
out
=
in
+
movedClip
->
getMixDuration
();
movedClip
->
setMixDuration
(
out
-
in
);
int
duration
=
info
.
firstClipInOut
.
second
-
info
.
secondClipInOut
.
first
;
int
out
=
in
+
duration
;
movedClip
->
setMixDuration
(
duration
);
std
::
unique_ptr
<
Mlt
::
Transition
>
t
;
const
QString
assetId
=
params
.
first
;
t
=
std
::
make_unique
<
Mlt
::
Transition
>
(
*
ptr
->
getProfile
(),
assetId
.
toUtf8
().
constData
());
...
...
@@ -2098,6 +2100,7 @@ bool TrackModel::createMix(MixInfo info, std::pair<QString,QVector<QPair<QString
}
return
true
;
}
qDebug
()
<<
"== COULD NOT PLANT MIX; TRACK UNAVAILABLE"
;
return
false
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment