[vlmc-devel] commit: TracksView: Support for track effects addition. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sun Aug 29 21:38:11 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Aug 29 21:30:42 2010 +0200| [e919874e62e76025fc66a876b7c155de811b69f1] | committer: Hugo Beauzée-Luyssen 

TracksView: Support for track effects addition.

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

 src/Gui/timeline/GraphicsTrack.cpp |    8 +++++
 src/Gui/timeline/GraphicsTrack.h   |   15 +++++----
 src/Gui/timeline/TracksView.cpp    |   59 ++++++++++++++++++++++++++++-------
 src/Gui/timeline/TracksView.h      |    4 ++-
 4 files changed, 66 insertions(+), 20 deletions(-)

diff --git a/src/Gui/timeline/GraphicsTrack.cpp b/src/Gui/timeline/GraphicsTrack.cpp
index 861e2d2..581bcd6 100644
--- a/src/Gui/timeline/GraphicsTrack.cpp
+++ b/src/Gui/timeline/GraphicsTrack.cpp
@@ -25,6 +25,8 @@
 #include "GraphicsTrack.h"
 #include "MainWorkflow.h"
 
+#include <QtDebug>
+
 GraphicsTrack::GraphicsTrack( Workflow::TrackType type, quint32 trackNumber,
                               QGraphicsItem *parent ) :
     QGraphicsWidget( parent )
@@ -106,3 +108,9 @@ GraphicsTrack::trackWorkflow()
 {
     return m_trackWorkflow;
 }
+
+void
+GraphicsTrack::setEmphasized( bool )
+{
+    //TODO
+}
diff --git a/src/Gui/timeline/GraphicsTrack.h b/src/Gui/timeline/GraphicsTrack.h
index a248b99..fe69cc2 100644
--- a/src/Gui/timeline/GraphicsTrack.h
+++ b/src/Gui/timeline/GraphicsTrack.h
@@ -40,14 +40,15 @@ public:
     GraphicsTrack( Workflow::TrackType type, quint32 trackNumber,
                    QGraphicsItem *parent = 0 );
 
-    void setHeight( int height );
-    int height();
-    void setTrackEnabled( bool enabled );
-    bool isEnabled();
-    quint32 trackNumber();
+    void                setHeight( int height );
+    int                 height();
+    void                setTrackEnabled( bool enabled );
+    bool                isEnabled();
+    quint32             trackNumber();
     Workflow::TrackType mediaType();
-    virtual int type() const { return Type; }
-    TrackWorkflow   *trackWorkflow();
+    virtual int         type() const { return Type; }
+    TrackWorkflow       *trackWorkflow();
+    void                setEmphasized( bool value );
 
     QList<AbstractGraphicsMediaItem*> childs();
 
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index 80b5782..438d8c9 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -356,18 +356,35 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
         moveMediaItem( m_dragAudioItem, event->pos() );
     else if ( m_dragEffect != NULL )
     {
-        foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
+        //first, some cleaning:
+        foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
             item->setEmphasized( false );
-        m_effectScaledItems.clear();
-        QList<AbstractGraphicsMediaItem*>   items = mediaItems( event->pos() );
-        if ( items.size() > 0 )
+        foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
+            item->setEmphasized( false );
+
+        m_effectEmphasizedItems.clear();
+        QList<AbstractGraphicsMediaItem*>   clips = mediaItems( event->pos() );
+        if ( clips.size() > 0 )
         {
-            foreach ( AbstractGraphicsMediaItem* item, items )
+            foreach ( AbstractGraphicsMediaItem* item, clips )
             {
-                m_effectScaledItems.insert( item );
+                m_effectEmphasizedItems.insert( item );
                 item->setEmphasized( true );
             }
         }
+        else
+        {
+            QList<QGraphicsItem*> tracks = items( 0, event->pos().y() );
+            foreach ( QGraphicsItem* item, tracks )
+            {
+                GraphicsTrack   *track = qgraphicsitem_cast<GraphicsTrack*>( item );
+                if ( track != NULL )
+                {
+                    m_effectEmphasizedTracks.insert( track );
+                    track->setEmphasized( true );
+                }
+            }
+        }
     }
 }
 
@@ -693,9 +710,12 @@ TracksView::dragLeaveEvent( QDragLeaveEvent *event )
     m_dragVideoItem = NULL;
     m_dragEffect = NULL; //Don't delete the effect.
 
-    foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
+    foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
         item->setEmphasized( false );
-    m_effectScaledItems.clear();
+    m_effectEmphasizedItems.clear();
+    foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
+        item->setEmphasized( false );
+    m_effectEmphasizedTracks.clear();
 
     if ( updateDurationNeeded )
         updateDuration();
@@ -752,12 +772,27 @@ TracksView::dropEvent( QDropEvent *event )
     }
     else if ( m_dragEffect != NULL )
     {
-        QList<AbstractGraphicsMediaItem*>   items = mediaItems( event->pos() );
-        foreach ( AbstractGraphicsMediaItem *item, items )
+        QList<AbstractGraphicsMediaItem*>   clips = mediaItems( event->pos() );
+        if ( clips.size() > 0 )
         {
-            item->clipHelper()->clipWorkflow()->appendEffect( m_dragEffect );
+            foreach ( AbstractGraphicsMediaItem *item, clips )
+            {
+                item->clipHelper()->clipWorkflow()->appendEffect( m_dragEffect );
+            }
         }
-        foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
+        else
+        {
+            QList<QGraphicsItem*> tracks = items( 0, event->pos().y() );
+            foreach ( QGraphicsItem* item, tracks )
+            {
+                GraphicsTrack   *track = qgraphicsitem_cast<GraphicsTrack*>( item );
+                if ( track != NULL )
+                    track->trackWorkflow()->addEffect( m_dragEffect );
+            }
+        }
+        foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
+            item->setEmphasized( false );
+        foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
             item->setEmphasized( false );
     }
 }
diff --git a/src/Gui/timeline/TracksView.h b/src/Gui/timeline/TracksView.h
index d0c53cc..568e94e 100644
--- a/src/Gui/timeline/TracksView.h
+++ b/src/Gui/timeline/TracksView.h
@@ -332,7 +332,9 @@ private:
     GraphicsMovieItem       *m_dragVideoItem;
     GraphicsAudioItem       *m_dragAudioItem;
     Effect                  *m_dragEffect;
-    QSet<AbstractGraphicsMediaItem*>    m_effectScaledItems;
+    QSet<AbstractGraphicsMediaItem*>    m_effectEmphasizedItems;
+    QSet<GraphicsTrack*>                m_effectEmphasizedTracks;
+
     QGraphicsWidget         *m_separator;
     ToolButtons             m_tool;
     WorkflowRenderer        *m_renderer;



More information about the Vlmc-devel mailing list