svgui
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 QMUL. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _PANNER_H_ 00017 #define _PANNER_H_ 00018 00019 #include <QWidget> 00020 00021 class Panner : public QWidget 00022 { 00023 Q_OBJECT 00024 00025 public: 00026 Panner(QWidget *parent = 0); 00027 virtual ~Panner(); 00028 00029 void setDefaultRectCentre(float, float); 00030 00031 void setThumbColour(QColor colour); 00032 void setAlpha(int backgroundAlpha, int thumbAlpha); 00033 00040 void setScrollUnit(float unit); 00041 00042 void getRectExtents(float &x0, float &y0, float &width, float &height); 00043 00044 virtual QSize sizeHint() const; 00045 00046 signals: 00053 void rectExtentsChanged(float, float, float, float); 00054 00061 void rectCentreMoved(float, float); 00062 00067 void doubleClicked(); 00068 00069 void mouseEntered(); 00070 void mouseLeft(); 00071 00072 public slots: 00078 void setRectExtents(float x0, float y0, float width, float height); 00079 00084 void setRectWidth(float width); 00085 00090 void setRectHeight(float height); 00091 00097 void setRectCentreX(float x); 00098 00104 void setRectCentreY(float y); 00105 00110 void scroll(bool up); 00111 00112 void resetToDefault(); 00113 00114 protected: 00115 virtual void mousePressEvent(QMouseEvent *e); 00116 virtual void mouseDoubleClickEvent(QMouseEvent *e); 00117 virtual void mouseMoveEvent(QMouseEvent *e); 00118 virtual void mouseReleaseEvent(QMouseEvent *e); 00119 virtual void wheelEvent(QWheelEvent *e); 00120 virtual void paintEvent(QPaintEvent *e); 00121 virtual void enterEvent(QEvent *); 00122 virtual void leaveEvent(QEvent *); 00123 00124 void normalise(); 00125 void emitAndUpdate(); 00126 00127 float m_rectX; 00128 float m_rectY; 00129 float m_rectWidth; 00130 float m_rectHeight; 00131 float m_scrollUnit; 00132 00133 float m_defaultCentreX; 00134 float m_defaultCentreY; 00135 bool m_defaultsSet; 00136 00137 QColor m_thumbColour; 00138 int m_backgroundAlpha; 00139 int m_thumbAlpha; 00140 00141 float centreX() const { return m_rectX + m_rectWidth/2; } 00142 float centreY() const { return m_rectY + m_rectHeight/2; } 00143 00144 bool m_clicked; 00145 QPoint m_clickPos; 00146 float m_dragStartX; 00147 float m_dragStartY; 00148 }; 00149 00150 #endif 00151