svgui  1.9
AudioDial.h
Go to the documentation of this file.
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     
00008     This program is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU General Public License as
00010     published by the Free Software Foundation; either version 2 of the
00011     License, or (at your option) any later version.  See the file
00012     COPYING included with this distribution for more information.
00013 */
00014 
00015 #ifndef _AUDIO_DIAL_H_
00016 #define _AUDIO_DIAL_H_
00017 
00041 #include <QDial>
00042 #include <map>
00043 
00044 class RangeMapper;
00045 
00059 class AudioDial : public QDial
00060 {
00061     Q_OBJECT
00062     Q_PROPERTY( QColor knobColor READ getKnobColor WRITE setKnobColor )
00063     Q_PROPERTY( QColor meterColor READ getMeterColor WRITE setMeterColor )
00064     Q_PROPERTY( bool mouseDial READ getMouseDial WRITE setMouseDial )
00065 
00066 public:
00067     AudioDial(QWidget *parent = 0);
00068     ~AudioDial();
00069 
00070     const QColor& getKnobColor()  const { return m_knobColor;  }
00071     const QColor& getMeterColor() const { return m_meterColor; }
00072     bool getMouseDial() const { return m_mouseDial; }
00073 
00074     void setRangeMapper(RangeMapper *mapper); // I take ownership, will delete
00075     const RangeMapper *rangeMapper() const { return m_rangeMapper; }
00076     float mappedValue() const;
00077 
00078     int defaultValue() const { return m_defaultValue; }
00079 
00080     void setShowToolTip(bool show);
00081 
00082 signals:
00083     void mouseEntered();
00084     void mouseLeft();
00085 
00086 public slots:
00091     void setKnobColor(const QColor &color);
00092 
00098     void setMeterColor(const QColor &color);
00099     
00104     void setMouseDial(bool mouseDial);
00105 
00106     void setDefaultValue(int defaultValue);
00107 
00108     void setValue(int value);
00109 
00110     void setDefaultMappedValue(float mappedValue);
00111 
00112     void setMappedValue(float mappedValue);
00113 
00114     void setToDefault();
00115 
00116 protected:
00117     void drawTick(QPainter &paint, float angle, int size, bool internal);
00118     virtual void paintEvent(QPaintEvent *);
00119 
00120     // Alternate mouse behavior event handlers.
00121     virtual void mousePressEvent(QMouseEvent *pMouseEvent);
00122     virtual void mouseMoveEvent(QMouseEvent *pMouseEvent);
00123     virtual void mouseReleaseEvent(QMouseEvent *pMouseEvent);
00124     virtual void mouseDoubleClickEvent(QMouseEvent *pMouseEvent);
00125     virtual void enterEvent(QEvent *);
00126     virtual void leaveEvent(QEvent *);
00127 
00128 protected slots:
00129     void updateMappedValue(int value);
00130 
00131 private:
00132     QColor m_knobColor;
00133     QColor m_meterColor;
00134     
00135     int m_defaultValue;
00136     float m_defaultMappedValue;
00137     float m_mappedValue;
00138     bool m_noMappedUpdate;
00139 
00140     // Alternate mouse behavior tracking.
00141     bool m_mouseDial;
00142     bool m_mousePressed;
00143     QPoint m_posMouse;
00144 
00145     bool m_showTooltip;
00146 
00147     RangeMapper *m_rangeMapper;
00148 };
00149 
00150 
00151 #endif  // __AudioDial_h
00152 
00153 // end of AudioDial.h