Commit d150c92b authored by Ludovic Fauvet's avatar Ludovic Fauvet

Basic track support

parent 6f7461bc
......@@ -23,6 +23,8 @@
#include <QScrollBar>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QGraphicsLinearLayout>
#include <QGraphicsWidget>
#include <QtDebug>
#include <cmath>
#include "TracksView.h"
......@@ -40,6 +42,9 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
m_tracksCount = mainWorkflow->getTrackCount();
m_fps = 30;
m_numAudioTrack = 0;
m_numVideoTrack = 0;
setMouseTracking( true );
setAcceptDrops( true );
setContentsMargins( 0, 0, 0, 0 );
......@@ -54,10 +59,48 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
m_cursorLine = new GraphicsCursorItem( maxHeight, QPen( QColor( 220, 30, 30 ) ) );
m_scene->addItem( m_cursorLine );
createLayout();
connect( m_cursorLine, SIGNAL( cursorPositionChanged(int) ),
this, SLOT( ensureCursorVisible() ) );
}
void TracksView::createLayout()
{
m_layout = new QGraphicsLinearLayout( Qt::Vertical );
m_layout->setContentsMargins( 0, 0, 0, 0 );
m_layout->setSpacing( 0 );
QGraphicsWidget* container = new QGraphicsWidget();
container->setContentsMargins( 0, 0, 0, 0 );
container->setLayout( m_layout );
addVideoTrack();
addAudioTrack();
m_scene->addItem( container );
}
void TracksView::addVideoTrack()
{
GraphicsTrack* track = new GraphicsTrack();
track->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
track->setPreferredHeight( m_tracksHeight );
track->setContentsMargins( 0, 0, 0, 0 );
m_layout->insertItem( 0, track );
m_numVideoTrack++;
}
void TracksView::addAudioTrack()
{
GraphicsTrack* track = new GraphicsTrack();
track->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
track->setPreferredHeight( m_tracksHeight );
track->setContentsMargins( 0, 0, 0, 0 );
m_layout->insertItem( 1000, track );
m_numAudioTrack++;
}
void TracksView::dragEnterEvent( QDragEnterEvent* event )
{
if ( event->mimeData()->hasFormat( "vlmc/uuid" ) )
......
......@@ -26,6 +26,8 @@
#include <QWidget>
#include <QGraphicsView>
#include <QGraphicsLineItem>
#include <QGraphicsLinearLayout>
#include <QGraphicsWidget>
#include <QWheelEvent>
#include <QDragEnterEvent>
#include <QDropEvent>
......@@ -34,6 +36,22 @@
#include "GraphicsCursorItem.h"
#include "Workflow/MainWorkflow.h"
class GraphicsTrack : public QGraphicsWidget
{
Q_OBJECT
public:
GraphicsTrack( QGraphicsItem* parent = 0 ) : QGraphicsWidget( parent ) {}
protected:
virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* = 0 )
{
painter->setBrush( Qt::cyan );
painter->drawRect( rect() );
}
};
class TracksView : public QGraphicsView
{
Q_OBJECT
......@@ -66,12 +84,18 @@ private slots:
void ensureCursorVisible();
private:
void createLayout();
void addVideoTrack();
void addAudioTrack();
QGraphicsScene* m_scene;
int m_tracksHeight;
unsigned int m_tracksCount;
int m_projectDuration;
int m_fps;
GraphicsCursorItem* m_cursorLine;
QGraphicsLinearLayout* m_layout;
int m_numVideoTrack;
int m_numAudioTrack;
MainWorkflow* m_mainWorkflow;
signals:
......
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