GraphicsTrack.hpp 2.8 KB
Newer Older
Ludovic Fauvet's avatar
Ludovic Fauvet committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*****************************************************************************
 * GraphicsTrack.hpp: Graphically represent a track in the timeline
 *****************************************************************************
 * 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.
 *****************************************************************************/

#ifndef GRAPHICSTRACK_HPP
#define GRAPHICSTRACK_HPP

#include <QGraphicsWidget>
#include <QPainter>
28
#include <QDebug>
29
#include "MainWorkflow.h"
Ludovic Fauvet's avatar
Ludovic Fauvet committed
30
31
32
33
34
35
36
37
38
39
40
41

class GraphicsTrack : public QGraphicsWidget
{
    Q_OBJECT

public:
    enum { Type = UserType + 2 };
    enum MediaType
    {
        Video,
        Audio
    };
Ludovic Fauvet's avatar
Ludovic Fauvet committed
42

43
    GraphicsTrack( MediaType type, quint32 trackNumber, QGraphicsItem* parent = 0 ) : QGraphicsWidget( parent )
Ludovic Fauvet's avatar
Ludovic Fauvet committed
44
45
46
    {
        m_type = type;
        m_trackNumber = trackNumber;
47
        m_enabled = true;
Ludovic Fauvet's avatar
Ludovic Fauvet committed
48
49
50

        setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
        setContentsMargins( 0, 0, 0, 0 );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
51
        setZValue( 1 );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
52
    }
Ludovic Fauvet's avatar
Ludovic Fauvet committed
53
54
55
56

    void setHeight( int height )
    {
        setPreferredHeight( height );
57
        adjustSize();
Ludovic Fauvet's avatar
Ludovic Fauvet committed
58
59
60
61
62
63
64
65
        updateGeometry();
    }

    int height()
    {
        return preferredHeight();
    }

66
67
    void setTrackEnabled( bool enabled )
    {
68
        if ( enabled == m_enabled ) return;
69
        m_enabled = enabled;
70
71
72

        MainWorkflow::TrackType type;
        if ( m_type == Audio )
73
74
75
            //TODO need audio support
            //type = MainWorkflow::AudioTrack;
            return;
76
77
78
79
80
81
82
        else
            type = MainWorkflow::VideoTrack;

        if ( enabled )
            MainWorkflow::getInstance()->unmuteTrack( m_trackNumber, type );
        else
            MainWorkflow::getInstance()->muteTrack( m_trackNumber, type );
83
84
85
86
87
88
89
    }

    bool trackEnabled()
    {
        return m_enabled;
    }

90
    quint32 trackNumber()
Ludovic Fauvet's avatar
Ludovic Fauvet committed
91
92
93
    {
        return m_trackNumber;
    }
Ludovic Fauvet's avatar
Ludovic Fauvet committed
94

95
96
97
98
99
    MediaType mediaType()
    {
        return m_type;
    }

Ludovic Fauvet's avatar
Ludovic Fauvet committed
100
101
102
103
    virtual int type() const { return Type; }

private:
    MediaType m_type;
104
    quint32 m_trackNumber;
105
    bool m_enabled;
Ludovic Fauvet's avatar
Ludovic Fauvet committed
106
107
108
};

#endif // GRAPHICSTRACK_HPP