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

Timeline: Effects (filters) can be added to clips.

This disable global effects addition.
parent 24eeabaa
......@@ -342,3 +342,12 @@ AbstractGraphicsMediaItem::uuid() const
{
return m_clipHelper->uuid();
}
void
AbstractGraphicsMediaItem::setEmphasized( bool value )
{
if ( value == true )
setScale( 1.2 );
else
setScale( 1.0 );
}
......@@ -115,6 +115,8 @@ public:
QColor itemColor();
void setColor( const QColor& color );
virtual void setEmphasized( bool value );
/**
* \brief Return a pointer to the linked item.
* \details This method will return NULL if there is no linked item.
......
......@@ -225,22 +225,3 @@ Timeline::load( const QDomElement &root )
elem = elem.nextSiblingElement();
}
}
void
Timeline::dragEnterEvent( QDragEnterEvent *event )
{
if ( event->mimeData()->hasFormat("vlmc/effect_name") == true )
event->acceptProposedAction();
else
event->ignore();
}
void
Timeline::dropEvent( QDropEvent *event )
{
Effect* effect = EffectsEngine::getInstance()->effect( event->mimeData()->data( "vlmc/effect_name") );
if ( effect != NULL )
m_renderer->appendEffect( effect );
else
qWarning() << "Can't find effect name" << event->mimeData()->data( "vlmc/effect_name");
}
......@@ -82,16 +82,6 @@ public slots:
* \brief Change the currently selected tool.
*/
void setTool( ToolButtons button );
/**
* \brief Move an item in the timeline.
* \param uuid The Universally Unique Identifier of the item.
* \param track The new track of the item.
* \param time The new position (in frames) of the item.
*/
// void actionMoveClip( const QUuid& uuid, unsigned int track, qint64 time, Workflow::TrackType );
void dragEnterEvent( QDragEnterEvent *event );
void dropEvent( QDropEvent *event );
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -23,6 +23,7 @@
#include "TracksView.h"
#include "ClipHelper.h"
#include "ClipWorkflow.h"
#include "Commands.h"
#include "Library.h"
#include "GraphicsMovieItem.h"
......@@ -283,14 +284,33 @@ void
TracksView::dragEnterEvent( QDragEnterEvent *event )
{
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) )
{
event->acceptProposedAction();
else
clipDragEnterEvent( event );
}
else if ( event->mimeData()->hasFormat( "vlmc/effect_name" ) )
{
event->ignore();
return ;
event->acceptProposedAction();
effectDragEnterEvent( event );
}
else
event->ignore();
}
void
TracksView::effectDragEnterEvent( QDragEnterEvent *event )
{
Effect* effect = EffectsEngine::getInstance()->effect( event->mimeData()->data( "vlmc/effect_name") );
if ( effect != NULL )
m_dragEffect = effect;
else
qWarning() << "Can't find effect name" << event->mimeData()->data( "vlmc/effect_name");
}
QString fullId = QString( event->mimeData()->data( "vlmc/uuid" ) );
void
TracksView::clipDragEnterEvent( QDragEnterEvent *event )
{
const QString fullId = QString( event->mimeData()->data( "vlmc/uuid" ) );
Clip *clip = Library::getInstance()->clip( fullId );
if ( !clip ) return;
if ( clip->getMedia()->hasAudioTrack() == false &&
......@@ -330,15 +350,25 @@ TracksView::dragEnterEvent( QDragEnterEvent *event )
void
TracksView::dragMoveEvent( QDragMoveEvent *event )
{
AbstractGraphicsMediaItem* target;
if ( m_dragVideoItem != NULL )
target = m_dragVideoItem;
moveMediaItem( m_dragVideoItem, event->pos() );
else if ( m_dragAudioItem != NULL)
target = m_dragAudioItem;
else
return ;
moveMediaItem( target, event->pos() );
moveMediaItem( m_dragAudioItem, event->pos() );
else if ( m_dragEffect != NULL )
{
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
item->setEmphasized( false );
m_effectScaledItems.clear();
QList<AbstractGraphicsMediaItem*> items = mediaItems( event->pos() );
if ( items.size() > 0 )
{
foreach ( AbstractGraphicsMediaItem* item, items )
{
m_effectScaledItems.insert( item );
item->setEmphasized( true );
}
}
}
}
void
......@@ -661,6 +691,11 @@ TracksView::dragLeaveEvent( QDragLeaveEvent *event )
delete m_dragVideoItem;
m_dragAudioItem = NULL;
m_dragVideoItem = NULL;
m_dragEffect = NULL; //Don't delete the effect.
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
item->setEmphasized( false );
m_effectScaledItems.clear();
if ( updateDurationNeeded )
updateDuration();
......@@ -671,47 +706,60 @@ TracksView::dropEvent( QDropEvent *event )
{
qreal mappedXPos = ( mapToScene( event->pos() ).x() + 0.5 );;
UndoStack::getInstance()->beginMacro( "Add clip" );
if ( m_dragAudioItem )
if ( m_dragAudioItem != NULL || m_dragVideoItem != NULL )
{
m_clipsLoaded.insert( m_dragAudioItem->clipHelper()->uuid() );
UndoStack::getInstance()->beginMacro( "Add clip" );
updateDuration();
if ( getTrack( Workflow::AudioTrack, m_numAudioTrack - 1 )->childItems().count() > 0 )
addTrack( Workflow::AudioTrack );
event->acceptProposedAction();
if ( m_dragAudioItem )
{
m_clipsLoaded.insert( m_dragAudioItem->clipHelper()->uuid() );
m_dragAudioItem->m_oldTrack = m_dragAudioItem->track()->trackWorkflow();
m_dragAudioItem->oldPosition = (qint64)mappedXPos;
updateDuration();
if ( getTrack( Workflow::AudioTrack, m_numAudioTrack - 1 )->childItems().count() > 0 )
addTrack( Workflow::AudioTrack );
event->acceptProposedAction();
Commands::trigger( new Commands::MainWorkflow::AddClip( m_dragAudioItem->clipHelper(),
m_dragAudioItem->track()->trackWorkflow(),
(qint64)mappedXPos ) );
m_dragAudioItem = NULL;
}
m_dragAudioItem->m_oldTrack = m_dragAudioItem->track()->trackWorkflow();
m_dragAudioItem->oldPosition = (qint64)mappedXPos;
if ( m_dragVideoItem )
{
m_clipsLoaded.insert( m_dragVideoItem->clipHelper()->uuid() );
Commands::trigger( new Commands::MainWorkflow::AddClip( m_dragAudioItem->clipHelper(),
m_dragAudioItem->track()->trackWorkflow(),
(qint64)mappedXPos ) );
m_dragAudioItem = NULL;
}
updateDuration();
if ( getTrack( Workflow::VideoTrack, m_numVideoTrack - 1 )->childItems().count() > 0 )
addTrack( Workflow::VideoTrack );
event->acceptProposedAction();
if ( m_dragVideoItem )
{
m_clipsLoaded.insert( m_dragVideoItem->clipHelper()->uuid() );
m_dragVideoItem->m_oldTrack = m_dragVideoItem->track()->trackWorkflow();
m_dragVideoItem->oldPosition = (qint64)mappedXPos;
updateDuration();
if ( getTrack( Workflow::VideoTrack, m_numVideoTrack - 1 )->childItems().count() > 0 )
addTrack( Workflow::VideoTrack );
event->acceptProposedAction();
Commands::trigger( new Commands::MainWorkflow::AddClip( m_dragVideoItem->clipHelper(),
m_dragVideoItem->track()->trackWorkflow(),
(qint64)mappedXPos ) );
m_dragVideoItem = NULL;
}
m_dragVideoItem->m_oldTrack = m_dragVideoItem->track()->trackWorkflow();
m_dragVideoItem->oldPosition = (qint64)mappedXPos;
UndoStack::getInstance()->endMacro();
Commands::trigger( new Commands::MainWorkflow::AddClip( m_dragVideoItem->clipHelper(),
m_dragVideoItem->track()->trackWorkflow(),
(qint64)mappedXPos ) );
m_dragVideoItem = NULL;
}
m_lastKnownTrack = NULL;
UndoStack::getInstance()->endMacro();
m_lastKnownTrack = NULL;
}
else if ( m_dragEffect != NULL )
{
QList<AbstractGraphicsMediaItem*> items = mediaItems( event->pos() );
foreach ( AbstractGraphicsMediaItem *item, items )
{
item->clipHelper()->clipWorkflow()->appendEffect( m_dragEffect );
}
foreach ( AbstractGraphicsMediaItem *item, m_effectScaledItems )
item->setEmphasized( false );
}
}
void
......
......@@ -36,12 +36,13 @@ class QWheelEvent;
class QGraphicsWidget;
class QGraphicsLinearLayout;
class TracksScene;
class GraphicsMovieItem;
class ClipHelper;
class Effect;
class GraphicsAudioItem;
class GraphicsMovieItem;
class MainWorkflow;
class TracksScene;
class TrackWorkflow;
class ClipHelper;
class WorkflowRenderer;
class ItemPosition
......@@ -240,6 +241,9 @@ protected:
virtual void dragLeaveEvent( QDragLeaveEvent *event );
virtual void dropEvent( QDropEvent *event );
void clipDragEnterEvent( QDragEnterEvent *event );
void effectDragEnterEvent( QDragEnterEvent *event );
private slots:
/**
* \brief Ensure that the cursor is visible.
......@@ -327,6 +331,8 @@ private:
MainWorkflow *m_mainWorkflow;
GraphicsMovieItem *m_dragVideoItem;
GraphicsAudioItem *m_dragAudioItem;
Effect *m_dragEffect;
QSet<AbstractGraphicsMediaItem*> m_effectScaledItems;
QGraphicsWidget *m_separator;
ToolButtons m_tool;
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