TracksView.h 2.71 KB
Newer Older
1
/*****************************************************************************
2
 * TracksView.h: QGraphicsView that contains the TracksScene
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Ludovic Fauvet <etix@l0cal.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

23 24
#ifndef TRACKSVIEW_H
#define TRACKSVIEW_H
25

26
#include <QWidget>
27
#include <QGraphicsView>
28
#include <QGraphicsLineItem>
Ludovic Fauvet's avatar
Ludovic Fauvet committed
29
#include <QWheelEvent>
30 31 32
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QDragMoveEvent>
33
#include "Media.h"
34
#include "GraphicsCursorItem.h"
35

36
class TracksView : public QGraphicsView
37
{
38 39
    Q_OBJECT

40
public:
41
    TracksView( QGraphicsScene* scene, QWidget* parent = 0 );
42
    void setDuration( int duration );
43 44 45
    int duration() const { return m_projectDuration; }
    int tracksHeight() const { return m_tracksHeight; }
    int tracksCount() const { return m_tracksCount; }
46
    void setCursorPos( int pos );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
47
    int cursorPos();
48
    GraphicsCursorItem* tracksCursor() const { return m_cursorLine; }
49
    void addClip( Media* clip, const QPoint& point );
50
    void setScale( double scaleFactor );
51 52 53 54

protected:
    virtual void resizeEvent( QResizeEvent* event );
    virtual void drawBackground( QPainter* painter, const QRectF& rect );
55 56
    virtual void mouseMoveEvent( QMouseEvent* event );
    virtual void mousePressEvent( QMouseEvent* event );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
57
    virtual void mouseReleaseEvent( QMouseEvent* event );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
58
    virtual void wheelEvent( QWheelEvent* event );
59 60 61
    virtual void dragEnterEvent( QDragEnterEvent* event );
    virtual void dropEvent( QDropEvent* event );
    virtual void dragMoveEvent( QDragMoveEvent* event );
62

63 64 65
private slots:
    void ensureCursorVisible();

66 67 68 69 70
private:
    QGraphicsScene* m_scene;
    int m_tracksHeight;
    int m_tracksCount;
    int m_projectDuration;
71
    int m_fps;
72
    GraphicsCursorItem* m_cursorLine;
73

Ludovic Fauvet's avatar
Ludovic Fauvet committed
74 75 76
signals:
    void zoomIn();
    void zoomOut();
77
    void durationChanged( int duration );
78 79
};

80
#endif // TRACKSVIEW_H