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
498434c2
Commit
498434c2
authored
May 04, 2020
by
Jean-Baptiste Mardelle
Browse files
Also consider moving clip's markers for snapping.
Fixes
#661
parent
8796b4f9
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/bin/model/markerlistmodel.cpp
View file @
498434c2
...
...
@@ -331,12 +331,12 @@ QList<CommentedTime> MarkerListModel::getAllMarkers() const
return
markers
;
}
std
::
vector
<
size_
t
>
MarkerListModel
::
getSnapPoints
()
const
std
::
vector
<
in
t
>
MarkerListModel
::
getSnapPoints
()
const
{
READ_LOCK
();
std
::
vector
<
size_
t
>
markers
;
std
::
vector
<
in
t
>
markers
;
for
(
const
auto
&
marker
:
m_markerList
)
{
markers
.
push_back
(
(
size_t
)
marker
.
first
.
frames
(
pCore
->
getCurrentFps
()));
markers
.
push_back
(
marker
.
first
.
frames
(
pCore
->
getCurrentFps
()));
}
return
markers
;
}
...
...
src/bin/model/markerlistmodel.hpp
View file @
498434c2
...
...
@@ -99,7 +99,7 @@ public:
QList
<
CommentedTime
>
getAllMarkers
()
const
;
/* @brief Returns all markers positions in model */
std
::
vector
<
size_
t
>
getSnapPoints
()
const
;
std
::
vector
<
in
t
>
getSnapPoints
()
const
;
/* @brief Returns true if a marker exists at given pos
Notice that add/remove queries are done in real time (gentime), but this request is made in frame
...
...
src/timeline2/model/clipmodel.cpp
View file @
498434c2
...
...
@@ -91,7 +91,7 @@ int ClipModel::construct(const std::shared_ptr<TimelineModel> &parent, const QSt
return
id
;
}
void
ClipModel
::
allSnaps
(
std
::
vector
<
size_
t
>
&
snaps
)
void
ClipModel
::
allSnaps
(
std
::
vector
<
in
t
>
&
snaps
)
{
m_clipMarkerModel
->
allSnaps
(
snaps
);
}
...
...
src/timeline2/model/clipmodel.hpp
View file @
498434c2
...
...
@@ -108,7 +108,7 @@ public:
QDomElement
toXml
(
QDomDocument
&
document
);
/* @brief Retrieve a list of all snaps for this clip */
void
allSnaps
(
std
::
vector
<
size_
t
>
&
snaps
);
void
allSnaps
(
std
::
vector
<
in
t
>
&
snaps
);
protected:
// helper functions that creates the lambda
...
...
src/timeline2/model/clipsnapmodel.cpp
View file @
498434c2
...
...
@@ -89,10 +89,9 @@ void ClipSnapModel::removeAllSnaps()
}
}
void
ClipSnapModel
::
allSnaps
(
std
::
vector
<
size_
t
>
&
snaps
)
void
ClipSnapModel
::
allSnaps
(
std
::
vector
<
in
t
>
&
snaps
)
{
snaps
.
push_back
((
size_t
)
m_position
);
snaps
.
push_back
((
size_t
)(
m_position
+
m_outPoint
-
m_inPoint
));
snaps
.
push_back
(
m_position
);
if
(
auto
ptr
=
m_registeredSnap
.
lock
())
{
for
(
const
auto
&
snap
:
m_snapPoints
)
{
if
(
snap
>=
m_inPoint
*
m_speed
&&
snap
<
m_outPoint
*
m_speed
)
{
...
...
@@ -100,6 +99,7 @@ void ClipSnapModel::allSnaps(std::vector<size_t> &snaps)
}
}
}
snaps
.
push_back
(
m_position
+
m_outPoint
-
m_inPoint
+
1
);
}
void
ClipSnapModel
::
registerSnapModel
(
const
std
::
weak_ptr
<
SnapModel
>
&
snapModel
,
int
position
,
int
in
,
int
out
,
double
speed
)
...
...
src/timeline2/model/clipsnapmodel.hpp
View file @
498434c2
...
...
@@ -54,7 +54,7 @@ public:
void
updateSnapModelPos
(
int
newPos
);
void
updateSnapModelInOut
(
std
::
pair
<
int
,
int
>
newInOut
);
/* @brief Retrieve all snap points */
void
allSnaps
(
std
::
vector
<
size_
t
>
&
snaps
);
void
allSnaps
(
std
::
vector
<
in
t
>
&
snaps
);
private:
...
...
src/timeline2/model/timelinemodel.cpp
View file @
498434c2
...
...
@@ -729,9 +729,14 @@ int TimelineModel::suggestClipMove(int clipId, int trackId, int position, int cu
}
for
(
int
current_clipId
:
all_items
)
{
if
(
getItemTrackId
(
current_clipId
)
!=
-
1
)
{
int
in
=
getItemPosition
(
current_clipId
);
ignored_pts
.
push_back
(
in
);
ignored_pts
.
push_back
(
in
+
getItemPlaytime
(
current_clipId
));
if
(
isClip
(
current_clipId
))
{
m_allClips
[
current_clipId
]
->
allSnaps
(
ignored_pts
);
}
else
{
// Composition
int
in
=
getItemPosition
(
current_clipId
);
ignored_pts
.
push_back
(
in
);
ignored_pts
.
push_back
(
in
+
getItemPlaytime
(
current_clipId
));
}
}
}
int
snapped
=
getBestSnapPos
(
currentPos
,
position
-
currentPos
,
m_editMode
==
TimelineMode
::
NormalEdit
?
ignored_pts
:
std
::
vector
<
int
>
(),
...
...
@@ -2759,7 +2764,7 @@ int TimelineModel::getBestSnapPos(int referencePos, int diff, std::vector<int> p
return
closest
;
}
int
TimelineModel
::
getNextSnapPos
(
int
pos
,
std
::
vector
<
size_
t
>
&
snaps
)
int
TimelineModel
::
getNextSnapPos
(
int
pos
,
std
::
vector
<
in
t
>
&
snaps
)
{
QVector
<
int
>
tracks
;
// Get active tracks
...
...
@@ -2792,7 +2797,7 @@ int TimelineModel::getNextSnapPos(int pos, std::vector<size_t> &snaps)
return
pos
;
}
int
TimelineModel
::
getPreviousSnapPos
(
int
pos
,
std
::
vector
<
size_
t
>
&
snaps
)
int
TimelineModel
::
getPreviousSnapPos
(
int
pos
,
std
::
vector
<
in
t
>
&
snaps
)
{
QVector
<
int
>
tracks
;
// Get active tracks
...
...
src/timeline2/model/timelinemodel.hpp
View file @
498434c2
...
...
@@ -559,12 +559,12 @@ public:
/* @brief Requests the next snapped point
@param pos is the current position
*/
int
getNextSnapPos
(
int
pos
,
std
::
vector
<
size_
t
>
&
snaps
);
int
getNextSnapPos
(
int
pos
,
std
::
vector
<
in
t
>
&
snaps
);
/* @brief Requests the previous snapped point
@param pos is the current position
*/
int
getPreviousSnapPos
(
int
pos
,
std
::
vector
<
size_
t
>
&
snaps
);
int
getPreviousSnapPos
(
int
pos
,
std
::
vector
<
in
t
>
&
snaps
);
/* @brief Add a new snap point
@param pos is the current position
...
...
src/timeline2/view/timelinecontroller.cpp
View file @
498434c2
...
...
@@ -686,8 +686,8 @@ void TimelineController::gotoNextSnap()
m_snapStackIndex
=
pCore
->
undoIndex
();
m_activeSnaps
.
clear
();
m_activeSnaps
=
pCore
->
projectManager
()
->
current
()
->
getGuideModel
()
->
getSnapPoints
();
m_activeSnaps
.
push_back
(
(
size_t
)
m_zone
.
x
());
m_activeSnaps
.
push_back
(
(
size_t
)(
m_zone
.
y
()
-
1
)
)
;
m_activeSnaps
.
push_back
(
m_zone
.
x
());
m_activeSnaps
.
push_back
(
m_zone
.
y
()
-
1
);
}
int
nextSnap
=
m_model
->
getNextSnapPos
(
pCore
->
getTimelinePosition
(),
m_activeSnaps
);
if
(
nextSnap
>
pCore
->
getTimelinePosition
())
{
...
...
@@ -702,8 +702,8 @@ void TimelineController::gotoPreviousSnap()
m_snapStackIndex
=
pCore
->
undoIndex
();
m_activeSnaps
.
clear
();
m_activeSnaps
=
pCore
->
projectManager
()
->
current
()
->
getGuideModel
()
->
getSnapPoints
();
m_activeSnaps
.
push_back
(
(
size_t
)
m_zone
.
x
());
m_activeSnaps
.
push_back
(
(
size_t
)(
m_zone
.
y
()
-
1
)
)
;
m_activeSnaps
.
push_back
(
m_zone
.
x
());
m_activeSnaps
.
push_back
(
m_zone
.
y
()
-
1
);
}
setPosition
(
m_model
->
getPreviousSnapPos
(
pCore
->
getTimelinePosition
(),
m_activeSnaps
));
}
...
...
src/timeline2/view/timelinecontroller.h
View file @
498434c2
...
...
@@ -588,7 +588,7 @@ private:
std
::
shared_ptr
<
AudioCorrelation
>
m_audioCorrelator
;
QMutex
m_metaMutex
;
bool
m_ready
;
std
::
vector
<
size_
t
>
m_activeSnaps
;
std
::
vector
<
in
t
>
m_activeSnaps
;
int
m_snapStackIndex
;
QMetaObject
::
Connection
m_connection
;
...
...
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