]> git.sesse.net Git - kdenlive/blob - src/beziercurve/beziersplineeditor.h
Bezier Spline: Add grid. Number of lines in the grid can be increased with a button...
[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
34     CubicBezierSpline spline();
35     void setSpline(const CubicBezierSpline &spline);
36
37     BPoint getCurrentPoint();
38     void updateCurrentPoint(const BPoint &p);
39
40 public slots:
41     void slotZoomIn();
42     void slotZoomOut();
43     void slotGridChange();
44
45 protected:
46     //void keyPressEvent(QKeyEvent *event);
47     void paintEvent(QPaintEvent *event);
48     void mousePressEvent(QMouseEvent *event);
49     void mouseReleaseEvent(QMouseEvent * event);
50     void mouseMoveEvent(QMouseEvent * event);
51     void leaveEvent(QEvent *event);
52     void resizeEvent(QResizeEvent *event);
53
54 private:
55     CubicBezierSpline m_spline;
56     enum modes { ModeDrag, ModeNormal };
57     enum point_types { PTypeH1, PTypeP, PTypeH2 };
58     modes m_mode;
59     int m_zoomLevel;
60     int m_gridLines;
61     int m_currentPointIndex;
62     point_types m_currentPointType;
63     double m_grabOffsetX;
64     double m_grabOffsetY;
65     double m_grabOriginalX;
66     double m_grabOriginalY;
67     //QPointF m_draggedAwayPoint;
68     //int m_draggedAwayPointIndex;
69
70     //inline void drawGrid(QPainter &p, int width, int height);
71     int nearestPointInRange(QPointF p, int wWidth, int wHeight, point_types *sel);
72
73 signals:
74     void modified();
75     void currentPoint(const BPoint &p);
76 };
77
78 #endif