[vlmc-devel] commit: Allow more than one effect per track/clip ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Sun Sep 26 18:23:08 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sun Sep 26 17:04:25 2010 +0200| [394bf8648ef8e8fe10158b40b7980fbc1c8564ca] | committer: Hugo Beauzée-Luyssen
Allow more than one effect per track/clip
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=394bf8648ef8e8fe10158b40b7980fbc1c8564ca
---
src/EffectsEngine/EffectUser.cpp | 18 +++++++++++++++++-
src/EffectsEngine/EffectUser.h | 1 +
src/Gui/timeline/AbstractGraphicsItem.h | 1 -
src/Gui/timeline/GraphicsEffectItem.cpp | 16 +++++++++++++++-
src/Gui/timeline/GraphicsEffectItem.h | 2 ++
src/Gui/timeline/TracksView.cpp | 25 +++++++++++++++++++------
src/Main/guimain.cpp | 6 ++++--
7 files changed, 58 insertions(+), 11 deletions(-)
diff --git a/src/EffectsEngine/EffectUser.cpp b/src/EffectsEngine/EffectUser.cpp
index 8d0d1eb..3b1c1ad 100644
--- a/src/EffectsEngine/EffectUser.cpp
+++ b/src/EffectsEngine/EffectUser.cpp
@@ -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;
+}
diff --git a/src/EffectsEngine/EffectUser.h b/src/EffectsEngine/EffectUser.h
index 50eeec3..0fcff18 100644
--- a/src/EffectsEngine/EffectUser.h
+++ b/src/EffectsEngine/EffectUser.h
@@ -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();
diff --git a/src/Gui/timeline/AbstractGraphicsItem.h b/src/Gui/timeline/AbstractGraphicsItem.h
index cbdad48..2fb098a 100644
--- a/src/Gui/timeline/AbstractGraphicsItem.h
+++ b/src/Gui/timeline/AbstractGraphicsItem.h
@@ -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 );
diff --git a/src/Gui/timeline/GraphicsEffectItem.cpp b/src/Gui/timeline/GraphicsEffectItem.cpp
index af23ffc..1aba88f 100644
--- a/src/Gui/timeline/GraphicsEffectItem.cpp
+++ b/src/Gui/timeline/GraphicsEffectItem.cpp
@@ -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 );
+}
diff --git a/src/Gui/timeline/GraphicsEffectItem.h b/src/Gui/timeline/GraphicsEffectItem.h
index 7753c3b..0f7359f 100644
--- a/src/Gui/timeline/GraphicsEffectItem.h
+++ b/src/Gui/timeline/GraphicsEffectItem.h
@@ -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 );
diff --git a/src/Gui/timeline/TracksView.cpp b/src/Gui/timeline/TracksView.cpp
index d03c487..f6dca13 100644
--- a/src/Gui/timeline/TracksView.cpp
+++ b/src/Gui/timeline/TracksView.cpp
@@ -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 &&
diff --git a/src/Main/guimain.cpp b/src/Main/guimain.cpp
index 3cc7499..9459110 100644
--- a/src/Main/guimain.cpp
+++ b/src/Main/guimain.cpp
@@ -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(
More information about the Vlmc-devel
mailing list