Skip to content
Snippets Groups Projects
Commit a013d4c7 authored by luyikei's avatar luyikei
Browse files

Implement clip splitting

parent 9281948b
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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 }
},
......
......@@ -247,6 +247,12 @@ MainWorkflow::removeClip( const QString& uuid )
trigger( new Commands::Clip::Remove( m_sequenceWorkflow, 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 )
{
......
......@@ -140,6 +140,9 @@ class MainWorkflow : public QObject
Q_INVOKABLE
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 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment