[vlmc-devel] commit: Adding an undo/redo command for resizing effect and triggering it. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Wed Sep 8 21:14:25 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Wed Sep 8 21:14:18 2010 +0200| [6686041023bb0f24b4fe79afdd0c55078c488bfd] | committer: Hugo Beauzée-Luyssen
Adding an undo/redo command for resizing effect and triggering it.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=6686041023bb0f24b4fe79afdd0c55078c488bfd
---
src/Commands/Commands.cpp | 23 +++++++++++++++++++++++
src/Commands/Commands.h | 14 ++++++++++++++
src/Gui/timeline/GraphicsEffectItem.cpp | 9 ++++++---
3 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index adec565..b4fcbdc 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -25,6 +25,7 @@
#include "Clip.h"
#include "ClipHelper.h"
#include "EffectHelper.h"
+#include "EffectInstance.h"
#include "Commands.h"
#include "MainWorkflow.h"
#include "TrackWorkflow.h"
@@ -224,3 +225,25 @@ Commands::Effect::Move::undo()
else
m_new->moveEffect( m_helper, m_oldPos );
}
+
+Commands::Effect::Resize::Resize( EffectHelper *helper, qint64 newBegin, qint64 newEnd ) :
+ m_helper( helper ),
+ m_newBegin( newBegin ),
+ m_newEnd( newEnd )
+{
+ setText( QObject::tr( "Resizing effect %1" ).arg( m_helper->effectInstance()->effect()->name() ) );
+ m_oldBegin = helper->begin();
+ m_oldEnd = helper->end();
+}
+
+void
+Commands::Effect::Resize::redo()
+{
+ m_helper->setBoundaries( m_newBegin, m_newEnd );
+}
+
+void
+Commands::Effect::Resize::undo()
+{
+ m_helper->setBoundaries( m_oldBegin, m_oldEnd );
+}
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index a99437d..e3c56d1 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -160,6 +160,20 @@ namespace Commands
qint64 m_oldPos;
qint64 m_newPos;
};
+
+ NEW_COMMAND( Resize )
+ {
+ public:
+ Resize( EffectHelper *helper, qint64 newBegin, qint64 newEnd );
+ virtual void redo();
+ virtual void undo();
+ private:
+ EffectHelper *m_helper;
+ qint64 m_newBegin;
+ qint64 m_newEnd;
+ qint64 m_oldBegin;
+ qint64 m_oldEnd;
+ };
}
}
diff --git a/src/Gui/timeline/GraphicsEffectItem.cpp b/src/Gui/timeline/GraphicsEffectItem.cpp
index 9958a60..00eb064 100644
--- a/src/Gui/timeline/GraphicsEffectItem.cpp
+++ b/src/Gui/timeline/GraphicsEffectItem.cpp
@@ -220,8 +220,11 @@ GraphicsEffectItem::triggerMove( TrackWorkflow *oldTrack, TrackWorkflow *newTrac
}
void
-GraphicsEffectItem::triggerResize( TrackWorkflow *tw, Workflow::Helper *helper,
- qint64 newBegin, qint64 newEnd, qint64 pos )
+GraphicsEffectItem::triggerResize( TrackWorkflow *, Workflow::Helper *helper,
+ qint64 newBegin, qint64 newEnd, qint64 )
{
- //FIXME
+ EffectHelper *eh = qobject_cast<EffectHelper*>( helper );
+ if ( eh == NULL )
+ return ;
+ Commands::trigger( new Commands::Effect::Resize( eh, newBegin, newEnd ) );
}
More information about the Vlmc-devel
mailing list