]> git.sesse.net Git - kdenlive/blob - src/regiongrabber.h
Fix label
[kdenlive] / src / regiongrabber.h
1 /*
2  *   Copyright (C) 2007 Luca Gugelmann <lucag@student.ethz.ch>
3  *   Adapted for Kdenlive by Jean-Baptiste Mardelle (2008) jb@kdenlive.org
4  *
5  *   This program is free software; you can redistribute it and/or modify it
6  *   under the terms of the GNU Library General Public License version 2 as
7  *   published by the Free Software Foundation
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 Library General Public
15  *   License 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 #ifndef REGIONGRABBER_H
21 #define REGIONGRABBER_H
22
23 #include <QWidget>
24 #include <QRegion>
25 #include <QPoint>
26 #include <QVector>
27 #include <QRect>
28 #include <QTimer>
29
30 class QPaintEvent;
31 class QResizeEvent;
32 class QMouseEvent;
33
34 class RegionGrabber : public QWidget
35 {
36     Q_OBJECT
37 public:
38     RegionGrabber();
39     ~RegionGrabber();
40
41 protected slots:
42     void init();
43     void displayHelp();
44
45 signals:
46     void regionGrabbed(const QRect &);
47
48 protected:
49     void paintEvent(QPaintEvent* e);
50     void resizeEvent(QResizeEvent* e);
51     void mousePressEvent(QMouseEvent* e);
52     void mouseMoveEvent(QMouseEvent* e);
53     void mouseReleaseEvent(QMouseEvent* e);
54     void mouseDoubleClickEvent(QMouseEvent*);
55     void keyPressEvent(QKeyEvent* e);
56     void updateHandles();
57     QRegion handleMask() const;
58     QPoint limitPointToRect(const QPoint &p, const QRect &r) const;
59     void grabRect();
60
61     QRect selection;
62     bool mouseDown;
63     bool newSelection;
64     const int handleSize;
65     QRect* mouseOverHandle;
66     QPoint dragStartPoint;
67     QRect  selectionBeforeDrag;
68     QTimer idleTimer;
69     bool showHelp;
70     bool grabbing;
71
72     // naming convention for handles
73     // T top, B bottom, R Right, L left
74     // 2 letters: a corner
75     // 1 letter: the handle on the middle of the corresponding side
76     QRect TLHandle, TRHandle, BLHandle, BRHandle;
77     QRect LHandle, THandle, RHandle, BHandle;
78
79     QVector<QRect*> handles;
80     QPixmap pixmap;
81 };
82
83 #endif