Commit 26edb376 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Adding clip croping to the backend

parent fff446c9
......@@ -126,6 +126,38 @@ namespace Commands
::MainWorkflow* m_workflow;
QVector<ClipActionInfo> m_clips;
};
NEW_COMMAND( ResizeClip )
{
public:
ResizeClip( ::MainWorkflow* mainWorkflow, const QUuid& uuid, unsigned int trackId,
float newBegin, float newEnd ) :
m_mainWorkflow( mainWorkflow ),
m_newBegin( newBegin ),
m_newEnd( newEnd )
{
m_clip = mainWorkflow->getClip( uuid, trackId );
m_oldBegin = m_clip->getBegin();
m_oldEnd = m_clip->getEnd();
}
virtual void redo()
{
m_clip->setBegin( m_newBegin );
m_clip->setEnd( m_newEnd );
}
virtual void undo()
{
m_clip->setBegin( m_oldBegin );
m_clip->setEnd( m_oldEnd );
}
private:
::MainWorkflow* m_mainWorkflow;
float m_oldBegin;
float m_oldEnd;
float m_newBegin;
float m_newEnd;
Clip* m_clip;
}
}
}
......
......@@ -158,3 +158,15 @@ void Clip::setTimelineUuid( const QUuid& uuid )
{
m_timelineUuid = uuid;
}
void Clip::setBegin( float begin )
{
Q_ASSERT( begin >= .0f );
m_begin = begin;
}
void Clip::setEnd( float end )
{
Q_ASSERT( end <= 1.0f );
m_end = end;
}
......@@ -65,6 +65,9 @@ class Clip : public QObject
*/
float getEnd() const;
void setBegin( float begin );
void setEnd( float end );
/**
\return Returns the clip length in frame.
*/
......
......@@ -380,3 +380,10 @@ void MainWorkflow::activateTrack( unsigned int trackId )
else
m_tracks[trackId].deactivate();
}
Clip* MainWorkflow::getClip( const QUuid& uuid, unsigned int trackId )
{
Q_ASSERT( trackId < m_trackCount );
return m_tracks[trackId]->getClip( uuid );
}
......@@ -99,6 +99,15 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
void muteTrack( unsigned int trackId );
void unmuteTrack( unsigned int trackId );
/**
* \param uuid : The clip's uuid.
* Please note that the UUID must be the "timeline uuid"
* and note the clip's uuid, or else nothing would match.
* \param trackId : the track id
* \returns The clip that matches the given UUID.
*/
Clip* getClip( const QUuid& uuid, unsigned int trackId );
private:
static MainWorkflow* m_instance;
......
......@@ -98,6 +98,20 @@ qint64 TrackWorkflow::getClipPosition( const QUuid& uuid ) const
return -1;
}
Clip* TrackWorkflow::getClip( const QUuid& uuid )
{
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::const_iterator end = m_clips.end();
while ( it != end )
{
if ( it.value()->getClip()->getTimelineUuid() == uuid )
return it.value()->getClip();
++it;
}
return NULL;
}
void TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentFrame,
qint64 start , bool needRepositioning )
{
......
......@@ -59,6 +59,7 @@ class TrackWorkflow : public QObject
void addClip( Clip*, qint64 start );
void addClip( ClipWorkflow*, qint64 start );
qint64 getClipPosition( const QUuid& uuid ) const;
Clip* getClip( const QUuid& uuid );
/**
* Returns the output that has been computed in synchrone mode.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment