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
47fcbb2a
Commit
47fcbb2a
authored
Sep 08, 2020
by
Jean-Baptiste Mardelle
Browse files
Fix group move with same track transition
parent
d06ec3cd
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/timeline2/model/timelinemodel.cpp
View file @
47fcbb2a
...
...
@@ -1982,8 +1982,9 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
int
current_in
=
item
.
second
;
int
playtime
=
getClipPlaytime
(
item
.
first
);
int
target_position
=
current_in
+
delta_pos
;
int
subPlaylist
=
m_allClips
[
item
.
first
]
->
getSubPlaylistIndex
();
if
(
delta_pos
<
0
)
{
if
(
!
getTrackById_const
(
current_track_id
)
->
isAvailable
(
target_position
,
playtime
))
{
if
(
!
getTrackById_const
(
current_track_id
)
->
isAvailable
(
target_position
,
-
delta_pos
,
subPlaylist
))
{
if
(
!
getTrackById_const
(
current_track_id
)
->
isBlankAt
(
current_in
-
1
))
{
// No move possible, abort
bool
undone
=
local_undo
();
...
...
@@ -1996,7 +1997,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
}
else
{
int
moveEnd
=
target_position
+
playtime
;
int
moveStart
=
qMax
(
current_in
+
playtime
,
target_position
);
if
(
!
getTrackById_const
(
current_track_id
)
->
isAvailable
(
moveStart
,
moveEnd
-
moveStart
))
{
if
(
!
getTrackById_const
(
current_track_id
)
->
isAvailable
(
moveStart
,
moveEnd
-
moveStart
,
subPlaylist
))
{
int
newStart
=
getTrackById_const
(
current_track_id
)
->
getBlankEnd
(
current_in
+
playtime
);
if
(
newStart
==
current_in
+
playtime
)
{
// No move possible, abort
...
...
@@ -2017,6 +2018,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
int
target_position
=
current_in
+
delta_pos
;
ok
=
requestClipMove
(
item
.
first
,
current_track_id
,
target_position
,
moveMirrorTracks
,
updateThisView
,
finalMove
,
finalMove
,
local_undo
,
local_redo
,
true
);
if
(
!
ok
)
{
qDebug
()
<<
"=== MOVING CLIP ON TK: "
<<
current_track_id
<<
" FAILED!!"
;
break
;
}
}
...
...
src/timeline2/model/trackmodel.cpp
View file @
47fcbb2a
...
...
@@ -998,10 +998,13 @@ bool TrackModel::isLastClip(int position)
return
false
;
}
bool
TrackModel
::
isBlankAt
(
int
position
)
bool
TrackModel
::
isBlankAt
(
int
position
,
int
playlist
)
{
READ_LOCK
();
return
m_playlists
[
0
].
is_blank_at
(
position
)
&&
m_playlists
[
1
].
is_blank_at
(
position
);
if
(
playlist
==
-
1
)
{
return
m_playlists
[
0
].
is_blank_at
(
position
)
&&
m_playlists
[
1
].
is_blank_at
(
position
);
}
return
m_playlists
[
playlist
].
is_blank_at
(
position
);
}
int
TrackModel
::
getBlankStart
(
int
position
)
...
...
@@ -1361,15 +1364,14 @@ void TrackModel::unlock()
}
bool
TrackModel
::
isAvailable
(
int
position
,
int
duration
)
bool
TrackModel
::
isAvailable
(
int
position
,
int
duration
,
int
playlist
)
{
//TODO: warning, does not work on second playlist
int
start_clip
=
m_playlists
[
0
].
get_clip_index_at
(
position
);
int
end_clip
=
m_playlists
[
0
].
get_clip_index_at
(
position
+
duration
-
1
);
int
start_clip
=
m_playlists
[
playlist
].
get_clip_index_at
(
position
);
int
end_clip
=
m_playlists
[
playlist
].
get_clip_index_at
(
position
+
duration
-
1
);
if
(
start_clip
!=
end_clip
)
{
return
false
;
}
return
m_playlists
[
0
].
is_blank
(
start_clip
);
return
m_playlists
[
playlist
].
is_blank
(
start_clip
);
}
bool
TrackModel
::
requestClipMix
(
std
::
pair
<
int
,
int
>
clipIds
,
int
mixDuration
,
bool
updateView
,
bool
finalMove
,
Fun
&
undo
,
Fun
&
redo
,
bool
groupMove
)
...
...
src/timeline2/model/trackmodel.hpp
View file @
47fcbb2a
...
...
@@ -249,7 +249,7 @@ protected:
QSharedPointer
<
Mlt
::
Producer
>
getClipProducer
(
int
clipId
);
/* @brief This is an helper function that checks in all playlists if the given position is a blank */
bool
isBlankAt
(
int
position
);
bool
isBlankAt
(
int
position
,
int
playlist
=
-
1
);
/* @brief This is an helper function that returns the end of the blank that covers given position */
int
getBlankEnd
(
int
position
);
...
...
@@ -289,7 +289,7 @@ protected:
/* @brief Copy effects from anoter effect stack */
bool
copyEffect
(
const
std
::
shared_ptr
<
EffectStackModel
>
&
stackModel
,
int
rowId
);
/* @brief Returns true if we have a blank at position for duration */
bool
isAvailable
(
int
position
,
int
duration
);
bool
isAvailable
(
int
position
,
int
duration
,
int
playlist
);
/* @brief Returns the number of same track transitions (mix) in this track */
int
mixCount
()
const
;
/* @brief Returns true if the track has a same track transition for this clip (cid) */
...
...
tests/mixtest.cpp
View file @
47fcbb2a
...
...
@@ -140,6 +140,11 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
state0
();
REQUIRE
(
timeline
->
mixClip
(
cid4
));
state2
();
// Move clip inside mix zone, should resize the mix
REQUIRE
(
timeline
->
requestClipMove
(
cid4
,
tid2
,
506
));
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
1
);
undoStack
->
undo
();
state2
();
// Move clip outside mix zone, should delete the mix and move it back to playlist 0
REQUIRE
(
timeline
->
requestClipMove
(
cid4
,
tid2
,
600
));
REQUIRE
(
timeline
->
m_allClips
[
cid4
]
->
getSubPlaylistIndex
()
==
0
);
...
...
@@ -153,6 +158,12 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
state0
();
REQUIRE
(
timeline
->
mixClip
(
cid2
));
state1
();
// Move clip inside mix zone, should resize the mix
/*REQUIRE(timeline->requestClipMove(cid2, tid2, 102));
REQUIRE(timeline->getTrackById_const(tid1)->mixCount() == 1);
REQUIRE(timeline->getTrackById_const(tid2)->mixCount() == 1);
undoStack->undo();
state1();*/
// Move clip outside mix zone, should delete the mix
REQUIRE
(
timeline
->
requestClipMove
(
cid2
,
tid2
,
200
));
REQUIRE
(
timeline
->
getTrackById_const
(
tid1
)
->
mixCount
()
==
0
);
...
...
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