[vlmc-devel] commit: EffectHelper: Don't force a 0 begin when changing target. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Sep 16 01:07:50 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Sep 16 01:08:11 2010 +0200| [437bb91470027d7e0525004c8d6778096de84eec] | committer: Hugo Beauzée-Luyssen 

EffectHelper: Don't force a 0 begin when changing target.

Effect addition undo/redo simplifications

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=437bb91470027d7e0525004c8d6778096de84eec
---

 src/Commands/Commands.cpp          |   13 ++++++-------
 src/Commands/Commands.h            |    2 ++
 src/EffectsEngine/EffectHelper.cpp |    1 -
 src/Gui/timeline/TracksView.cpp    |    1 -
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 2d4b7f9..f162822 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -219,6 +219,8 @@ Commands::Effect::Move::Move( EffectHelper *helper, EffectUser *old, EffectUser
     m_newPos( pos )
 {
     m_oldPos = helper->begin();
+    m_oldEnd = helper->end();
+    m_newEnd = m_helper->end() - ( m_helper->begin() - pos );
     setText( QObject::tr( "Moving effect %1" ).arg( m_helper->effectInstance()->effect()->name() ) );
 }
 
@@ -228,12 +230,9 @@ Commands::Effect::Move::redo()
     if ( m_old != m_new )
     {
         m_old->removeEffect( m_helper );
+        m_helper->setBoundaries( m_newPos, m_newEnd );
         m_new->addEffect( m_helper );
-        qint64  offset = m_helper->begin() - m_newPos;
-        if ( m_helper->end() <= 0 )
-            m_helper->setBoundaries( m_newPos, ::Effect::TrackEffectDefaultLength );
-        else
-            m_helper->setBoundaries( m_newPos, m_helper->end() - offset );
+
     }
     else
         m_new->moveEffect( m_helper, m_newPos );
@@ -245,9 +244,9 @@ Commands::Effect::Move::undo()
     if ( m_old != m_new )
     {
         m_new->removeEffect( m_helper );
+        m_helper->setBoundaries( m_oldPos, m_oldEnd );
+        //This must be called after setting boundaries, as the effect's begin is its begin boundary
         m_old->addEffect( m_helper );
-        qint64  offset = m_helper->begin() - m_oldPos;
-        m_helper->setBoundaries( m_oldPos, m_helper->end() - offset );
     }
     else
         m_new->moveEffect( m_helper, m_oldPos );
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index f62f974..fb4609e 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -172,6 +172,8 @@ namespace Commands
                 EffectUser      *m_new;
                 qint64          m_oldPos;
                 qint64          m_newPos;
+                qint64          m_newEnd;
+                qint64          m_oldEnd;
         };
 
         NEW_COMMAND( Resize )
diff --git a/src/EffectsEngine/EffectHelper.cpp b/src/EffectsEngine/EffectHelper.cpp
index 2a1baf7..2a805c4 100644
--- a/src/EffectsEngine/EffectHelper.cpp
+++ b/src/EffectsEngine/EffectHelper.cpp
@@ -53,7 +53,6 @@ void
 EffectHelper::setTarget( EffectUser *target )
 {
     m_target = target;
-    m_begin = 0;
     if ( target != NULL )
         m_end = target->length();
     if ( m_end <= 0 ) //Clip can't be 0lengthed, so this case would be a track.
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index a79233d..3280fa6 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -915,7 +915,6 @@ TracksView::mouseMoveEvent( QMouseEvent *event )
                     break ;
                 }
             }
-            qDebug() << (void*)m_effectTarget;
         }
     }
     else if ( event->modifiers() == Qt::NoModifier &&



More information about the Vlmc-devel mailing list