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

EffectUser: Adding a length() method

parent 66f41dc2
......@@ -51,6 +51,7 @@ class EffectUser : public QObject
void swapFilters( qint32 idx, qint32 idx2 );
qint32 count( Effect::Type type ) const;
void cleanEffects();
virtual qint64 length() const = 0;
protected:
EffectUser();
......
......@@ -66,17 +66,17 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
painter.setBrush( QBrush( QColor( 50, 50, 50 ) ) );
painter.drawRect( marks );
if ( m_renderer->getLength() > 0 )
if ( m_renderer->length() > 0 )
{
qreal linesToDraw = 0;
qreal spacing = 0;
QRect r = marks.adjusted( 1, 0, -1, 0 );
// Draw the marks
if ( r.width() / 2 >= m_renderer->getLength() )
if ( r.width() / 2 >= m_renderer->length() )
{ // Every frame
painter.setPen( QPen( Qt::cyan ) );
linesToDraw = (qreal)m_renderer->getLength();
linesToDraw = (qreal)m_renderer->length();
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -84,10 +84,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->getLength() / m_renderer->getFps() ) )
if ( r.width() / 2 >= ( m_renderer->length() / m_renderer->getFps() ) )
{ // Every second
painter.setPen( QPen( Qt::green ) );
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps();
linesToDraw = (qreal)m_renderer->length() / m_renderer->getFps();
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -95,10 +95,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->getLength() / m_renderer->getFps() / 12 ) )
else if ( r.width() / 2 >= ( m_renderer->length() / m_renderer->getFps() / 12 ) )
{ // Every 5 seconds
painter.setPen( QPen( Qt::green ) );
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 12;
linesToDraw = (qreal)m_renderer->length() / m_renderer->getFps() / 12;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -106,10 +106,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->getLength() / m_renderer->getFps() / 60 ) )
if ( r.width() / 2 >= ( m_renderer->length() / m_renderer->getFps() / 60 ) )
{ // Every minute
painter.setPen( QPen( Qt::yellow ) );
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60;
linesToDraw = (qreal)m_renderer->length() / m_renderer->getFps() / 60;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -118,10 +118,10 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
}
}
else if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 / 12 ) )
else if ( r.width() / 2 >= ( m_renderer->length() / m_renderer->getFps() / 60 / 12 ) )
{ // Every 5 minutes
painter.setPen( QPen( Qt::yellow ) );
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60 / 12;
linesToDraw = (qreal)m_renderer->length() / m_renderer->getFps() / 60 / 12;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -130,10 +130,10 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
}
}
if ( r.width() / 2 >= ( m_renderer->getLength() / m_renderer->getFps() / 60 / 60 ) )
if ( r.width() / 2 >= ( m_renderer->length() / m_renderer->getFps() / 60 / 60 ) )
{ // Every hour
painter.setPen( QPen( Qt::red ) );
linesToDraw = (qreal)m_renderer->getLength() / m_renderer->getFps() / 60 / 60;
linesToDraw = (qreal)m_renderer->length() / m_renderer->getFps() / 60 / 60;
if ( linesToDraw > 0 )
{
spacing = (qreal)r.width() / linesToDraw;
......@@ -147,7 +147,7 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
if ( m_markerStart > MARKER_DEFAULT )
{
int markerPos = m_markerStart * width() / m_renderer->getLength();
int markerPos = m_markerStart * width() / m_renderer->length();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos + 8, 1,
......@@ -158,7 +158,7 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
}
if ( m_markerStop > MARKER_DEFAULT )
{
int markerPos = m_markerStop * width() / m_renderer->getLength();
int markerPos = m_markerStop * width() / m_renderer->length();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos - 8, 1,
......@@ -177,9 +177,9 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
int cursorPos;
if ( m_renderer->getLength() > 0 )
if ( m_renderer->length() > 0 )
{
cursorPos = m_frame * width() / m_renderer->getLength();
cursorPos = m_frame * width() / m_renderer->length();
}
else
cursorPos = 0;
......@@ -193,9 +193,9 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
void PreviewRuler::mousePressEvent( QMouseEvent* event )
{
m_isSliding = true;
if ( m_renderer->getLength() > 0 )
if ( m_renderer->length() > 0 )
{
setFrame( (qreal)(event->pos().x() * m_renderer->getLength() ) / width(), true );
setFrame( (qreal)(event->pos().x() * m_renderer->length() ) / width(), true );
}
}
......@@ -203,11 +203,11 @@ void PreviewRuler::mouseMoveEvent( QMouseEvent* event )
{
if ( m_isSliding )
{
if ( m_renderer->getLength() > 0 )
if ( m_renderer->length() > 0 )
{
qint64 pos = event->pos().x();
pos = qBound( (qint64)0, m_renderer->getLength(), pos );
setFrame( (qreal)(pos * m_renderer->getLength() ) / width(), true );
pos = qBound( (qint64)0, m_renderer->length(), pos );
setFrame( (qreal)(pos * m_renderer->length() ) / width(), true );
}
}
}
......@@ -229,7 +229,7 @@ void PreviewRuler::setFrame( qint64 frame, bool broadcastEvent /*= false*/ )
void PreviewRuler::updateTimecode( qint64 frames /*= -1*/ )
{
if ( m_renderer->getLength() > 0 )
if ( m_renderer->length() > 0 )
{
int fps = (int)m_renderer->getFps();
......
......@@ -171,7 +171,7 @@ ClipRenderer::previousFrame()
}
qint64
ClipRenderer::getLength() const
ClipRenderer::length() const
{
return m_end - m_begin;
}
......
......@@ -49,7 +49,7 @@ public:
virtual void stop();
virtual void nextFrame();
virtual void previousFrame();
virtual qint64 getLength() const;
virtual qint64 length() const;
virtual qint64 getLengthMs() const;
virtual qint64 getCurrentFrame() const;
virtual float getFps() const;
......
......@@ -121,7 +121,7 @@ public:
* \return The length that has to be rendered in frames
* \sa getLengthMs()
*/
virtual qint64 getLength() const = 0;
virtual qint64 length() const = 0;
/**
* \brief Return true if the renderer is paused
......
......@@ -320,7 +320,7 @@ qint64 WorkflowRenderer::getCurrentFrame() const
return m_mainWorkflow->getCurrentFrame();
}
qint64 WorkflowRenderer::getLength() const
qint64 WorkflowRenderer::length() const
{
return qRound64( (qreal)getLengthMs() / 1000.0 * (qreal)getFps() );
}
......
......@@ -107,7 +107,7 @@ class WorkflowRenderer : public GenericRenderer
*/
virtual qint64 getLengthMs() const;
virtual qint64 getLength() const;
virtual qint64 length() const;
/**
* \brief Return the current frame number
......
......@@ -328,3 +328,9 @@ ClipWorkflow::save( QXmlStreamWriter &project ) const
project.writeAttribute( "helper", m_clipHelper->uuid().toString() );
saveFilters( project );
}
qint64
ClipWorkflow::length() const
{
return m_clipHelper->length();
}
......@@ -203,6 +203,7 @@ class ClipWorkflow : public EffectUser
void stopRenderer();
void save( QXmlStreamWriter& project ) const;
virtual qint64 length() const;
private:
void setState( State state );
......
......@@ -644,3 +644,9 @@ TrackWorkflow::__effectMoved( const QUuid& uuid, qint64 pos )
{
emit effectMoved( this, uuid, pos );
}
qint64
TrackWorkflow::length() const
{
return m_length;
}
......@@ -100,6 +100,7 @@ class TrackWorkflow : public EffectUser
//FIXME: this is not thread safe if the list gets modified (but it can't be const, as it is intended to be modified...)
EffectsEngine::EffectList *filters();
EffectsEngine::EffectList *mixers();
qint64 length() const;
private:
void computeLength();
......
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