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