[vlmc-devel] Implement clip splitting
Yikai Lu
git at videolan.org
Fri Aug 12 16:52:30 CEST 2016
vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Mon Aug 8 19:17:23 2016 -0500| [a013d4c729a0e0bb675e9f06cf74b7c9c9fe9d62] | committer: Yikai Lu
Implement clip splitting
> https://code.videolan.org/videolan/vlmc/commit/a013d4c729a0e0bb675e9f06cf74b7c9c9fe9d62
---
src/Commands/Commands.cpp | 21 ++++++++++++++++-----
src/Gui/timeline/Clip.qml | 17 ++++++++++++++++-
src/Workflow/MainWorkflow.cpp | 6 ++++++
src/Workflow/MainWorkflow.h | 3 +++
4 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index a5a2c82..e9424c6 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -311,7 +311,7 @@ Commands::Clip::Split::Split( std::shared_ptr<SequenceWorkflow> const& workflow,
retranslate();
return;
}
- m_newClip = std::make_shared<::Clip>( m_toSplit.get(), newClipBegin, m_toSplit->end() );
+ m_newClip = std::make_shared<::Clip>( m_toSplit.get(), newClipBegin - m_toSplit->begin(), m_toSplit->end() - m_toSplit->begin() );
m_oldEnd = m_toSplit->end();
retranslate();
}
@@ -325,15 +325,22 @@ Commands::Clip::Split::retranslate()
void
Commands::Clip::Split::internalRedo()
{
+ if ( !m_toSplit )
+ {
+ invalidate();
+ return;
+ }
//If we don't remove 1, the clip will end exactly at the starting frame (ie. they will
//be rendering at the same time)
- if ( !m_toSplit )
+ bool ret = m_workflow->resizeClip( m_toSplit->uuid(), m_toSplit->begin(),
+ m_newClipBegin - 1, m_workflow->position( m_toSplit->uuid() ) );
+ if ( ret == false )
{
invalidate();
return;
}
- m_toSplit->setEnd( m_newClipBegin );
- bool ret = m_workflow->addClip( m_newClip, m_trackId, m_newClipPos );
+
+ ret = m_workflow->addClip( m_newClip, m_trackId, m_newClipPos );
if ( ret == true )
emit Core::instance()->workflow()->clipAdded( m_newClip->uuid().toString() );
else
@@ -350,7 +357,11 @@ Commands::Clip::Split::internalUndo()
invalidate();
return;
}
- m_toSplit->setEnd( m_oldEnd );
+ else
+ emit Core::instance()->workflow()->clipRemoved( m_newClip->uuid().toString() );
+ m_workflow->resizeClip( m_toSplit->uuid(), m_toSplit->begin(),
+ m_oldEnd, m_workflow->position( m_toSplit->uuid() ) );
+ emit Core::instance()->workflow()->clipResized( m_toSplit->uuid().toString() );
}
Commands::Clip::Link::Link( std::shared_ptr<SequenceWorkflow> const& workflow,
diff --git a/src/Gui/timeline/Clip.qml b/src/Gui/timeline/Clip.qml
index d3d065f..f217b07 100644
--- a/src/Gui/timeline/Clip.qml
+++ b/src/Gui/timeline/Clip.qml
@@ -231,6 +231,9 @@ Rectangle {
property bool resizing: false
onPositionChanged: {
+ if ( isCutMode === true )
+ return;
+
// If it's too short, don't resize.
if ( width < 6 ) {
resizing = false;
@@ -281,10 +284,17 @@ Rectangle {
if ( mouse.button & Qt.RightButton ) {
clipContextMenu.popup();
}
+ else if ( isCutMode === true ) {
+ var newClipPos = position + ptof( mouseX );
+ var newClipBegin = begin + ptof( mouseX );
+ if ( newClipPos - position < 1 || end - newClipBegin < 1 )
+ return;
+ workflow.splitClip( uuid, newClipPos, newClipBegin );
+ }
}
onReleased: {
- if ( resizing === true )
+ if ( resizing === true && isCutMode === false )
resize();
else
dragFinished();
@@ -293,6 +303,11 @@ Rectangle {
states: [
State {
name: "Normal"
+ when: isCutMode
+ PropertyChanges { target: dragArea; cursorShape: Qt.ArrowCursor }
+ },
+ State {
+ name: "Move"
when: !dragArea.pressed && !dragArea.resizing
PropertyChanges { target: dragArea; cursorShape: Qt.OpenHandCursor }
},
diff --git a/src/Workflow/MainWorkflow.cpp b/src/Workflow/MainWorkflow.cpp
index de5f6a4..d8765d7 100644
--- a/src/Workflow/MainWorkflow.cpp
+++ b/src/Workflow/MainWorkflow.cpp
@@ -248,6 +248,12 @@ MainWorkflow::removeClip( const QString& uuid )
}
void
+MainWorkflow::splitClip( const QUuid& uuid, qint64 newClipPos, qint64 newClipBegin )
+{
+ trigger( new Commands::Clip::Split( m_sequenceWorkflow, uuid, newClipPos, newClipBegin ) );
+}
+
+void
MainWorkflow::linkClips( const QString& uuidA, const QString& uuidB )
{
trigger( new Commands::Clip::Link( m_sequenceWorkflow, uuidA, uuidB ) );
diff --git a/src/Workflow/MainWorkflow.h b/src/Workflow/MainWorkflow.h
index c3e2ac8..8bf2900 100644
--- a/src/Workflow/MainWorkflow.h
+++ b/src/Workflow/MainWorkflow.h
@@ -141,6 +141,9 @@ class MainWorkflow : public QObject
void removeClip( const QString& uuid );
Q_INVOKABLE
+ void splitClip( const QUuid& uuid, qint64 newClipPos, qint64 newClipBegin );
+
+ Q_INVOKABLE
void linkClips( const QString& uuidA, const QString& uuidB );
Q_INVOKABLE
More information about the Vlmc-devel
mailing list