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
18fae083
Commit
18fae083
authored
Sep 28, 2020
by
Jean-Baptiste Mardelle
Browse files
Make mix cut pos snap in timeline
Related to
#796
parent
5d6e7e81
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/timeline2/model/clipmodel.cpp
View file @
18fae083
...
...
@@ -662,11 +662,18 @@ void ClipModel::setMixDuration(int mix, int cutOffset)
m_mixCutPos
=
cutOffset
;
}
m_mixDuration
=
mix
;
if
(
m_mixCutPos
>
0
)
{
m_clipMarkerModel
->
updateSnapMixPosition
(
m_mixDuration
-
m_mixCutPos
);
}
}
void
ClipModel
::
setMixDuration
(
int
mix
)
{
m_mixDuration
=
mix
;
if
(
m_mixDuration
==
0
)
{
m_mixCutPos
=
0
;
}
m_clipMarkerModel
->
updateSnapMixPosition
(
m_mixDuration
-
m_mixCutPos
);
}
int
ClipModel
::
getMixDuration
()
const
...
...
@@ -682,7 +689,7 @@ int ClipModel::getMixCutPosition() const
void
ClipModel
::
setInOut
(
int
in
,
int
out
)
{
MoveableItem
::
setInOut
(
in
,
out
);
m_clipMarkerModel
->
updateSnapModelInOut
(
std
::
pair
<
int
,
int
>
(
in
,
out
)
);
m_clipMarkerModel
->
updateSnapModelInOut
(
{
in
,
out
,
qMax
(
0
,
m_mixDuration
-
m_mixCutPos
)}
);
}
void
ClipModel
::
setCurrentTrackId
(
int
tid
,
bool
finalMove
)
...
...
src/timeline2/model/clipsnapmodel.cpp
View file @
18fae083
...
...
@@ -59,11 +59,19 @@ void ClipSnapModel::updateSnapModelPos(int newPos)
addAllSnaps
();
}
void
ClipSnapModel
::
updateSnapModelInOut
(
std
::
pair
<
int
,
int
>
newInOut
)
void
ClipSnapModel
::
updateSnapModelInOut
(
std
::
vector
<
int
>
borderSnaps
)
{
removeAllSnaps
();
m_inPoint
=
newInOut
.
first
;
m_outPoint
=
newInOut
.
second
;
m_inPoint
=
borderSnaps
.
at
(
0
);
m_outPoint
=
borderSnaps
.
at
(
1
);
m_mixPoint
=
borderSnaps
.
at
(
2
);
addAllSnaps
();
}
void
ClipSnapModel
::
updateSnapMixPosition
(
int
mixPos
)
{
removeAllSnaps
();
m_mixPoint
=
mixPos
;
addAllSnaps
();
}
...
...
@@ -75,6 +83,9 @@ void ClipSnapModel::addAllSnaps()
ptr
->
addPoint
(
m_speed
<
0
?
ceil
(
m_outPoint
+
m_position
+
snap
/
m_speed
-
m_inPoint
)
:
ceil
(
m_position
+
snap
/
m_speed
-
m_inPoint
));
}
}
if
(
m_mixPoint
>
0
)
{
ptr
->
addPoint
(
ceil
(
m_position
+
m_mixPoint
/
m_speed
));
}
}
}
...
...
@@ -86,6 +97,9 @@ void ClipSnapModel::removeAllSnaps()
ptr
->
removePoint
(
m_speed
<
0
?
ceil
(
m_outPoint
+
m_position
+
snap
/
m_speed
-
m_inPoint
)
:
ceil
(
m_position
+
snap
/
m_speed
-
m_inPoint
));
}
}
if
(
m_mixPoint
>
0
)
{
ptr
->
removePoint
(
ceil
(
m_position
+
m_mixPoint
/
m_speed
));
}
}
}
...
...
@@ -99,6 +113,9 @@ void ClipSnapModel::allSnaps(std::vector<int> &snaps, int offset)
}
}
}
if
(
m_mixPoint
>
0
)
{
snaps
.
push_back
(
m_position
+
m_mixPoint
-
offset
);
}
snaps
.
push_back
(
m_position
+
m_outPoint
-
m_inPoint
+
1
-
offset
);
}
...
...
src/timeline2/model/clipsnapmodel.hpp
View file @
18fae083
...
...
@@ -52,7 +52,8 @@ public:
void
setReferenceModel
(
const
std
::
weak_ptr
<
MarkerListModel
>
&
markerModel
,
double
speed
);
void
updateSnapModelPos
(
int
newPos
);
void
updateSnapModelInOut
(
std
::
pair
<
int
,
int
>
newInOut
);
void
updateSnapModelInOut
(
std
::
vector
<
int
>
borderSnaps
);
void
updateSnapMixPosition
(
int
mixPos
);
/* @brief Retrieve all snap points */
void
allSnaps
(
std
::
vector
<
int
>
&
snaps
,
int
offset
=
0
);
...
...
@@ -63,6 +64,7 @@ private:
std
::
unordered_set
<
int
>
m_snapPoints
;
int
m_inPoint
;
int
m_outPoint
;
int
m_mixPoint
{
0
};
int
m_position
;
double
m_speed
{
1.
};
void
addAllSnaps
();
...
...
src/timeline2/view/qml/Clip.qml
View file @
18fae083
...
...
@@ -391,7 +391,7 @@ Rectangle {
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
width
:
2
color
:
"
indigo
"
color
:
"
navy
"
}
MouseArea
{
// Left resize handle
...
...
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