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
40085a04
Commit
40085a04
authored
Sep 19, 2020
by
Jean-Baptiste Mardelle
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix creating mix between color clip and AV clip
parent
c3155b94
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
61 deletions
+63
-61
src/timeline2/model/timelinemodel.cpp
src/timeline2/model/timelinemodel.cpp
+63
-61
No files found.
src/timeline2/model/timelinemodel.cpp
View file @
40085a04
...
...
@@ -801,79 +801,81 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
bool
TimelineModel
::
mixClip
(
int
idToMove
)
{
int
selectedTrack
=
-
1
;
std
::
unordered_set
<
int
>
initialSelection
;
if
(
idToMove
==
-
1
)
{
initialSelection
=
getCurrentSelection
();
if
(
initialSelection
.
empty
())
{
pCore
->
displayMessage
(
i18n
(
"Select a clip to apply the mix"
),
InformationMessage
,
500
);
return
false
;
}
for
(
int
s
:
initialSelection
)
{
if
(
!
isClip
(
s
))
{
continue
;
}
if
(
selectedTrack
==
-
1
)
{
idToMove
=
s
;
break
;
}
}
}
if
(
idToMove
==
-
1
||
!
isClip
(
idToMove
))
{
std
::
unordered_set
<
int
>
initialSelection
=
getCurrentSelection
();
if
(
idToMove
==
-
1
&&
initialSelection
.
empty
())
{
pCore
->
displayMessage
(
i18n
(
"Select a clip to apply the mix"
),
InformationMessage
,
500
);
return
false
;
}
selectedTrack
=
getClipTrackId
(
idToMove
);
if
(
selectedTrack
==
-
1
||
!
isTrack
(
selectedTrack
))
{
pCore
->
displayMessage
(
i18n
(
"Select a clip to apply the mix"
),
InformationMessage
,
500
);
return
false
;
}
int
mixPosition
=
getItemPosition
(
idToMove
);
int
clipDuration
=
getItemPlaytime
(
idToMove
);
std
::
pair
<
int
,
int
>
clipsToMix
;
// Check if we have a clip before and/or after
int
mixPosition
=
0
;
int
previousClip
=
-
1
;
int
nextClip
=
-
1
;
// Check if clip already has a mix
if
(
getTrackById_const
(
selectedTrack
)
->
hasStartMix
(
idToMove
))
{
if
(
getTrackById_const
(
selectedTrack
)
->
hasEndMix
(
idToMove
))
{
pCore
->
displayMessage
(
i18n
(
"Clip already mixed"
),
InformationMessage
,
500
);
return
false
;
if
(
idToMove
!=
-
1
)
{
initialSelection
=
{
idToMove
};
idToMove
=
-
1
;
}
for
(
int
s
:
initialSelection
)
{
if
(
!
isClip
(
s
))
{
continue
;
}
nextClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
+
clipDuration
+
1
);
}
else
if
(
getTrackById_const
(
selectedTrack
)
->
hasEndMix
(
idToMove
))
{
previousClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
-
1
);
if
(
previousClip
>
-
1
&&
getTrackById_const
(
selectedTrack
)
->
hasEndMix
(
previousClip
))
{
// Could happen if 2 clips before are mixed to full length
previousClip
=
-
1
;
selectedTrack
=
getClipTrackId
(
s
);
if
(
selectedTrack
==
-
1
||
!
isTrack
(
selectedTrack
))
{
continue
;
}
}
else
{
previousClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
-
1
);
nextClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
+
clipDuration
+
1
);
}
if
(
previousClip
>
-
1
&&
nextClip
>
-
1
)
{
// We have a clip before and a clip after, check timeline cursor position to decide where to mix
int
cursor
=
pCore
->
getTimelinePosition
();
if
(
cursor
<
mixPosition
+
clipDuration
/
2
)
{
nextClip
=
-
1
;
mixPosition
=
getItemPosition
(
s
);
int
clipDuration
=
getItemPlaytime
(
s
);
// Check if we have a clip before and/or after
int
nextClip
=
-
1
;
// Check if clip already has a mix
if
(
getTrackById_const
(
selectedTrack
)
->
hasStartMix
(
s
))
{
if
(
getTrackById_const
(
selectedTrack
)
->
hasEndMix
(
s
))
{
continue
;
}
nextClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
+
clipDuration
+
1
);
}
else
if
(
getTrackById_const
(
selectedTrack
)
->
hasEndMix
(
s
))
{
previousClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
-
1
);
if
(
previousClip
>
-
1
&&
getTrackById_const
(
selectedTrack
)
->
hasEndMix
(
previousClip
))
{
// Could happen if 2 clips before are mixed to full length
previousClip
=
-
1
;
}
}
else
{
previousClip
=
-
1
;
previousClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
-
1
);
nextClip
=
getTrackById_const
(
selectedTrack
)
->
getClipByPosition
(
mixPosition
+
clipDuration
+
1
);
}
if
(
previousClip
>
-
1
&&
nextClip
>
-
1
)
{
// We have a clip before and a clip after, check timeline cursor position to decide where to mix
int
cursor
=
pCore
->
getTimelinePosition
();
if
(
cursor
<
mixPosition
+
clipDuration
/
2
)
{
nextClip
=
-
1
;
}
else
{
previousClip
=
-
1
;
}
}
}
if
(
nextClip
==
-
1
)
{
if
(
previousClip
==
-
1
)
{
if
(
nextClip
==
-
1
)
{
if
(
previousClip
==
-
1
)
{
// No clip to mix, abort
pCore
->
displayMessage
(
i18n
(
"No adjacent clip to perform mix"
),
InformationMessage
,
500
);
return
false
;
continue
;
}
// Mix at start of selected clip
clipsToMix
.
first
=
previousClip
;
clipsToMix
.
second
=
s
;
idToMove
=
s
;
break
;
}
else
{
// Mix at end of selected clip
mixPosition
+=
clipDuration
;
clipsToMix
.
first
=
s
;
clipsToMix
.
second
=
nextClip
;
idToMove
=
s
;
break
;
}
// Mix at start of selected clip
clipsToMix
.
first
=
previousClip
;
clipsToMix
.
second
=
idToMove
;
}
else
{
// Mix at end of selected clip
mixPosition
+=
clipDuration
;
clipsToMix
.
first
=
idToMove
;
clipsToMix
.
second
=
nextClip
;
}
if
(
idToMove
==
-
1
||
!
isClip
(
idToMove
))
{
pCore
->
displayMessage
(
i18n
(
"Select a clip to apply the mix"
),
InformationMessage
,
500
);
return
false
;
}
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
bool
result
=
requestClipMix
(
clipsToMix
,
selectedTrack
,
mixPosition
,
true
,
true
,
true
,
undo
,
...
...
Eugen Mohr
@emohr
mentioned in issue
#796
·
Sep 19, 2020
mentioned in issue
#796
mentioned in issue #796
Toggle commit list
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