GraphicsAudioItem.h 3.42 KB
Newer Older
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
28
29
30
31
32
33
34
35
/*****************************************************************************
 * GraphicsAudioItem.h: Represent an audio region graphically 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 GRAPHICSAUDIOITEM_H
#define GRAPHICSAUDIOITEM_H

#include <QFontMetrics>
#include "AbstractGraphicsMediaItem.h"
#include "Clip.h"
#include "TracksView.h"

#define Z_SELECTED 4
#define Z_NOT_SELECTED 3

#define ROUNDED_RECT_RADIUS 5

36
37
38
/**
 * \brief Represents an audio item.
 */
39
40
41
42
class GraphicsAudioItem : public AbstractGraphicsMediaItem
{
    Q_OBJECT
public:
43
44
45
    /**
     * \brief See http://doc.trolltech.com/4.5/qgraphicsitem.html#type
     */
46
47
48
49
50
51
52
53
    enum { Type = UserType + 1 };
    GraphicsAudioItem( Clip* clip );
    virtual ~GraphicsAudioItem();

    virtual int type() const { return Type; }
    virtual bool expandable() const { return false; }
    virtual bool moveable() const { return true; }
    virtual const QUuid& uuid() const { return m_clip->getUuid(); }
54
    virtual MainWorkflow::TrackType mediaType() const;
55
56
57
58
59
    virtual QRectF boundingRect() const;
    virtual void paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0 );

    void setWidth( int width );
    void setHeight( int height );
60
    virtual Clip* clip() const;
61
62

protected:
63
64
65
66
67
    /**
     * \brief Paint the item's rectangle.
     * \param painter Pointer to a QPainter.
     * \param option Painting options.
     */
68
    void                paintRect( QPainter* painter, const QStyleOptionGraphicsItem* option );
69
70
71
72
73
    /**
     * \brief Paint the item's title.
     * \param painter Pointer to a QPainter.
     * \param option Painting options.
     */
74
75
76
77
78
79
80
    void                paintTitle( QPainter* painter, const QStyleOptionGraphicsItem* option );
    virtual void        hoverEnterEvent( QGraphicsSceneHoverEvent* event );
    virtual void        hoverLeaveEvent( QGraphicsSceneHoverEvent* event );
    virtual void        mousePressEvent( QGraphicsSceneMouseEvent* event );
    virtual void        mouseReleaseEvent( QGraphicsSceneMouseEvent* event );

private slots:
81
82
83
    /**
     * \deprecated Do not use.
     */
84
85
86
87
88
89
90
91
    void                adjustLength();

private:
    Clip*               m_clip;
    int                 m_width;
    int                 m_height;

signals:
92
93
94
95
96
    /**
     * \brief Emitted when the item detect a cut request.
     * \param self A pointer to the sender.
     * \param frame Frame's number where the cut takes place.
     */
97
98
99
100
    void                split( GraphicsAudioItem* self, qint64 frame );
};

#endif // GRAPHICSAUDIOITEM_H