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
d06ec3cd
Commit
d06ec3cd
authored
Sep 07, 2020
by
Jean-Baptiste Mardelle
Browse files
More fixes and tests for moving a clip with same track transition
parent
2ea5bdcd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/timeline2/model/timelinemodel.cpp
View file @
d06ec3cd
...
...
@@ -611,40 +611,46 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
}
Fun
move_mix
=
[]()
{
return
true
;
};
Fun
restore_mix
=
[]()
{
return
true
;
};
Fun
update_mix
=
[]()
{
return
true
;
};
if
(
isTrack
(
old_trackId
)
&&
getTrackById_const
(
old_trackId
)
->
hasMix
(
clipId
))
{
std
::
pair
<
MixInfo
,
MixInfo
>
mixData
=
getTrackById_const
(
old_trackId
)
->
getMixInfo
(
clipId
);
if
(
mixData
.
first
.
firstClipId
>
-
1
)
{
update_mix
=
[
this
,
mixData
]()
{
QModelIndex
ix
=
makeClipIndexFromID
(
mixData
.
first
.
secondClipId
);
emit
dataChanged
(
ix
,
ix
,
{
TimelineModel
::
StartRole
,
TimelineModel
::
MixRole
});
return
true
;
};
// We have a mix at clip start
if
(
old_trackId
!=
trackId
||
position
>=
mixData
.
first
.
firstClipInOut
.
second
)
{
// Clip moved to another track, or outside of mix duration, delete mix
move_mix
=
[
this
,
old_trackId
,
clipId
,
finalMove
]()
{
int
subPlaylist
=
m_allClips
[
clipId
]
->
getSubPlaylistIndex
();
move_mix
=
[
this
,
old_trackId
,
clipId
,
finalMove
,
subPlaylist
]()
{
bool
result
=
getTrackById_const
(
old_trackId
)
->
deleteMix
(
clipId
,
finalMove
);
qDebug
()
<<
"======
\n
RESETTING SUB PLAYLIST, RESULT: "
<<
result
<<
"
\n
===="
;
if
(
finalMove
)
{
m_allClips
[
clipId
]
->
setSubPlaylistIndex
(
subPlaylist
==
0
?
1
:
0
);
}
return
result
;
};
restore_mix
=
[
this
,
old_trackId
,
mixData
]()
{
qDebug
()
<<
"================0
\n
START RESTORING MIX
\n\n
================"
;
m_allClips
[
mixData
.
first
.
secondClipId
]
->
setSubPlaylistIndex
(
1
);
restore_mix
=
[
this
,
old_trackId
,
mixData
,
finalMove
,
subPlaylist
]()
{
if
(
finalMove
)
{
m_allClips
[
mixData
.
first
.
secondClipId
]
->
setSubPlaylistIndex
(
subPlaylist
);
}
bool
result
=
getTrackById_const
(
old_trackId
)
->
createMix
({
mixData
.
first
.
firstClipId
,
mixData
.
first
.
secondClipId
},
{
mixData
.
first
.
secondClipInOut
.
first
,
mixData
.
first
.
firstClipInOut
.
second
-
mixData
.
first
.
secondClipInOut
.
first
});
qDebug
()
<<
"====================
\n
CREATED MIX ON UNDO: "
<<
result
<<
"
\n\n
========"
;
return
result
;
};
}
else
if
(
old_trackId
==
trackId
)
{
// Clip moved on same track, resize mix
move_mix
=
[
this
,
old_trackId
,
clipId
,
position
]()
{
qDebug
()
<<
"================0
\n
MIX RESIZE PROCESS 1
\n\n
================"
;
return
getTrackById_const
(
old_trackId
)
->
resizeMixStart
(
clipId
,
position
);
};
restore_mix
=
[
this
,
old_trackId
,
clipId
,
mixData
]()
{
// Resize mix to oringinal start
qDebug
()
<<
"================0
\n
MIX RESIZE PROCESS 2
\n\n
================"
;
return
getTrackById_const
(
old_trackId
)
->
resizeMixStart
(
clipId
,
mixData
.
first
.
secondClipInOut
.
first
);
};
}
move_mix
();
UPDATE_UNDO_REDO
(
move_mix
,
restore_mix
,
local_undo
,
local_redo
);
}
}
PUSH_LAMBDA
(
update_mix
,
local_undo
);
if
(
old_trackId
!=
-
1
)
{
if
(
notifyViewOnly
)
{
PUSH_LAMBDA
(
update_model
,
local_undo
);
...
...
@@ -656,6 +662,8 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
return
false
;
}
}
move_mix
();
UPDATE_UNDO_REDO
(
move_mix
,
restore_mix
,
local_undo
,
local_redo
);
ok
=
getTrackById
(
trackId
)
->
requestClipInsertion
(
clipId
,
position
,
updateView
,
finalMove
,
local_undo
,
local_redo
,
groupMove
);
if
(
!
ok
)
{
qDebug
()
<<
"-------------
\n\n
INSERTION FAILED, REVERTING
\n\n
-------------------"
;
...
...
@@ -664,8 +672,10 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
return
false
;
}
update_model
();
update_mix
();
if
(
notifyViewOnly
)
{
PUSH_LAMBDA
(
update_model
,
local_redo
);
PUSH_LAMBDA
(
update_mix
,
local_redo
);
}
UPDATE_UNDO_REDO
(
local_redo
,
local_undo
,
undo
,
redo
);
return
true
;
...
...
src/timeline2/model/trackmodel.cpp
View file @
d06ec3cd
...
...
@@ -320,14 +320,14 @@ Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView, bool fin
ptr
->
requestClearSelection
(
true
);
}
}
auto
clip_loc
=
getClipIndexAt
(
clip_position
,
m_allClips
[
clipId
]
->
getSubPlaylistIndex
());
int
target_track
=
m_allClips
[
clipId
]
->
getSubPlaylistIndex
();
auto
clip_loc
=
getClipIndexAt
(
clip_position
,
target_track
);
if
(
updateView
)
{
int
old_clip_index
=
getRowfromClip
(
clipId
);
auto
ptr
=
m_parent
.
lock
();
ptr
->
_beginRemoveRows
(
ptr
->
makeTrackIndexFromID
(
getId
()),
old_clip_index
,
old_clip_index
);
ptr
->
_endRemoveRows
();
}
int
target_track
=
m_allClips
[
clipId
]
->
getSubPlaylistIndex
();
int
target_clip
=
clip_loc
.
second
;
// lock MLT playlist so that we don't end up with invalid frames in monitor
m_playlists
[
target_track
].
lock
();
...
...
@@ -1572,8 +1572,6 @@ bool TrackModel::createMix(std::pair<int, int> clipIds, std::pair<int, int> mixD
if
(
auto
ptr
=
m_parent
.
lock
())
{
std
::
shared_ptr
<
ClipModel
>
movedClip
(
ptr
->
getClipPtr
(
clipIds
.
second
));
movedClip
->
setMixDuration
(
mixData
.
second
);
QModelIndex
ix
=
ptr
->
makeClipIndexFromID
(
clipIds
.
second
);
emit
ptr
->
dataChanged
(
ix
,
ix
,
{
TimelineModel
::
StartRole
,
TimelineModel
::
MixRole
});
// Insert mix transition
if
(
isAudioTrack
())
{
std
::
shared_ptr
<
Mlt
::
Transition
>
t
(
new
Mlt
::
Transition
(
*
ptr
->
getProfile
(),
"mix"
));
...
...
tests/mixtest.cpp
View file @
d06ec3cd
...
...
@@ -82,6 +82,7 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
REQUIRE
(
timeline
->
getClipPlaytime
(
cid3
)
==
20
);
REQUIRE
(
timeline
->
getClipPosition
(
cid4
)
==
520
);
REQUIRE
(
timeline
->
getClipPlaytime
(
cid4
)
==
20
);
REQUIRE
(
timeline
->
m_allClips
[
cid4
]
->
getSubPlaylistIndex
()
==
0
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid1
)
->
mixCount
()
==
0
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
0
);
};
...
...
@@ -102,6 +103,7 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
REQUIRE
(
timeline
->
getClipPosition
(
cid3
)
==
500
);
REQUIRE
(
timeline
->
getClipPlaytime
(
cid4
)
>
20
);
REQUIRE
(
timeline
->
getClipPosition
(
cid4
)
<
520
);
REQUIRE
(
timeline
->
m_allClips
[
cid4
]
->
getSubPlaylistIndex
()
==
1
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid1
)
->
mixCount
()
==
0
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
1
);
};
...
...
@@ -110,6 +112,7 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
{
state0
();
REQUIRE
(
timeline
->
mixClip
(
cid4
));
state2
();
undoStack
->
undo
();
state0
();
...
...
@@ -136,17 +139,16 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
{
state0
();
REQUIRE
(
timeline
->
mixClip
(
cid4
));
qDebug
()
<<
"==========MIX COLOR DONE; CHECKING STATE"
;
state2
();
// Move clip outside mix zone, should delete the mix
// 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
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
0
);
qDebug
()
<<
"==========MIX COLOR STARTING UNDO"
;
undoStack
->
undo
();
state2
();
}
/*
SECTION("Create mix and move AV clips")
SECTION
(
"Create mix and move AV clips"
)
{
state0
();
REQUIRE
(
timeline
->
mixClip
(
cid2
));
...
...
@@ -155,7 +157,7 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
REQUIRE
(
timeline
->
requestClipMove
(
cid2
,
tid2
,
200
));
REQUIRE
(
timeline
->
getTrackById_const
(
tid1
)
->
mixCount
()
==
0
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
0
);
}
*/
}
binModel
->
clean
();
pCore
->
m_projectManager
=
nullptr
;
Logger
::
print_trace
();
...
...
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