Mercurial > hg > svgui
comparison widgets/Panner.h @ 172:d0b95a8cac96
* A start to a panner widget to go with thumbwheels
author | Chris Cannam |
---|---|
date | Wed, 18 Oct 2006 16:38:30 +0000 |
parents | |
children | 9c40dc10c88c |
comparison
equal
deleted
inserted
replaced
171:78d523e8433e | 172:d0b95a8cac96 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _PANNER_H_ | |
17 #define _PANNER_H_ | |
18 | |
19 #include <QWidget> | |
20 | |
21 class Panner : public QWidget | |
22 { | |
23 Q_OBJECT | |
24 | |
25 public: | |
26 Panner(QWidget *parent = 0); | |
27 virtual ~Panner(); | |
28 | |
29 virtual void mousePressEvent(QMouseEvent *e); | |
30 virtual void mouseDoubleClickEvent(QMouseEvent *e); | |
31 virtual void mouseMoveEvent(QMouseEvent *e); | |
32 virtual void mouseReleaseEvent(QMouseEvent *e); | |
33 virtual void wheelEvent(QWheelEvent *e); | |
34 virtual void paintEvent(QPaintEvent *e); | |
35 | |
36 virtual QSize sizeHint() const; | |
37 | |
38 signals: | |
39 /** | |
40 * Emitted when the panned rectangle is dragged or otherwise | |
41 * moved. Arguments are x0, y0, width and height of the rectangle | |
42 * in the range 0 -> 1 as proportions of the width and height of | |
43 * the whole widget. | |
44 */ | |
45 void rectExtentsChanged(float, float, float, float); | |
46 | |
47 /** | |
48 * Emitted when the rectangle is dragged or otherwise moved (as | |
49 * well as extentsChanged). Arguments are the centre coordinates | |
50 * of the rectangle in the range 0 -> 1 as proportions of the | |
51 * width and height of the whole widget. | |
52 */ | |
53 void rectCentreMoved(float, float); | |
54 | |
55 public slots: | |
56 /** | |
57 * Set the extents of the panned rectangle within the overall | |
58 * panner widget. Coordinates are in the range 0 -> 1 in both axes, | |
59 * with 0 at the top in the y axis. | |
60 */ | |
61 void setRectExtents(float x0, float y0, float width, float height); | |
62 | |
63 /** | |
64 * Set the width of the panned rectangle as a fraction (0 -> 1) of | |
65 * that of the whole panner widget. | |
66 */ | |
67 void setRectWidth(float width); | |
68 | |
69 /** | |
70 * Set the height of the panned rectangle as a fraction (0 -> 1) | |
71 * of that of the whole panner widget. | |
72 */ | |
73 void setRectHeight(float height); | |
74 | |
75 /** | |
76 * Set the location of the centre of the panned rectangle on the x | |
77 * axis, as a proportion (0 -> 1) of the width of the whole panner | |
78 * widget. | |
79 */ | |
80 void setRectCentreX(float x); | |
81 | |
82 /** | |
83 * Set the location of the centre of the panned rectangle on the y | |
84 * axis, as a proportion (0 -> 1) of the height of the whole panner | |
85 * widget. | |
86 */ | |
87 void setRectCentreY(float y); | |
88 | |
89 protected: | |
90 void normalise(); | |
91 void emitAndUpdate(); | |
92 | |
93 float m_rectX; | |
94 float m_rectY; | |
95 float m_rectWidth; | |
96 float m_rectHeight; | |
97 }; | |
98 | |
99 #endif | |
100 |