Commit 52f33707 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Position can be updated from the timeline's cursor, but some display bug are still presents...

parent 7453e351
......@@ -49,7 +49,6 @@ MainWorkflow::MainWorkflow( int trackCount ) :
connect( m_tracks[i], SIGNAL( trackUnpaused() ), this, SLOT( trackUnpaused() ) );
connect( m_tracks[i], SIGNAL( renderCompleted( unsigned int ) ), this, SLOT( tracksRenderCompleted( unsigned int ) ), Qt::QueuedConnection );
}
muteTrack( 0 );
m_renderStartedLock = new QReadWriteLock;
m_renderMutex = new QMutex;
m_highestTrackNumberMutex = new QMutex;
......@@ -169,18 +168,14 @@ void MainWorkflow::unpause()
void MainWorkflow::nextFrame()
{
// qDebug() << "Going to the next frame";
++m_currentFrame;
//FIXME: This is probably a bit much...
emit frameChanged( m_currentFrame );
emit positionChanged( (float)m_currentFrame / (float)m_length );
}
void MainWorkflow::previousFrame()
{
// qDebug() << "Going to the previous frame";
--m_currentFrame;
//FIXME: This is probably a bit much...
emit frameChanged( m_currentFrame );
emit positionChanged( (float)m_currentFrame / (float)m_length );
}
......@@ -368,3 +363,9 @@ void MainWorkflow::unmuteTrack( unsigned int trackId )
{
m_tracks[trackId].setHardDeactivation( false );
}
void MainWorkflow::setCurrentFrame( qint64 currentFrame )
{
m_currentFrame = currentFrame;
emit positionChanged( (float)m_currentFrame / (float)m_length );
}
......@@ -51,6 +51,12 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
*/
void setPosition( float pos );
/**
* \brief Set the workflow position by the desired frame
* \param currentFrame: The desired frame to render from
*/
void setCurrentFrame( qint64 currentFrame );
/**
* \return Returns the global length of the workflow
* in frames.
......
......@@ -2,7 +2,7 @@
#include "GraphicsCursorItem.h"
GraphicsCursorItem::GraphicsCursorItem( int height, const QPen& pen )
: m_pen( pen )
: m_pen( pen ), m_moveRequired( false )
{
setFlags( QGraphicsItem::ItemIgnoresTransformations | QGraphicsItem::ItemIsMovable );
setCursor( QCursor( Qt::SizeHorCursor ) );
......@@ -32,7 +32,10 @@ QVariant GraphicsCursorItem::itemChange( GraphicsItemChange change, const QVaria
}
if ( change == ItemPositionHasChanged )
{
emit cursorPositionChanged( ( int ) pos().x() );
if ( m_moveRequired == false )
emit cursorPositionChanged( ( qint64 ) pos().x() );
else
m_moveRequired = false;
}
return QGraphicsItem::itemChange( change, value );
}
......@@ -40,6 +43,7 @@ QVariant GraphicsCursorItem::itemChange( GraphicsItemChange change, const QVaria
void GraphicsCursorItem::setCursorPos( int position )
{
setPos( position, pos().y() );
m_moveRequired = true;
}
void GraphicsCursorItem::updateCursorPos( qint64 position )
......
......@@ -26,9 +26,10 @@ protected:
private:
QPen m_pen;
QRectF m_boundingRect;
bool m_moveRequired;
signals:
void cursorPositionChanged( int pos );
void cursorPositionChanged( qint64 pos );
public slots:
void updateCursorPos( qint64 pos );
......
......@@ -43,7 +43,7 @@ TracksRuler::TracksRuler( TracksView* tracksView, QWidget* parent )
setPixelPerMark( 5 );
// Redraw the ruler when the cursor position change
connect( tracksView->tracksCursor(), SIGNAL( cursorPositionChanged(int) ),
connect( tracksView->tracksCursor(), SIGNAL( cursorPositionChanged(qint64) ),
this, SLOT( update() ) );
}
......
......@@ -63,7 +63,7 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
createLayout();
connect( m_cursorLine, SIGNAL( cursorPositionChanged(int) ),
connect( m_cursorLine, SIGNAL( cursorPositionChanged(qint64) ),
this, SLOT( ensureCursorVisible() ) );
}
......
......@@ -50,11 +50,12 @@ public:
{
m_mediaPlayer->setDrawable( renderWidget->winId() );
}
virtual void setPosition( float newPos ) = 0;
virtual void togglePlayPause( bool forcePause = false ) = 0;
virtual void nextFrame() = 0;
virtual void previousFrame() = 0;
virtual void stop() = 0;
virtual void setPosition( float newPos ) = 0;
bool isPaused() const
{
return m_paused;
......
......@@ -142,8 +142,11 @@ void WorkflowRenderer::startPreview()
connect( m_mainWorkflow, SIGNAL( frameChanged(qint64) ),
Timeline::getInstance()->tracksView()->tracksCursor(), SLOT( updateCursorPos( qint64 ) ) );
connect( Timeline::getInstance()->tracksView()->tracksCursor(), SIGNAL( cursorPositionChanged( qint64 ) ),
this, SLOT( timelineCursorChanged(qint64) ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowPaused() ), this, SLOT( mainWorkflowPaused() ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowUnpaused() ), this, SLOT( mainWorkflowUnpaused() ) );
m_mainWorkflow->startRender();
sprintf( buff, ":fake-duration=%lli", m_mainWorkflow->getLength() / FPS * 1000 );
m_media->addOption( buff );
......@@ -289,3 +292,8 @@ void WorkflowRenderer::__videoStopped()
{
emit endReached();
}
void WorkflowRenderer::timelineCursorChanged( qint64 newFrame )
{
m_mainWorkflow->setCurrentFrame( newFrame );
}
......@@ -84,6 +84,7 @@ class WorkflowRenderer : public GenericRenderer
public slots:
void setClip( Clip* ){}
void mediaUnloaded( const QUuid& ) {}
void timelineCursorChanged( qint64 newFrame );
void __positionChanged();
void __positionChanged( float pos );
......
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