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

TracksView: Support for track effects addition.

parent 3220a333
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "GraphicsTrack.h" #include "GraphicsTrack.h"
#include "MainWorkflow.h" #include "MainWorkflow.h"
#include <QtDebug>
GraphicsTrack::GraphicsTrack( Workflow::TrackType type, quint32 trackNumber, GraphicsTrack::GraphicsTrack( Workflow::TrackType type, quint32 trackNumber,
QGraphicsItem *parent ) : QGraphicsItem *parent ) :
QGraphicsWidget( parent ) QGraphicsWidget( parent )
...@@ -106,3 +108,9 @@ GraphicsTrack::trackWorkflow() ...@@ -106,3 +108,9 @@ GraphicsTrack::trackWorkflow()
{ {
return m_trackWorkflow; return m_trackWorkflow;
} }
void
GraphicsTrack::setEmphasized( bool )
{
//TODO
}
...@@ -40,14 +40,15 @@ public: ...@@ -40,14 +40,15 @@ public:
GraphicsTrack( Workflow::TrackType type, quint32 trackNumber, GraphicsTrack( Workflow::TrackType type, quint32 trackNumber,
QGraphicsItem *parent = 0 ); QGraphicsItem *parent = 0 );
void setHeight( int height ); void setHeight( int height );
int height(); int height();
void setTrackEnabled( bool enabled ); void setTrackEnabled( bool enabled );
bool isEnabled(); bool isEnabled();
quint32 trackNumber(); quint32 trackNumber();
Workflow::TrackType mediaType(); Workflow::TrackType mediaType();
virtual int type() const { return Type; } virtual int type() const { return Type; }
TrackWorkflow *trackWorkflow(); TrackWorkflow *trackWorkflow();
void setEmphasized( bool value );
QList<AbstractGraphicsMediaItem*> childs(); QList<AbstractGraphicsMediaItem*> childs();
......
...@@ -356,18 +356,35 @@ TracksView::dragMoveEvent( QDragMoveEvent *event ) ...@@ -356,18 +356,35 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
moveMediaItem( m_dragAudioItem, event->pos() ); moveMediaItem( m_dragAudioItem, event->pos() );
else if ( m_dragEffect != NULL ) else if ( m_dragEffect != NULL )
{ {
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems ) //first, some cleaning:
foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
item->setEmphasized( false ); item->setEmphasized( false );
m_effectScaledItems.clear(); foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
QList<AbstractGraphicsMediaItem*> items = mediaItems( event->pos() ); item->setEmphasized( false );
if ( items.size() > 0 )
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 ); 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 ) ...@@ -693,9 +710,12 @@ TracksView::dragLeaveEvent( QDragLeaveEvent *event )
m_dragVideoItem = NULL; m_dragVideoItem = NULL;
m_dragEffect = NULL; //Don't delete the effect. m_dragEffect = NULL; //Don't delete the effect.
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems ) foreach ( AbstractGraphicsMediaItem *item, m_effectEmphasizedItems )
item->setEmphasized( false ); item->setEmphasized( false );
m_effectScaledItems.clear(); m_effectEmphasizedItems.clear();
foreach ( GraphicsTrack *item, m_effectEmphasizedTracks )
item->setEmphasized( false );
m_effectEmphasizedTracks.clear();
if ( updateDurationNeeded ) if ( updateDurationNeeded )
updateDuration(); updateDuration();
...@@ -752,12 +772,27 @@ TracksView::dropEvent( QDropEvent *event ) ...@@ -752,12 +772,27 @@ TracksView::dropEvent( QDropEvent *event )
} }
else if ( m_dragEffect != NULL ) else if ( m_dragEffect != NULL )
{ {
QList<AbstractGraphicsMediaItem*> items = mediaItems( event->pos() ); QList<AbstractGraphicsMediaItem*> clips = mediaItems( event->pos() );
foreach ( AbstractGraphicsMediaItem *item, items ) 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 ); item->setEmphasized( false );
} }
} }
......
...@@ -332,7 +332,9 @@ private: ...@@ -332,7 +332,9 @@ private:
GraphicsMovieItem *m_dragVideoItem; GraphicsMovieItem *m_dragVideoItem;
GraphicsAudioItem *m_dragAudioItem; GraphicsAudioItem *m_dragAudioItem;
Effect *m_dragEffect; Effect *m_dragEffect;
QSet<AbstractGraphicsMediaItem*> m_effectScaledItems; QSet<AbstractGraphicsMediaItem*> m_effectEmphasizedItems;
QSet<GraphicsTrack*> m_effectEmphasizedTracks;
QGraphicsWidget *m_separator; QGraphicsWidget *m_separator;
ToolButtons m_tool; ToolButtons m_tool;
WorkflowRenderer *m_renderer; WorkflowRenderer *m_renderer;
......
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