svgui  1.9
Panner.h
Go to the documentation of this file.
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 QMUL.
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  void setDefaultRectCentre(float, float);
30 
31  void setThumbColour(QColor colour);
32  void setAlpha(int backgroundAlpha, int thumbAlpha);
33 
40  void setScrollUnit(float unit);
41 
42  void getRectExtents(float &x0, float &y0, float &width, float &height);
43 
44  virtual QSize sizeHint() const;
45 
46 signals:
53  void rectExtentsChanged(float, float, float, float);
54 
61  void rectCentreMoved(float, float);
62 
67  void doubleClicked();
68 
69  void mouseEntered();
70  void mouseLeft();
71 
72 public slots:
78  void setRectExtents(float x0, float y0, float width, float height);
79 
84  void setRectWidth(float width);
85 
90  void setRectHeight(float height);
91 
97  void setRectCentreX(float x);
98 
104  void setRectCentreY(float y);
105 
110  void scroll(bool up);
111 
112  void resetToDefault();
113 
114 protected:
115  virtual void mousePressEvent(QMouseEvent *e);
116  virtual void mouseDoubleClickEvent(QMouseEvent *e);
117  virtual void mouseMoveEvent(QMouseEvent *e);
118  virtual void mouseReleaseEvent(QMouseEvent *e);
119  virtual void wheelEvent(QWheelEvent *e);
120  virtual void paintEvent(QPaintEvent *e);
121  virtual void enterEvent(QEvent *);
122  virtual void leaveEvent(QEvent *);
123 
124  void normalise();
125  void emitAndUpdate();
126 
127  float m_rectX;
128  float m_rectY;
129  float m_rectWidth;
132 
136 
140 
141  float centreX() const { return m_rectX + m_rectWidth/2; }
142  float centreY() const { return m_rectY + m_rectHeight/2; }
143 
144  bool m_clicked;
145  QPoint m_clickPos;
148 };
149 
150 #endif
151 
float centreX() const
Definition: Panner.h:141
void normalise()
Definition: Panner.cpp:179
virtual void mousePressEvent(QMouseEvent *e)
Definition: Panner.cpp:82
virtual void leaveEvent(QEvent *)
Definition: Panner.cpp:145
float m_rectHeight
Definition: Panner.h:130
void getRectExtents(float &x0, float &y0, float &width, float &height)
Definition: Panner.cpp:204
int m_backgroundAlpha
Definition: Panner.h:138
Panner(QWidget *parent=0)
Definition: Panner.cpp:26
int m_thumbAlpha
Definition: Panner.h:139
virtual QSize sizeHint() const
Definition: Panner.cpp:273
void scroll(bool up)
Move up (if up is true) or down a bit.
Definition: Panner.cpp:63
float m_dragStartY
Definition: Panner.h:147
void setScrollUnit(float unit)
Set the amount the scroll() function or mouse wheel movement makes the panner rectangle move by.
Definition: Panner.cpp:57
void mouseEntered()
bool m_defaultsSet
Definition: Panner.h:135
virtual void mouseDoubleClickEvent(QMouseEvent *e)
Definition: Panner.cpp:97
QPoint m_clickPos
Definition: Panner.h:145
float m_rectX
Definition: Panner.h:127
void setRectWidth(float width)
Set the width of the panned rectangle as a fraction (0 -> 1) of that of the whole panner widget.
Definition: Panner.cpp:235
Definition: Panner.h:21
bool m_clicked
Definition: Panner.h:144
virtual void enterEvent(QEvent *)
Definition: Panner.cpp:139
float centreY() const
Definition: Panner.h:142
void setRectHeight(float height)
Set the height of the panned rectangle as a fraction (0 -> 1) of that of the whole panner widget.
Definition: Panner.cpp:244
virtual ~Panner()
Definition: Panner.cpp:45
void mouseLeft()
void setThumbColour(QColor colour)
void setRectCentreY(float y)
Set the location of the centre of the panned rectangle on the y axis, as a proportion (0 -> 1) of the...
Definition: Panner.cpp:263
void emitAndUpdate()
Definition: Panner.cpp:196
virtual void mouseReleaseEvent(QMouseEvent *e)
Definition: Panner.cpp:124
virtual void wheelEvent(QWheelEvent *e)
Definition: Panner.cpp:133
void rectExtentsChanged(float, float, float, float)
Emitted when the panned rectangle is dragged or otherwise moved.
float m_dragStartX
Definition: Panner.h:146
void doubleClicked()
Emitted when the panner is double-clicked (for the "customer" code to pop up a value editing dialog,...
float m_defaultCentreX
Definition: Panner.h:133
void resetToDefault()
Definition: Panner.cpp:287
virtual void mouseMoveEvent(QMouseEvent *e)
Definition: Panner.cpp:107
float m_rectY
Definition: Panner.h:128
void setRectCentreX(float x)
Set the location of the centre of the panned rectangle on the x axis, as a proportion (0 -> 1) of the...
Definition: Panner.cpp:253
float m_rectWidth
Definition: Panner.h:129
void setDefaultRectCentre(float, float)
Definition: Panner.cpp:279
float m_defaultCentreY
Definition: Panner.h:134
void setRectExtents(float x0, float y0, float width, float height)
Set the extents of the panned rectangle within the overall panner widget.
Definition: Panner.cpp:213
QColor m_thumbColour
Definition: Panner.h:137
void rectCentreMoved(float, float)
Emitted when the rectangle is dragged or otherwise moved (as well as extentsChanged).
virtual void paintEvent(QPaintEvent *e)
Definition: Panner.cpp:151
void setAlpha(int backgroundAlpha, int thumbAlpha)
Definition: Panner.cpp:50
float m_scrollUnit
Definition: Panner.h:131