Commit 973d894e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Commands: Adding a undo/reco command for effect moving.

parent b8c0bf27
......@@ -24,6 +24,7 @@
#include "config.h"
#include "Clip.h"
#include "ClipHelper.h"
#include "EffectHelper.h"
#include "Commands.h"
#include "MainWorkflow.h"
#include "TrackWorkflow.h"
......@@ -189,3 +190,37 @@ void Commands::Clip::Split::undo()
m_trackWorkflow->removeClip( m_newClip->uuid() );
m_toSplit->setEnd( m_oldEnd );
}
Commands::Effect::Move::Move( EffectHelper *helper, EffectUser *old, EffectUser *newUser,
qint64 pos) :
m_helper( helper ),
m_old( old ),
m_new( newUser ),
m_newPos( pos )
{
m_oldPos = helper->begin();
}
void
Commands::Effect::Move::redo()
{
if ( m_old != m_new )
{
m_old->removeEffect( m_helper );
m_new->addEffect( m_helper );
}
else
m_new->moveEffect( m_helper, m_newPos );
}
void
Commands::Effect::Move::undo()
{
if ( m_old != m_new )
{
m_new->removeEffect( m_helper );
m_old->addEffect( m_helper );
}
else
m_new->moveEffect( m_helper, m_oldPos );
}
......@@ -35,6 +35,7 @@
class Clip;
class ClipHelper;
class EffectUser;
#define NEW_COMMAND(x) class x : public Generic
......@@ -144,6 +145,22 @@ namespace Commands
qint64 m_oldEnd;
};
}
namespace Effect
{
NEW_COMMAND( Move )
{
public:
Move( EffectHelper *helper, EffectUser *old, EffectUser *newUser, qint64 pos );
virtual void redo();
virtual void undo();
private:
EffectHelper *m_helper;
EffectUser *m_old;
EffectUser *m_new;
qint64 m_oldPos;
qint64 m_newPos;
};
}
}
#endif // COMMANDS_H
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