[vlmc-devel] commit: Commands: Adding a undo/reco command for effect moving. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Wed Sep 8 20:28:27 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Sep 8 20:26:47 2010 +0200| [973d894ea52ff4332dfab3c7051305d400a61cf6] | committer: Hugo Beauzée-Luyssen
Commands: Adding a undo/reco command for effect moving.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=973d894ea52ff4332dfab3c7051305d400a61cf6
---
src/Commands/Commands.cpp | 35 +++++++++++++++++++++++++++++++++++
src/Commands/Commands.h | 17 +++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 414b1c6..adec565 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -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 );
+}
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index ab09f88..a99437d 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -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
More information about the Vlmc-devel
mailing list