Commit 2de957bd authored by Ludovic Fauvet's avatar Ludovic Fauvet

PreviewWidget: GUI support for markers

parent 59df02a9
......@@ -34,6 +34,8 @@ PreviewRuler::PreviewRuler( QWidget* parent ) :
{
setMouseTracking( true );
m_isSliding = false;
m_markerStart = MARKER_DEFAULT;
m_markerStop = MARKER_DEFAULT;
}
void PreviewRuler::setRenderer( GenericRenderer* renderer )
......@@ -48,6 +50,8 @@ void PreviewRuler::setRenderer( GenericRenderer* renderer )
this, SLOT( update() ) );
connect( m_renderer, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
this, SLOT( updateTimecode( qint64 ) ) );
connect( m_renderer, SIGNAL( stopped() ),
this, SLOT( clear() ) );
}
void PreviewRuler::paintEvent( QPaintEvent * event )
......@@ -56,7 +60,7 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
Q_ASSERT( m_renderer );
QPainter painter( this );
QRect marks( 0, 0, width() - 1, MARK_LARGE + 1 );
QRect marks( 0, 3, width() - 1, MARK_LARGE + 1 );
painter.setPen( QPen( QColor( 50, 50, 50 ) ) );
painter.setBrush( QBrush( QColor( 50, 50, 50 ) ) );
......@@ -139,6 +143,32 @@ void PreviewRuler::paintEvent( QPaintEvent * event )
}
}
// Draw the markers (if any)
painter.setPen( QPen( Qt::green, 2 ) );
if ( m_markerStart > MARKER_DEFAULT )
{
int markerPos = m_markerStart * width() / m_renderer->getLength();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos + 8, 1,
markerPos, 1,
markerPos, 20,
markerPos + 8, 20 );
painter.drawPolyline( marker );
}
if ( m_markerStop > MARKER_DEFAULT )
{
int markerPos = m_markerStop * width() / m_renderer->getLength();
QPolygon marker( 4 );
marker.setPoints( 4,
markerPos - 8, 1,
markerPos, 1,
markerPos, 20,
markerPos - 8, 20 );
painter.drawPolyline( marker );
}
// Draw the pointer
painter.setRenderHint( QPainter::Antialiasing );
painter.setPen( QPen( Qt::white ) );
......@@ -216,3 +246,18 @@ void PreviewRuler::updateTimecode( qint64 frames /*= -1*/ )
}
}
}
void PreviewRuler::setMarker( Marker m )
{
if ( m == START )
m_markerStart = m_frame;
else
m_markerStop = m_frame;
}
void PreviewRuler::clear()
{
m_markerStart = MARKER_DEFAULT;
m_markerStop = MARKER_DEFAULT;
m_frame = 0;
}
......@@ -34,13 +34,22 @@
#define MARK_MEDIUM 8
#define MARK_LARGE 11
#define MARKER_DEFAULT -1
class PreviewRuler : public QWidget
{
Q_OBJECT
public:
enum Marker
{
START,
STOP
};
PreviewRuler( QWidget* parent = 0 );
virtual ~PreviewRuler() { }
void setRenderer( GenericRenderer* renderer );
void setMarker( Marker m );
public slots:
void setFrame( qint64 frame, bool broadcastEvent = false );
......@@ -53,10 +62,13 @@ protected:
private slots:
void updateTimecode( qint64 frames = -1 );
void clear();
private:
GenericRenderer* m_renderer;
qint64 m_frame;
qint64 m_markerStart;
qint64 m_markerStop;
bool m_isSliding;
signals:
......
......@@ -72,6 +72,9 @@ PreviewWidget::PreviewWidget( GenericRenderer* genericRenderer, QWidget *parent
connect( m_renderer, SIGNAL( endReached() ), this, SLOT( endReached() ) );
connect( m_ui->rulerWidget, SIGNAL( frameChanged(qint64, MainWorkflow::FrameChangedReason) ),
m_renderer, SLOT( previewWidgetCursorChanged(qint64) ) );
connect( m_ui->pushButtonMarkerStart, SIGNAL( clicked() ), this, SLOT( markerStartClicked() ) );
connect( m_ui->pushButtonMarkerStop, SIGNAL( clicked() ), this, SLOT( markerStopClicked() ) );
}
PreviewWidget::~PreviewWidget()
......@@ -163,3 +166,13 @@ void PreviewWidget::stop()
//Ugly but avoid code dupplication.
on_pushButtonStop_clicked();
}
void PreviewWidget::markerStartClicked()
{
m_ui->rulerWidget->setMarker( PreviewRuler::START );
}
void PreviewWidget::markerStopClicked()
{
m_ui->rulerWidget->setMarker( PreviewRuler::STOP );
}
......@@ -66,6 +66,8 @@ private slots:
void videoPlaying();
void videoStopped();
void endReached();
void markerStartClicked();
void markerStopClicked();
};
#endif // PREVIEWWIDGET_H
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