onmonitorpathitem.h 2.77 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
/***************************************************************************
 *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
 *                                                                         *
 *   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 ONMONITORPATHITEM_H
#define ONMONITORPATHITEM_H

#include <QGraphicsPathItem>

class QGraphicsView;

Laurent Montel's avatar
Laurent Montel committed
27 28
namespace Mlt
{
29 30 31 32 33 34 35
class Geometry;
}

class OnMonitorPathItem : public QObject, public QGraphicsPathItem
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
36
    explicit OnMonitorPathItem(QGraphicsItem *parent = nullptr);
37
    void setPoints(Mlt::Geometry *geometry);
38
    void getMode(const QPointF &pos);
39
    void rebuildShape();
Laurent Montel's avatar
Laurent Montel committed
40
    QList<QPointF> points() const;
Laurent Montel's avatar
Laurent Montel committed
41
    QPainterPath shape() const Q_DECL_OVERRIDE;
42 43

    /** @brief Reimplemented to draw the handles. */
Laurent Montel's avatar
Laurent Montel committed
44
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) Q_DECL_OVERRIDE;
Laurent Montel's avatar
Laurent Montel committed
45
    QRectF boundingRect() const Q_DECL_OVERRIDE;
46 47 48

protected:
    //virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
Laurent Montel's avatar
Laurent Montel committed
49 50 51 52 53
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
54 55

private:
Laurent Montel's avatar
Laurent Montel committed
56
    QList<QPointF> m_points;
57 58 59 60 61 62 63 64 65 66 67 68 69 70
    QPointF m_lastPoint;
    bool m_modified;
    QGraphicsView *m_view;
    int m_activePoint;
    QPainterPath m_shape;

    /** @brief Tries to get the view of the scene. */
    bool getView();

signals:
    void changed();
};

#endif