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 FADER_H 00016 #define FADER_H 00017 00028 #include <string> 00029 #include <iostream> 00030 00031 #include <QWidget> 00032 #include <QPixmap> 00033 #include <QMouseEvent> 00034 #include <QWheelEvent> 00035 #include <QPaintEvent> 00036 00037 class Fader : public QWidget 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 Fader(QWidget *parent, bool withoutKnob = false); 00043 ~Fader(); 00044 00045 void setValue(float newValue); 00046 float getValue(); 00047 00048 void setPeakLeft(float); 00049 float getPeakLeft() { return m_peakLeft; } 00050 00051 void setPeakRight(float); 00052 float getPeakRight() { return m_peakRight; } 00053 00054 signals: 00055 void valueChanged(float); // 0.0 -> 1.0 00056 00057 void mouseEntered(); 00058 void mouseLeft(); 00059 00060 protected: 00061 virtual void mousePressEvent(QMouseEvent *ev); 00062 virtual void mouseDoubleClickEvent(QMouseEvent *ev); 00063 virtual void mouseMoveEvent(QMouseEvent *ev); 00064 virtual void mouseReleaseEvent(QMouseEvent *ev); 00065 virtual void wheelEvent( QWheelEvent *ev ); 00066 virtual void paintEvent(QPaintEvent *ev); 00067 virtual void enterEvent(QEvent *); 00068 virtual void leaveEvent(QEvent *); 00069 00070 int getMaxX() const; 00071 00072 bool m_withoutKnob; 00073 float m_value; 00074 float m_peakLeft; 00075 float m_peakRight; 00076 00077 bool m_mousePressed; 00078 int m_mousePressX; 00079 float m_mousePressValue; 00080 00081 QPixmap m_back; 00082 QPixmap m_leds; 00083 QPixmap m_knob; 00084 QPixmap m_clip; 00085 }; 00086 00087 #endif
1.5.1