Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
a7c7e98d
Commit
a7c7e98d
authored
Oct 18, 2020
by
Jean-Baptiste Mardelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests, improve mix behavior with resize undo/redo
parent
97503c9b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
18 deletions
+26
-18
src/timeline2/model/timelinemodel.cpp
src/timeline2/model/timelinemodel.cpp
+17
-10
src/timeline2/model/timelinemodel.hpp
src/timeline2/model/timelinemodel.hpp
+2
-1
src/timeline2/view/qml/Clip.qml
src/timeline2/view/qml/Clip.qml
+1
-1
tests/mixtest.cpp
tests/mixtest.cpp
+6
-6
No files found.
src/timeline2/model/timelinemodel.cpp
View file @
a7c7e98d
...
...
@@ -2719,13 +2719,19 @@ int TimelineModel::requestItemSpeedChange(int itemId, int size, bool right, int
return
proposed_size
>
0
?
proposed_size
:
size
;
}
bool
TimelineModel
::
removeMix
(
int
cid
)
bool
TimelineModel
::
removeMix
WithUndo
(
int
cid
,
Fun
&
undo
,
Fun
&
redo
)
{
Fun
undo
=
[]()
{
return
true
;
};
Fun
redo
=
[]()
{
return
true
;
};
int
tid
=
getItemTrackId
(
cid
);
MixInfo
mixData
=
getTrackById_const
(
tid
)
->
getMixInfo
(
cid
).
first
;
bool
res
=
getTrackById
(
tid
)
->
requestRemoveMix
({
mixData
.
firstClipId
,
mixData
.
secondClipId
},
undo
,
redo
);
return
res
;
}
bool
TimelineModel
::
removeMix
(
int
cid
)
{
Fun
undo
=
[]()
{
return
true
;
};
Fun
redo
=
[]()
{
return
true
;
};
bool
res
=
removeMixWithUndo
(
cid
,
undo
,
redo
);
if
(
res
)
{
PUSH_UNDO
(
undo
,
redo
,
i18n
(
"Remove mix"
));
}
else
{
...
...
@@ -2767,11 +2773,12 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
std
::
pair
<
MixInfo
,
MixInfo
>
mixData
=
getTrackById_const
(
tid
)
->
getMixInfo
(
itemId
);
if
(
in
+
size
<=
mixData
.
second
.
secondClipInOut
.
first
+
m_allClips
[
mixData
.
second
.
secondClipId
]
->
getMixDuration
()
-
m_allClips
[
mixData
.
second
.
secondClipId
]
->
getMixCutPosition
())
{
// Clip resized outside of mix zone, mix will be deleted
bool
res
=
removeMix
(
mixData
.
second
.
secondClipId
);
bool
res
=
removeMix
WithUndo
(
mixData
.
second
.
secondClipId
,
undo
,
redo
);
if
(
res
)
{
return
m_allClips
[
itemId
]
->
getPlaytime
();
size
=
m_allClips
[
itemId
]
->
getPlaytime
();
}
else
{
return
-
1
;
}
return
-
1
;
}
else
{
// Mix was resized, update cut position
int
currentMixDuration
=
m_allClips
[
mixData
.
second
.
secondClipId
]
->
getMixDuration
();
...
...
@@ -2818,7 +2825,6 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
}
}
}
if
(
!
allowSingleResize
&&
m_groups
->
isInGroup
(
itemId
))
{
int
groupId
=
m_groups
->
getRootId
(
itemId
);
std
::
unordered_set
<
int
>
items
=
m_groups
->
getLeaves
(
groupId
);
...
...
@@ -2851,8 +2857,9 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
tracksWithMixes
<<
tid
;
}
std
::
pair
<
MixInfo
,
MixInfo
>
mixData
=
getTrackById_const
(
tid
)
->
getMixInfo
(
id
);
if
(
end
-
offset
<=
mixData
.
second
.
secondClipInOut
.
first
)
{
if
(
end
-
offset
<=
mixData
.
second
.
secondClipInOut
.
first
+
m_allClips
[
mixData
.
second
.
secondClipId
]
->
getMixDuration
()
-
m_allClips
[
mixData
.
second
.
secondClipId
]
->
getMixCutPosition
()
)
{
// Resized outside mix
bool
res
=
removeMixWithUndo
(
mixData
.
second
.
secondClipId
,
undo
,
redo
);
Fun
sync_mix_undo
=
[
this
,
tid
,
mixData
]()
{
getTrackById_const
(
tid
)
->
createMix
(
mixData
.
second
,
getTrackById_const
(
tid
)
->
isAudioTrack
());
getTrackById_const
(
tid
)
->
syncronizeMixes
(
true
);
...
...
@@ -4925,7 +4932,7 @@ void TimelineModel::plantMix(int tid, Mlt::Transition *t)
getTrackById_const
(
tid
)
->
loadMix
(
t
);
}
bool
TimelineModel
::
resizeStartMix
(
int
cid
,
int
duration
)
bool
TimelineModel
::
resizeStartMix
(
int
cid
,
int
duration
,
bool
singleResize
)
{
Q_ASSERT
(
isClip
(
cid
));
int
tid
=
m_allClips
[
cid
]
->
getCurrentTrackId
();
...
...
@@ -4935,7 +4942,7 @@ bool TimelineModel::resizeStartMix(int cid, int duration)
int
clipToResize
=
mixData
.
first
.
firstClipId
;
Q_ASSERT
(
isClip
(
clipToResize
));
int
updatedDuration
=
m_allClips
[
cid
]
->
getPosition
()
+
duration
-
m_allClips
[
clipToResize
]
->
getPosition
();
int
result
=
requestItemResize
(
clipToResize
,
updatedDuration
,
true
,
true
,
0
,
fals
e
);
int
result
=
requestItemResize
(
clipToResize
,
updatedDuration
,
true
,
true
,
0
,
singleResiz
e
);
return
result
>
-
1
;
}
}
...
...
src/timeline2/model/timelinemodel.hpp
View file @
a7c7e98d
...
...
@@ -424,6 +424,7 @@ public:
/** @brief Plant a same track composition in track tid
*/
void
plantMix
(
int
tid
,
Mlt
::
Transition
*
t
);
bool
removeMixWithUndo
(
int
cid
,
Fun
&
undo
,
Fun
&
redo
);
bool
removeMix
(
int
cid
);
protected:
...
...
@@ -705,7 +706,7 @@ public:
void
importMasterEffects
(
std
::
weak_ptr
<
Mlt
::
Service
>
service
);
/** @brief Create a mix selection with currently selected clip. If delta = -1, mix with previous clip, +1 with next clip and 0 will check cursor position*/
bool
mixClip
(
int
idToMove
=
-
1
,
int
delta
=
0
);
Q_INVOKABLE
bool
resizeStartMix
(
int
cid
,
int
duration
);
Q_INVOKABLE
bool
resizeStartMix
(
int
cid
,
int
duration
,
bool
singleResize
);
protected:
/* @brief Register a new track. This is a call-back meant to be called from TrackModel
...
...
src/timeline2/view/qml/Clip.qml
View file @
a7c7e98d
...
...
@@ -418,7 +418,7 @@ Rectangle {
mixCutPos
.
anchors
.
right
=
undefined
}
onReleased
:
{
controller
.
resizeStartMix
(
clipRoot
.
clipId
,
Math
.
round
(
Math
.
max
(
0
,
x
)
/
clipRoot
.
timeScale
))
controller
.
resizeStartMix
(
clipRoot
.
clipId
,
Math
.
round
(
Math
.
max
(
0
,
x
)
/
clipRoot
.
timeScale
)
,
mouse
.
modifiers
&
Qt
.
ShiftModifier
)
root
.
autoScrolling
=
timeline
.
autoScroll
if
(
sizeChanged
)
{
sizeChanged
=
false
...
...
tests/mixtest.cpp
View file @
a7c7e98d
...
...
@@ -265,19 +265,19 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
SECTION
(
"Create mix on color clip and resize"
)
{
state0
();
REQUIRE
(
timeline
->
mixClip
(
cid4
));
state2
();
// CID 3 length=20, pos=500, CID4 length=20, pos=520
// Default mix duration = 25 frames (12 before / 13 after)
REQUIRE
(
timeline
->
mixClip
(
cid4
));
state2
();
// Resize left clip, should resize the mix
REQUIRE
(
timeline
->
requestItemResize
(
cid3
,
16
,
true
,
true
)
==
16
);
REQUIRE
(
timeline
->
requestItemResize
(
cid3
,
24
,
true
,
true
)
==
24
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
1
);
REQUIRE
(
timeline
->
m_allClips
[
cid3
]
->
getSubPlaylistIndex
()
==
0
);
REQUIRE
(
timeline
->
m_allClips
[
cid4
]
->
getSubPlaylistIndex
()
==
1
);
undoStack
->
undo
();
state2
();
// Resize left clip outside mix zone, should delete the mix
REQUIRE
(
timeline
->
requestItemResize
(
cid3
,
4
,
true
,
true
)
==
4
);
REQUIRE
(
timeline
->
requestItemResize
(
cid3
,
4
,
true
,
true
)
==
20
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
0
);
REQUIRE
(
timeline
->
m_allClips
[
cid3
]
->
getSubPlaylistIndex
()
==
0
);
REQUIRE
(
timeline
->
m_allClips
[
cid4
]
->
getSubPlaylistIndex
()
==
0
);
...
...
@@ -317,7 +317,7 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
// CID 1 length=30, pos=100, CID2 length=30, pos=130
// Default mix duration = 25 frames (12 before / 13 after)
// Resize left clip, should resize the mix
REQUIRE
(
timeline
->
requestItemResize
(
cid1
,
25
,
true
,
true
)
==
2
5
);
REQUIRE
(
timeline
->
requestItemResize
(
cid1
,
35
,
true
,
true
)
==
3
5
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
1
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid3
)
->
mixCount
()
==
1
);
REQUIRE
(
timeline
->
m_allClips
[
cid1
]
->
getSubPlaylistIndex
()
==
0
);
...
...
@@ -325,7 +325,7 @@ TEST_CASE("Simple Mix", "[SameTrackMix]")
undoStack
->
undo
();
state3
();
// Resize left clip outside mix zone, should delete the mix
REQUIRE
(
timeline
->
requestItemResize
(
cid1
,
10
,
true
,
true
)
==
1
0
);
REQUIRE
(
timeline
->
requestItemResize
(
cid1
,
10
,
true
,
true
)
==
3
0
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid2
)
->
mixCount
()
==
0
);
REQUIRE
(
timeline
->
getTrackById_const
(
tid3
)
->
mixCount
()
==
0
);
REQUIRE
(
timeline
->
m_allClips
[
cid1
]
->
getSubPlaylistIndex
()
==
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