]> git.sesse.net Git - kdenlive/blob - src/onmonitoritems/onmonitorpathitem.h
ed930a1bc313156953d0a4ff56f74d87e9cd0f07
[kdenlive] / src / onmonitoritems / onmonitorpathitem.h
1 /***************************************************************************
2  *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20
21 #ifndef ONMONITORPATHITEM_H
22 #define ONMONITORPATHITEM_H
23
24
25 #include <QtCore>
26 #include <QGraphicsPathItem>
27
28 class QGraphicsView;
29
30 namespace Mlt {
31 class Geometry;
32 }
33
34
35 class OnMonitorPathItem : public QObject, public QGraphicsPathItem
36 {
37     Q_OBJECT
38 public:
39     OnMonitorPathItem(double dar, QGraphicsItem *parent = 0);
40     void setPoints(Mlt::Geometry *geometry);
41     void getMode(const QPointF &pos);
42     void rebuildShape();
43     QList <QPointF> points() const;
44     virtual QPainterPath shape () const;
45
46     /** @brief Reimplemented to draw the handles. */
47     virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
48     virtual QRectF boundingRect () const;
49
50 protected:
51     //virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
52     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
53     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
54     void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
55     void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
56     void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
57
58 private:
59     double m_dar;
60     QList <QPointF> m_points;
61     QPointF m_lastPoint;
62     bool m_modified;
63     QGraphicsView *m_view;
64     int m_activePoint;
65     QPainterPath m_shape;
66
67     /** @brief Tries to get the view of the scene. */
68     bool getView();
69
70 signals:
71     void changed();
72 };
73
74 #endif