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

Allow more than one effect per track/clip

parent c318bd3b
......@@ -35,7 +35,7 @@ EffectUser::EffectUser() :
m_width( 0 ),
m_height( 0 )
{
m_effectsLock = new QReadWriteLock;
m_effectsLock = new QReadWriteLock();
}
EffectUser::~EffectUser()
......@@ -333,3 +333,19 @@ EffectUser::cleanEffects()
m_filters.clear();
m_mixers.clear();
}
bool
EffectUser::contains( Effect::Type, const QUuid &uuid ) const
{
QReadLocker lock( m_effectsLock );
EffectsEngine::EffectList::const_iterator it = m_filters.constBegin();
EffectsEngine::EffectList::const_iterator ite = m_filters.constEnd();
while ( it != ite )
{
if ( (*it)->uuid() == uuid )
return true;
++it;
}
return false;
}
......@@ -61,6 +61,7 @@ class EffectUser : public QObject
virtual Type effectType() const = 0;
void loadEffects( const QDomElement &project );
void saveFilters( QXmlStreamWriter &project ) const;
bool contains( Effect::Type, const QUuid &uuid ) const;
protected:
EffectUser();
......
......@@ -122,7 +122,6 @@ class AbstractGraphicsItem : public QObject, public QGraphicsItem
virtual qint32 zSelected() const = 0;
virtual qint32 zNotSelected() const = 0;
protected:
virtual void hoverEnterEvent( QGraphicsSceneHoverEvent* event );
virtual void hoverMoveEvent( QGraphicsSceneHoverEvent* event );
......
......@@ -101,7 +101,7 @@ GraphicsEffectItem::trackType() const
qint64
GraphicsEffectItem::itemHeight() const
{
return 15;
return 10;
}
void
......@@ -342,3 +342,17 @@ GraphicsEffectItem::contextMenuEvent( QGraphicsSceneContextMenuEvent *event )
update();
}
}
void
GraphicsEffectItem::setStartPos( qint64 position )
{
if ( m_effectHelper != NULL && m_effectHelper->target() != NULL )
{
int nbEffect = m_effectHelper->target()->count( Effect::Filter );
if ( m_effectHelper->target()->contains( Effect::Filter, m_effectHelper->uuid() ) == true )
--nbEffect;
QGraphicsItem::setPos( position, nbEffect * itemHeight() );
}
else
QGraphicsItem::setPos( position, 0 );
}
......@@ -61,6 +61,8 @@ class GraphicsEffectItem : public AbstractGraphicsItem
virtual qint32 zNotSelected() const;
void setContainer( AbstractGraphicsMediaItem *item );
const AbstractGraphicsMediaItem *container() const;
virtual void setStartPos( qint64 position );
protected:
virtual bool hasResizeBoundaries() const;
virtual void contextMenuEvent( QGraphicsSceneContextMenuEvent *event );
......
......@@ -132,18 +132,18 @@ TracksView::addTrack( Workflow::TrackType type )
m_scene->invalidate(); // Redraw the background
//Clips part:
connect( track->trackWorkflow(), SIGNAL( clipAdded( TrackWorkflow*, Workflow::Helper*, qint64 ) ),
this, SLOT( addItem( TrackWorkflow*, Workflow::Helper*, qint64 ) ) );
this, SLOT( addItem( TrackWorkflow*, Workflow::Helper*, qint64 ) ), Qt::QueuedConnection );
connect( track->trackWorkflow(), SIGNAL( clipRemoved( TrackWorkflow*, const QUuid& ) ),
this, SLOT( removeItem( TrackWorkflow*, const QUuid& ) ) );
this, SLOT( removeItem( TrackWorkflow*, const QUuid& ) ), Qt::QueuedConnection );
connect( track->trackWorkflow(), SIGNAL( clipMoved( TrackWorkflow*, const QUuid&, qint64 ) ),
this, SLOT( moveItem( TrackWorkflow*, const QUuid&, qint64 ) ) );
this, SLOT( moveItem( TrackWorkflow*, const QUuid&, qint64 ) ), Qt::QueuedConnection );
//Effect part:
connect( track->trackWorkflow(), SIGNAL( effectAdded( TrackWorkflow*, Workflow::Helper*, qint64 ) ),
this, SLOT(addItem( TrackWorkflow*, Workflow::Helper*, qint64 ) ) );
this, SLOT(addItem( TrackWorkflow*, Workflow::Helper*, qint64 ) ), Qt::QueuedConnection );
connect( track->trackWorkflow(), SIGNAL( effectRemoved( TrackWorkflow*, QUuid ) ),
this, SLOT( removeItem( TrackWorkflow*, QUuid ) ) );
this, SLOT( removeItem( TrackWorkflow*, QUuid ) ), Qt::QueuedConnection );
connect( track->trackWorkflow(), SIGNAL( effectMoved( TrackWorkflow*, QUuid, qint64 ) ),
this, SLOT( moveItem( TrackWorkflow*, QUuid, qint64 ) ) );
this, SLOT( moveItem( TrackWorkflow*, QUuid, qint64 ) ), Qt::QueuedConnection );
if ( type == Workflow::VideoTrack )
{
......@@ -414,9 +414,13 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
if ( itemList.size() > 0 )
{
AbstractGraphicsMediaItem *item = itemList.first();
ClipHelper *clipHelper = qobject_cast<ClipHelper*>( item->helper() );
Q_ASSERT( clipHelper != NULL );
m_dragEffectItem->setWidth( item->clipHelper()->length() );
m_dragEffectItem->setStartPos( item->startPos() );
m_dragEffectItem->setTrack( item->track() );
m_dragEffectItem->effectHelper()->setTarget( clipHelper->clipWorkflow() );
}
else
{
......@@ -429,6 +433,7 @@ TracksView::dragMoveEvent( QDragMoveEvent *event )
m_dragEffectItem->setWidth( m_dragEffectItem->helper()->length() );
m_dragEffectItem->setStartPos( 0 );
m_dragEffectItem->setTrack( track );
m_dragEffectItem->effectHelper()->setTarget( track->trackWorkflow() );
break ;
}
}
......@@ -945,10 +950,18 @@ TracksView::mouseMoveEvent( QMouseEvent *event )
AbstractGraphicsMediaItem *mediaItem = dynamic_cast<AbstractGraphicsMediaItem*>( collidingItem );
if ( mediaItem != NULL )
{
ClipHelper *clipHelper = qobject_cast<ClipHelper*>( mediaItem->helper() );
Q_ASSERT( clipHelper != NULL );
m_effectTarget = mediaItem;
effectItem->effectHelper()->setTarget( clipHelper->clipWorkflow() );
break ;
}
}
if ( m_effectTarget == NULL ) //Avoid doing this all the time.
{
GraphicsTrack *track = getTrack( m_actionItem->trackType(), m_actionItem->trackNumber() );
effectItem->effectHelper()->setTarget( track->trackWorkflow() );
}
}
}
else if ( event->modifiers() == Qt::NoModifier &&
......
......@@ -34,10 +34,11 @@
#include "Types.h"
#include <QApplication>
#include <QSettings>
#include <QFile>
#include <QColor>
#include <QFile>
#include <QPalette>
#include <QSettings>
#include <QUuid>
#ifdef Q_WS_X11
#include <X11/Xlib.h>
......@@ -65,6 +66,7 @@ VLMCmain( int argc, char **argv )
qRegisterMetaType<Workflow::TrackType>( "Workflow::TrackType" );
qRegisterMetaType<Vlmc::FrameChangedReason>( "Vlmc::FrameChangedReason" );
qRegisterMetaType<QVariant>( "QVariant" );
qRegisterMetaType<QUuid>( "QUuid" );
QSettings s;
LanguageHelper::getInstance()->languageChanged(
......
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