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