Commit c6036b72 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Refactored position setting.

Everything is now handled in frames, and not in "vlc positions"
parent 9191079a
......@@ -63,9 +63,9 @@ QVariant GraphicsCursorItem::itemChange( GraphicsItemChange change, const QVaria
return QGraphicsItem::itemChange( change, value );
}
void GraphicsCursorItem::frameChanged( qint64 newFrame, GenericRenderer::FrameChangedReason reason )
void GraphicsCursorItem::frameChanged( qint64 newFrame, MainWorkflow::FrameChangedReason reason )
{
if ( reason != GenericRenderer::TimelineCursor )
if ( reason != MainWorkflow::TimelineCursor )
{
m_manualMove = false;
setPos( newFrame, pos().y() );
......
......@@ -54,7 +54,7 @@ signals:
void cursorPositionChanged( qint64 pos );
public slots:
void frameChanged( qint64 position, GenericRenderer::FrameChangedReason );
void frameChanged( qint64 position, MainWorkflow::FrameChangedReason );
};
#endif // GRAPHICSCURSORITEM_H
......@@ -62,7 +62,7 @@ MainWindow::MainWindow( QWidget *parent ) :
{
m_ui.setupUi( this );
qRegisterMetaType<MainWorkflow::TrackType>( "MainWorkflow::TrackType" );
qRegisterMetaType<GenericRenderer::FrameChangedReason>( "GenericRenderer::FrameChangedReason" );
qRegisterMetaType<MainWorkflow::FrameChangedReason>( "MainWorkflow::FrameChangedReason" );
DockWidgetManager::instance( this )->setMainWindow( this );
initializeDockWidgets();
createStatusBar();
......
......@@ -27,48 +27,29 @@
#include <QBrush>
#include "PreviewRuler.h"
PreviewRuler::PreviewRuler( QWidget* parent ) : QAbstractSlider( parent ), m_renderer( NULL ), m_frame( NULL )
PreviewRuler::PreviewRuler( QWidget* parent ) :
QWidget( parent ),
m_renderer( NULL ),
m_frame( NULL )
{
setMouseTracking( true );
m_isSliding = false;
m_range = maximum() - minimum();
}
void PreviewRuler::setRenderer( GenericRenderer* renderer )
{
if ( m_renderer )
{
disconnect( m_renderer, SIGNAL( positionChanged(float) ) );
disconnect( m_renderer, SIGNAL( frameChanged(qint64, GenericRenderer::FrameChangedReason ) ) );
disconnect( m_renderer, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason ) ) );
}
m_renderer = renderer;
connect( m_renderer, SIGNAL( positionChanged(float) ), this, SLOT( update() ) );
connect( m_renderer, SIGNAL( frameChanged(qint64,GenericRenderer::FrameChangedReason) ),
connect( m_renderer, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
this, SLOT( update() ) );
connect( m_renderer, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
this, SLOT( updateTimecode( qint64 ) ) );
}
void PreviewRuler::sliderChange( SliderChange change )
{
switch ( change )
{
case QAbstractSlider::SliderRangeChange:
m_range = maximum() - minimum();
break;
case QAbstractSlider::SliderOrientationChange:
qWarning("PreviewRuler: Slider orientation is not supported.");
break;
case QAbstractSlider::SliderStepsChange:
qWarning("PreviewRuler: Slider steps are not supported.");
break;
case QAbstractSlider::SliderValueChange:
m_frame = value() * m_renderer->getLengthMs() / m_range;
update();
updateTimecode();
break;
}
}
void PreviewRuler::paintEvent( QPaintEvent * event )
{
Q_UNUSED( event );
......@@ -81,17 +62,17 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
painter.setBrush( QBrush( QColor( 50, 50, 50 ) ) );
painter.drawRect( marks );
if ( m_renderer->getLengthMs() > 0 )
if ( m_renderer->getLength() > 0 )
{
qreal linesToDraw = 0;
qreal spacing = 0;
QRect r = marks.adjusted( 1, 0, -1, 0 );
// Draw the marks
if ( r.width() / 2 >= m_renderer->getLengthMs() )
if ( r.width() / 2 >= m_renderer->getLength() )
{ // Every frame
painter.setPen( QPen( Qt::cyan ) );
linesToDraw = (qreal)m_renderer->getLengthMs();
linesToDraw = (qreal)m_renderer->getLength();
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -99,10 +80,10 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_XSMALL, r.left() + step * spacing, r.bottom() ) );
}
}
if ( r.width() / 2 >= ( m_renderer->getLengthMs() / 25 ) )
if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() ) )
{ // Every second
painter.setPen( QPen( Qt::green ) );
linesToDraw = (qreal)m_renderer->getLengthMs() / 25;
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps();
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -110,10 +91,10 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_XSMALL, r.left() + step * spacing, r.bottom() ) );
}
}
else if ( r.width() / 2 >= ( m_renderer->getLengthMs() / 25 / 12 ) )
else if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 12 ) )
{ // Every 5 seconds
painter.setPen( QPen( Qt::green ) );
linesToDraw = (qreal)m_renderer->getLengthMs() / 25 / 12;
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 12;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -121,10 +102,10 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
painter.drawLine( QLineF( r.left() + step * spacing, r.height() - MARK_SMALL, r.left() + step * spacing, r.bottom() ) );
}
}
if ( r.width() / 2 >= ( m_renderer->getLengthMs() / 25 / 60 ) )
if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 ) )
{ // Every minute
painter.setPen( QPen( Qt::yellow ) );
linesToDraw = (qreal)m_renderer->getLengthMs() / 25 / 60;
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -133,10 +114,10 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
}
}
else if ( r.width() / 2 >= ( m_renderer->getLengthMs() / 25 / 60 / 12 ) )
else if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 / 12 ) )
{ // Every 5 minutes
painter.setPen( QPen( Qt::yellow ) );
linesToDraw = (qreal)m_renderer->getLengthMs() / 25 / 60 / 12;
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60 / 12;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -145,10 +126,10 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
}
}
if ( r.width() / 2 >= ( m_renderer->getLengthMs() / 25 / 60 / 60 ) )
if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 / 60 ) )
{ // Every hour
painter.setPen( QPen( Qt::red ) );
linesToDraw = (qreal)m_renderer->getLengthMs() / 25 / 60 / 60;
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60 / 60;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -165,10 +146,12 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
int cursorPos;
if ( m_renderer->getLengthMs() > 0 )
cursorPos = m_frame * width() / m_renderer->getLengthMs();
if ( m_renderer->getLength() > 0 )
{
cursorPos = m_frame * width() / m_renderer->getLength();
}
else
cursorPos = value() * width() / m_range;
cursorPos = 0;
cursorPos = qMin( qMax( cursorPos, 0 ), width() );
cursor.setPoints( 3, cursorPos - 5, 20, cursorPos + 5, 20, cursorPos, 9 );
......@@ -179,12 +162,9 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
void PreviewRuler::mousePressEvent( QMouseEvent* event )
{
m_isSliding = true;
if ( m_renderer->getLengthMs() )
setFrame( event->pos().x() * m_renderer->getLengthMs() / width() );
else
if ( m_renderer->getLength() > 0 )
{
setValue( ( event->pos().x() * m_range / width() ) + minimum() );
emit sliderPosChanged( ( event->pos().x() * m_range / width() ) + minimum() );
setFrame( (qreal)(event->pos().x() * m_renderer->getLength() ) / width() );
}
}
......@@ -192,34 +172,29 @@ void PreviewRuler::mouseMoveEvent( QMouseEvent* event )
{
if ( m_isSliding )
{
if ( m_renderer->getLengthMs() )
setFrame( event->pos().x() * m_renderer->getLengthMs() / width() );
else
{
setValue( ( event->pos().x() * m_range / width() ) + minimum() );
emit sliderPosChanged( ( event->pos().x() * m_range / width() ) + minimum() );
}
if ( m_renderer->getLength() > 0 )
setFrame( (qreal)(event->pos().x() * m_renderer->getLength() ) / width() );
}
}
void PreviewRuler::mouseReleaseEvent( QMouseEvent * event )
void PreviewRuler::mouseReleaseEvent( QMouseEvent* )
{
Q_UNUSED( event );
m_isSliding = false;
}
void PreviewRuler::setFrame( qint64 frame )
{
m_frame = frame;
setValue( frame * m_range / m_renderer->getLengthMs() );
if ( m_isSliding )
emit sliderPosChanged( frame * m_range / m_renderer->getLengthMs() );
{
emit frameChanged( frame, MainWorkflow::PreviewCursor );
}
update();
}
void PreviewRuler::updateTimecode( qint64 frames /*= -1*/ )
{
if ( m_renderer->getLengthMs() )
if ( m_renderer->getLength() > 0 )
{
int fps = (int)m_renderer->getFps();
if ( frames == -1 )
......
......@@ -34,7 +34,7 @@
#define MARK_MEDIUM 8
#define MARK_LARGE 11
class PreviewRuler : public QAbstractSlider
class PreviewRuler : public QWidget
{
Q_OBJECT
public:
......@@ -50,20 +50,17 @@ protected:
virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent * event );
virtual void sliderChange( SliderChange change );
private slots:
void updateTimecode( qint64 frames = -1 );
private:
GenericRenderer* m_renderer;
qint64 m_frame;
bool m_isSliding;
int m_range;
GenericRenderer* m_renderer;
qint64 m_frame;
bool m_isSliding;
signals:
void frameChanged( qint64 );
void sliderPosChanged( int value );
void frameChanged( qint64, MainWorkflow::FrameChangedReason );
void timeChanged( int h, int m, int s, int f );
};
......
......@@ -37,9 +37,6 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
{
m_ui->setupUi( this );
m_ui->rulerWidget->setMinimum( 0 );
m_ui->rulerWidget->setMaximum( 1000 );
m_ui->rulerWidget->setSingleStep( 2 );
m_ui->rulerWidget->setFocusPolicy( Qt::NoFocus );
// Prepare and set the black background
......@@ -53,9 +50,6 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
setAcceptDrops( false );
connect( m_ui->rulerWidget, SIGNAL( sliderPressed() ), this, SLOT( seekSliderPressed() ) );
connect( m_ui->rulerWidget, SIGNAL( sliderPosChanged(int) ), this, SLOT( seekSliderMoved(int) ) );
connect( m_ui->rulerWidget, SIGNAL( sliderReleased() ), this, SLOT( seekSliderReleased() ) );
connect( m_ui->rulerWidget, SIGNAL( timeChanged(int,int,int,int) ),
m_ui->lcdNumber, SLOT( setTime(int,int,int,int) ) );
......@@ -63,13 +57,14 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
m_renderer->setPreviewLabel( m_ui->previewLabel );
m_ui->previewLabel->hide();
connect( m_renderer, SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
connect( m_renderer, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( m_renderer, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( m_renderer, SIGNAL( positionChanged(float) ), this, SLOT( positionChanged(float) ) );
connect( m_renderer, SIGNAL( frameChanged(qint64,GenericRenderer::FrameChangedReason) ),
this, SLOT( frameChanged(qint64, GenericRenderer::FrameChangedReason ) ) );
connect( m_renderer, SIGNAL( endReached() ), this, SLOT( endReached() ) );
connect( m_renderer, SIGNAL( stopped() ), this, SLOT( videoStopped() ) );
connect( m_renderer, SIGNAL( paused() ), this, SLOT( videoPaused() ) );
connect( m_renderer, SIGNAL( playing() ), this, SLOT( videoPlaying() ) );
connect( m_renderer, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
this, SLOT( frameChanged(qint64, MainWorkflow::FrameChangedReason ) ) );
connect( m_renderer, SIGNAL( endReached() ), this, SLOT( endReached() ) );
connect( m_ui->rulerWidget, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
m_renderer, SLOT( previewWidgetCursorChanged(qint64) ) );
}
PreviewWidget::~PreviewWidget()
......@@ -90,53 +85,14 @@ void PreviewWidget::changeEvent( QEvent *e )
}
}
void PreviewWidget::positionChanged( float newPos )
void PreviewWidget::frameChanged( qint64 currentFrame, MainWorkflow::FrameChangedReason reason )
{
if ( m_previewStopped == false )
m_ui->rulerWidget->setValue( (int)( newPos * 1000.0 ) );
}
void PreviewWidget::frameChanged( qint64 currentFrame, GenericRenderer::FrameChangedReason reason )
{
if ( m_previewStopped == false && reason != GenericRenderer::PreviewCursor )
if ( m_previewStopped == false && reason != MainWorkflow::PreviewCursor )
{
m_ui->rulerWidget->setFrame( currentFrame );
}
}
void PreviewWidget::seekSliderPressed()
{
disconnect( m_renderer, SIGNAL( positionChanged( float ) ),
this, SLOT( positionChanged( float ) ) );
}
void PreviewWidget::seekSliderMoved( int )
{
if ( m_ui->rulerWidget->value() == m_ui->rulerWidget->maximum() )
{
m_endReached = true;
return;
}
m_endReached = false;
//Putting back the slider value into vlc position
m_renderer->setPosition( (float)m_ui->rulerWidget->value() / 1000.0f );
}
void PreviewWidget::seekSliderReleased()
{
if ( m_endReached == true && m_previewStopped == false )
{
//When cursor reaches the maximum right, end reached becomes true.
//When we will release our slider, if endReached is true, we actually set the position.
//Otherwise, we do nothing.
//This prevents the video to stop if we put the slider to the maximum right by mistake
m_renderer->setPosition( (float)m_ui->rulerWidget->maximum() );
m_previewStopped = false;
}
connect( m_renderer, SIGNAL( positionChanged( float ) ),
this, SLOT( positionChanged( float ) ) );
}
void PreviewWidget::on_pushButtonStop_clicked()
{
if ( m_previewStopped == false )
......@@ -161,7 +117,6 @@ void PreviewWidget::videoPaused()
void PreviewWidget::videoStopped()
{
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/play" ) );
m_ui->rulerWidget->setValue( 0 );
}
void PreviewWidget::videoPlaying()
......@@ -174,7 +129,6 @@ void PreviewWidget::endReached()
m_previewStopped = true;
m_ui->pushButtonPlay->setIcon( QIcon( ":/images/play" ) );
m_ui->rulerWidget->setValue( 0 );
// Set the black background
m_ui->renderWidget->setPalette( m_videoPalette );
......
......@@ -61,11 +61,7 @@ private slots:
void on_pushButtonStop_clicked();
void on_pushButtonNextFrame_clicked();
void on_pushButtonPreviousFrame_clicked();
void positionChanged( float );
void frameChanged( qint64, GenericRenderer::FrameChangedReason reason );
void seekSliderPressed();
void seekSliderMoved( int value );
void seekSliderReleased();
void frameChanged( qint64, MainWorkflow::FrameChangedReason reason );
void videoPaused();
void videoPlaying();
void videoStopped();
......
......@@ -81,8 +81,8 @@ Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) :
connect( m_tracksView, SIGNAL( audioTrackAdded(GraphicsTrack*) ),
m_tracksControls, SLOT( addAudioTrack(GraphicsTrack*) ) );
connect( m_renderer, SIGNAL( frameChanged(qint64, GenericRenderer::FrameChangedReason) ),
m_tracksView->tracksCursor(), SLOT( frameChanged( qint64, GenericRenderer::FrameChangedReason ) ),
connect( m_renderer, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
m_tracksView->tracksCursor(), SLOT( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ),
Qt::QueuedConnection );
connect( m_tracksView->tracksCursor(), SIGNAL( cursorPositionChanged( qint64 ) ),
m_renderer, SLOT( timelineCursorChanged(qint64) ) );
......
......@@ -632,7 +632,7 @@ QList<AbstractGraphicsMediaItem*> TracksView::mediaItems( const QPoint& pos )
void TracksView::setCursorPos( qint64 pos )
{
if ( pos < 0 ) pos = 0;
m_cursorLine->frameChanged( pos, GenericRenderer::TimelineCursor );
m_cursorLine->frameChanged( pos, MainWorkflow::TimelineCursor );
}
qint64 TracksView::cursorPos()
......
......@@ -25,6 +25,7 @@
#include <QtGlobal>
#include "ClipRenderer.h"
#include "MainWorkflow.h"
ClipRenderer::ClipRenderer() :
GenericRenderer(),
......@@ -114,16 +115,6 @@ void ClipRenderer::startPreview()
m_mediaChanged = false;
}
void ClipRenderer::setPosition( float newPos )
{
if ( m_clipLoaded == false || m_isRendering == false )
return ;
float begin = m_begin / ( m_end - m_begin );
float end = m_end / ( m_end - m_begin );
float pos = newPos * ( end - begin ) + begin;
m_mediaPlayer->setPosition( pos );
}
void ClipRenderer::stop()
{
if ( m_clipLoaded == true && m_isRendering == true )
......@@ -140,7 +131,7 @@ void ClipRenderer::togglePlayPause( bool forcePause )
{
if ( m_clipLoaded == false )
{
emit positionChanged( 0 );
emit frameChanged( 0, MainWorkflow::Renderer );
startPreview();
return ;
}
......@@ -226,6 +217,15 @@ float ClipRenderer::getFps() const
return 0.0f;
}
void ClipRenderer::previewWidgetCursorChanged( qint64 newFrame )
{
if ( m_isRendering == true )
{
qint64 nbSeconds = qRound64( (qreal)newFrame / m_selectedMedia->getFps() );
m_mediaPlayer->setTime( nbSeconds / 1000 );
}
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////
......@@ -253,13 +253,13 @@ void ClipRenderer::__positionChanged()
float end = m_end / ( m_end - m_begin );
float pos = ( m_mediaPlayer->getPosition() - begin ) /
( end - begin );
emit positionChanged( pos );
emit frameChanged( pos, MainWorkflow::Renderer );
}
void ClipRenderer::__timeChanged()
{
qint64 f = qRound64( (qreal)m_mediaPlayer->getTime() / 1000.0 * (qreal)m_mediaPlayer->getFps() );
emit frameChanged( f, Renderer );
emit frameChanged( f, MainWorkflow::Renderer );
}
void ClipRenderer::__endReached()
......
......@@ -39,7 +39,6 @@ public:
explicit ClipRenderer();
virtual ~ClipRenderer();
virtual void setPosition( float newPos );
virtual void togglePlayPause( bool forcePause );
virtual void stop();
virtual void nextFrame();
......@@ -68,6 +67,7 @@ public slots:
virtual void setClip( Clip* clip );
virtual void setMedia( Media* media );
virtual void mediaUnloaded( const QUuid& );
virtual void previewWidgetCursorChanged( qint64 newFrame );
void __positionChanged();
void __timeChanged();
......
......@@ -29,6 +29,7 @@
#include "Clip.h"
#include "VLCMediaPlayer.h"
#include "MainWorkflow.h"
class GenericRenderer : public QObject
{
......@@ -36,12 +37,6 @@ class GenericRenderer : public QObject
Q_DISABLE_COPY( GenericRenderer );
public:
enum FrameChangedReason
{
Renderer,
TimelineCursor,
PreviewCursor,
};
explicit GenericRenderer() :
m_paused( false ),
m_isRendering( false )
......@@ -79,12 +74,6 @@ public:
*/
virtual void stop() = 0;
/**
* \brief Sets the position in the video
* The value should be bounded between 0.0 and 1.0
*/
virtual void setPosition( float newPos ) = 0;
/**
* \brief Return the length in milliseconds
*/
......@@ -106,7 +95,7 @@ public:
*/
qint64 getLength() const
{
return qRound64( (qreal)getLengthMs() / 1000 * (qreal)getFps() );
return qRound64( (qreal)getLengthMs() / 1000.0 * (qreal)getFps() );
}
/**
......@@ -144,21 +133,20 @@ protected:
public slots:
virtual void __positionChanged() = 0;
virtual void __videoPaused() = 0;
virtual void __videoPlaying() = 0;
virtual void __endReached() = 0;
virtual void setClip( Clip* ) = 0;
virtual void setMedia( Media* ) = 0;
virtual void mediaUnloaded( const QUuid& ) = 0;
virtual void previewWidgetCursorChanged( qint64 ) = 0;
signals:
void stopped();
void paused();
void playing();
void positionChanged( float );
void frameChanged( qint64, GenericRenderer::FrameChangedReason );
void frameChanged( qint64, MainWorkflow::FrameChangedReason );
void endReached();
};
......
......@@ -77,11 +77,6 @@ void WorkflowFileRenderer::stop()
m_dialog->done( 0 );
}
void WorkflowFileRenderer::positionChanged( float newPos )
{
m_dialog->setProgressBarValue( static_cast<int>( newPos * 100 ) );
}
void WorkflowFileRenderer::cancelButtonClicked()
{
stop();
......
......@@ -48,7 +48,6 @@ private:
private slots:
void stop();
void positionChanged( float newPos );
void cancelButtonClicked();
};
......
......@@ -153,8 +153,8 @@ void WorkflowRenderer::startPreview()
connect( m_mediaPlayer, SIGNAL( paused() ), this, SLOT( __videoPaused() ), Qt::DirectConnection );
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SLOT( __videoStopped() ) );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( __endReached() ) );
connect( m_mainWorkflow, SIGNAL( frameChanged( qint64 ) ),
this, SLOT( __frameChanged( qint64 ) ) );
connect( m_mainWorkflow, SIGNAL( frameChanged( qint64, MainWorkflow::FrameChangedReason ) ),
this, SLOT( __frameChanged( qint64, MainWorkflow::FrameChangedReason ) ) );
m_mainWorkflow->setFullSpeedRender( false );
m_mainWorkflow->startRender();
......@@ -165,12 +165,6 @@ void WorkflowRenderer::startPreview()
m_outputFps = SettingsManager::getInstance()->getValue( "default", "VLMCPreviewFPS" ).toDouble();
}
void WorkflowRenderer::setPosition( float newPos )
{
qDebug() << "Setting position to:" << newPos;
m_mainWorkflow->setPosition( newPos );
}
void WorkflowRenderer::nextFrame()
{
m_mainWorkflow->nextFrame();
......@@ -307,6 +301,16 @@ void WorkflowRenderer::addClip( Clip* clip, uint32_t trackNumber, qint64
m_mainWorkflow->addClip( clip, trackNumber, startingPos, trackType );
}
void WorkflowRenderer::timelineCursorChanged( qint64 newFrame )
{
m_mainWorkflow->setCurrentFrame( newFrame, MainWorkflow::TimelineCursor );
}
void WorkflowRenderer::previewWidgetCursorChanged( qint64 newFrame )
{
m_mainWorkflow->setCurrentFrame( newFrame, MainWorkflow::PreviewCursor );
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////
......@@ -317,9 +321,9 @@ void WorkflowRenderer::__endReached()
emit endReached();
}
void WorkflowRenderer::__frameChanged( qint64 frame )
void WorkflowRenderer::__frameChanged( qint64 frame, MainWorkflow::FrameChangedReason reason )
{
emit frameChanged( frame, Renderer );
emit frameChanged( frame, reason );
}
void WorkflowRenderer::__videoPaused()
......@@ -344,7 +348,3 @@ void WorkflowRenderer::__videoStopped()
emit endReached();
}
void WorkflowRenderer::timelineCursorChanged( qint64 newFrame )
{
m_mainWorkflow->setCurrentFrame( newFrame );
}
......@@ -57,12 +57,6 @@ class WorkflowRenderer : public GenericRenderer
WorkflowRenderer();
~WorkflowRenderer();
/**
\brief Set the preview position
\param newPos : The new position in vlc position (between
0 and 1)
*/
virtual void setPosition( float newPos );
virtual void togglePlayPause( bool forcePause );
virtual void stop();
virtual void nextFrame();
......@@ -104,9 +98,9 @@ class WorkflowRenderer : public GenericRenderer
virtual void setMedia( Media* ) {}
void mediaUnloaded( const QUuid& ) {}
void timelineCursorChanged( qint64 newFrame );
void previewWidgetCursorChanged( qint64 newFrame );
void __positionChanged() { qFatal("Get out."); }
void __frameChanged( qint64 frame );
void __frameChanged( qint64 frame, MainWorkflow::FrameChangedReason );
void __videoPaused();
void __videoStopped();
void __videoPlaying();
......
......@@ -154,7 +154,7 @@ void MainWorkflow::nextFrame()
QWriteLocker lock( m_currentFrameLock );
++m_currentFrame;
emit frameChanged( m_currentFrame );
emit frameChanged( m_currentFrame, Renderer );
}
void MainWorkflow::previousFrame()
......@@ -162,24 +162,7 @@ void MainWorkflow::previousFrame()
QWriteLocker lock( m_currentFrameLock );
--m_currentFrame;
emit frameChanged( m_currentFrame );
}
void MainWorkflow::setPosition( float pos )
{
if ( m_renderStarted == true )
{
//Since any track can be reactivated, we reactivate all of them, and let them
//unable themself if required.
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i)
m_tracks[i]->activateAll();
}
QReadLocker lock( m_currentFrameLock );
qint64 frame = static_cast<qint64>( (float)m_lengthFrame * pos );
m_currentFrame = frame;
emit frameChanged( frame );
//Do not emit a signal for the RenderWidget, since it's the one that triggered that call...
emit frameChanged( m_currentFrame, Renderer );
}
qint64 MainWorkflow::getLengthFrame() const
......@@ -201,7 +184,7 @@ void MainWorkflow::stop()
for (unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i)
m_tracks[i]->stop();
m_currentFrame = 0;
emit frameChanged( 0 );