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
9db68961
Commit
9db68961
authored
Jun 04, 2021
by
Jean-Baptiste Mardelle
Browse files
Fix various spacer issues.
Fixes
#1093
parent
6431ce25
Pipeline
#64169
passed with stage
in 8 minutes and 2 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bin/model/subtitlemodel.cpp
View file @
9db68961
...
...
@@ -1225,3 +1225,18 @@ int SubtitleModel::getBlankSizeAtPos(int pos) const
}
return
max
.
frames
(
pCore
->
getCurrentFps
())
-
min
.
frames
(
pCore
->
getCurrentFps
());
}
int
SubtitleModel
::
getBlankStart
(
int
pos
)
const
{
GenTime
matchPos
(
pos
,
pCore
->
getCurrentFps
());
std
::
unordered_set
<
int
>
matching
;
bool
found
=
false
;
GenTime
min
;
for
(
const
auto
&
subtitles
:
m_subtitleList
)
{
if
(
subtitles
.
second
.
second
<
matchPos
&&
(
min
==
GenTime
()
||
subtitles
.
second
.
second
>
min
))
{
min
=
subtitles
.
second
.
second
;
found
=
true
;
}
}
return
found
?
min
.
frames
(
pCore
->
getCurrentFps
())
+
1
:
0
;
}
src/bin/model/subtitlemodel.hpp
View file @
9db68961
...
...
@@ -144,6 +144,8 @@ public:
QDomElement
toXml
(
int
sid
,
QDomDocument
&
document
);
/** @brief Returns the size of the space between subtitles */
int
getBlankSizeAtPos
(
int
pos
)
const
;
/** @brief Returns the position of the first blank frame before a position */
int
getBlankStart
(
int
pos
)
const
;
/** @brief Switch a subtitle's grab state */
void
switchGrab
(
int
sid
);
/** @brief Ungrab all items */
...
...
src/timeline2/model/timelinefunctions.cpp
View file @
9db68961
...
...
@@ -1925,14 +1925,31 @@ bool TimelineFunctions::pasteTimelineClips(const std::shared_ptr<TimelineItemMod
bool
TimelineFunctions
::
requestDeleteBlankAt
(
const
std
::
shared_ptr
<
TimelineItemModel
>
&
timeline
,
int
trackId
,
int
position
,
bool
affectAllTracks
)
{
// find blank duration
int
spaceDuration
;
if
(
trackId
==
-
2
)
{
// Subtitle track
spaceDuration
=
timeline
->
getSubtitleModel
()
->
getBlankSizeAtPos
(
position
);
int
spaceStart
=
0
;
if
(
affectAllTracks
)
{
int
lastFrame
=
0
;
for
(
const
auto
&
track
:
timeline
->
m_allTracks
)
{
lastFrame
=
track
->
getBlankStart
(
position
);
if
(
lastFrame
>
spaceStart
)
{
spaceStart
=
lastFrame
;
}
}
// check subtitle track
if
(
timeline
->
getSubtitleModel
())
{
lastFrame
=
timeline
->
getSubtitleModel
()
->
getBlankStart
(
position
);
if
(
lastFrame
>
spaceStart
)
{
spaceStart
=
lastFrame
;
}
}
}
else
{
spaceDuration
=
timeline
->
getTrackById_const
(
trackId
)
->
getBlankSizeAtPos
(
position
);
if
(
trackId
==
-
2
)
{
// Subtitle track
spaceStart
=
timeline
->
getSubtitleModel
()
->
getBlankStart
(
position
);
}
else
{
spaceStart
=
timeline
->
getTrackById_const
(
trackId
)
->
getBlankStart
(
position
);
}
}
if
(
space
Duration
<=
0
)
{
if
(
space
Start
==
position
)
{
return
false
;
}
int
cid
=
requestSpacerStartOperation
(
timeline
,
affectAllTracks
?
-
1
:
trackId
,
position
);
...
...
@@ -1943,7 +1960,7 @@ bool TimelineFunctions::requestDeleteBlankAt(const std::shared_ptr<TimelineItemM
// Start undoable command
std
::
function
<
bool
(
void
)
>
undo
=
[]()
{
return
true
;
};
std
::
function
<
bool
(
void
)
>
redo
=
[]()
{
return
true
;
};
requestSpacerEndOperation
(
timeline
,
cid
,
start
,
s
tart
-
spaceDuration
,
affectAllTracks
?
-
1
:
trackId
,
!
KdenliveSettings
::
lockedGuides
(),
undo
,
redo
);
requestSpacerEndOperation
(
timeline
,
cid
,
start
,
s
paceStart
,
affectAllTracks
?
-
1
:
trackId
,
!
KdenliveSettings
::
lockedGuides
(),
undo
,
redo
);
return
true
;
}
...
...
src/timeline2/model/trackmodel.cpp
View file @
9db68961
...
...
@@ -459,8 +459,9 @@ int TrackModel::getBlankSizeAtPos(int frame)
int
min_length
=
0
;
int
blank_length
=
0
;
for
(
auto
&
m_playlist
:
m_playlists
)
{
if
(
frame
>=
m_playlist
.
get_length
())
{
blank_length
=
frame
-
m_playlist
.
get_length
()
+
1
;
int
playlistLength
=
m_playlist
.
get_length
();
if
(
frame
>=
playlistLength
)
{
continue
;
}
else
{
int
ix
=
m_playlist
.
get_clip_index_at
(
frame
);
if
(
m_playlist
.
is_blank
(
ix
))
{
...
...
@@ -474,6 +475,10 @@ int TrackModel::getBlankSizeAtPos(int frame)
min_length
=
blank_length
;
}
}
if
(
blank_length
==
0
)
{
// playlists are shorter than frame
return
-
1
;
}
return
min_length
;
}
...
...
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