]> git.sesse.net Git - kdenlive/blob - src/beziercurve/beziersplineeditor.h
0320e3197f36f1542289365235f99d038b757363
[kdenlive] / src / beziercurve / beziersplineeditor.h
1 /***************************************************************************
2  *   Copyright (C) 2010 by Till Theato (root@ttill.de)                     *
3  *   This file is part of Kdenlive (www.kdenlive.org).                     *
4  *                                                                         *
5  *   Kdenlive is free software: you can redistribute it and/or modify      *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation, either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   Kdenlive is distributed in the hope that it will be useful,           *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with Kdenlive.  If not, see <http://www.gnu.org/licenses/>.     *
17  ***************************************************************************/
18
19 #ifndef BEZIERSPLINEEDITOR_H
20 #define BEZIERSPLINEEDITOR_H
21
22 #include "cubicbezierspline.h"
23
24 #include <QtCore>
25 #include <QWidget>
26
27 class BezierSplineEditor : public QWidget
28 {
29     Q_OBJECT
30
31 public:
32     BezierSplineEditor(QWidget* parent = 0);
33     virtual ~BezierSplineEditor();
34
35     CubicBezierSpline spline();
36     void setSpline(const CubicBezierSpline &spline);
37
38     BPoint getCurrentPoint();
39     void updateCurrentPoint(const BPoint &p);
40
41     int gridLines();
42     void setGridLines(int lines);
43
44     void setPixmap(const QPixmap &pixmap);
45
46 public slots:
47     void slotZoomIn();
48     void slotZoomOut();
49
50 protected:
51     void paintEvent(QPaintEvent *event);
52     void mousePressEvent(QMouseEvent *event);
53     void mouseReleaseEvent(QMouseEvent * event);
54     void mouseMoveEvent(QMouseEvent * event);
55     void leaveEvent(QEvent *event);
56     void resizeEvent(QResizeEvent *event);
57
58 private:
59     CubicBezierSpline m_spline;
60     enum modes { ModeDrag, ModeNormal };
61     enum point_types { PTypeH1, PTypeP, PTypeH2 };
62     modes m_mode;
63     int m_zoomLevel;
64     int m_gridLines;
65     QPixmap m_pixmap;
66     QPixmap *m_pixmapCache;
67     bool m_pixmapIsDirty;
68
69     int m_currentPointIndex;
70     point_types m_currentPointType;
71     double m_grabOffsetX;
72     double m_grabOffsetY;
73     BPoint m_grabPOriginal;
74     BPoint m_grabPNext;
75     BPoint m_grabPPrevious;
76
77     int nearestPointInRange(QPointF p, int wWidth, int wHeight, point_types *sel);
78
79 signals:
80     void modified();
81     void currentPoint(const BPoint &p);
82 };
83
84 #endif