Chris@58: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@0: 
Chris@0: /*
Chris@59:     Sonic Visualiser
Chris@59:     An audio file viewer and annotation editor.
Chris@59:     Centre for Digital Music, Queen Mary, University of London.
Chris@0:     
Chris@59:     This program is free software; you can redistribute it and/or
Chris@59:     modify it under the terms of the GNU General Public License as
Chris@59:     published by the Free Software Foundation; either version 2 of the
Chris@59:     License, or (at your option) any later version.  See the file
Chris@59:     COPYING included with this distribution for more information.
Chris@0: */
Chris@0: 
Chris@0: #ifndef FADER_H
Chris@0: #define FADER_H
Chris@0: 
Chris@0: /**
Chris@0:  * Horizontal audio fader and meter widget.
Chris@0:  * Based on the vertical fader and meter widget from:
Chris@0:  * 
Chris@0:  * Hydrogen
Chris@0:  * Copyright(c) 2002-2005 by Alex >Comix< Cominu [comix@users.sourceforge.net]
Chris@0:  * http://www.hydrogen-music.org
Chris@0:  */
Chris@0: 
Chris@0: 
Chris@0: #include <string>
Chris@0: #include <iostream>
Chris@0: 
Chris@0: #include <QWidget>
Chris@0: #include <QPixmap>
Chris@0: #include <QMouseEvent>
Chris@0: #include <QWheelEvent>
Chris@0: #include <QPaintEvent>
Chris@0: 
Chris@0: class Fader : public QWidget
Chris@0: {
Chris@0:     Q_OBJECT
Chris@0: 
Chris@0: public:
Chris@0:     Fader(QWidget *parent, bool withoutKnob = false);
Chris@0:     ~Fader();
Chris@0: 
Chris@0:     void setValue(float newValue);
Chris@0:     float getValue();
Chris@0: 
Chris@0:     void setPeakLeft(float);
Chris@0:     float getPeakLeft() { return m_peakLeft; }
Chris@0: 
Chris@0:     void setPeakRight(float);
Chris@0:     float getPeakRight() { return m_peakRight; }
Chris@0: 
Chris@189: signals:
Chris@189:     void valueChanged(float); // 0.0 -> 1.0
Chris@189: 
Chris@189:     void mouseEntered();
Chris@189:     void mouseLeft();
Chris@189: 
Chris@189: protected:
Chris@0:     virtual void mousePressEvent(QMouseEvent *ev);
Chris@0:     virtual void mouseDoubleClickEvent(QMouseEvent *ev);
Chris@0:     virtual void mouseMoveEvent(QMouseEvent *ev);
Chris@132:     virtual void mouseReleaseEvent(QMouseEvent *ev);
Chris@0:     virtual void wheelEvent( QWheelEvent *ev );
Chris@0:     virtual void paintEvent(QPaintEvent *ev);
Chris@189:     virtual void enterEvent(QEvent *);
Chris@189:     virtual void leaveEvent(QEvent *);
Chris@0: 
Chris@187:     int getMaxX() const;
Chris@187: 
Chris@0:     bool m_withoutKnob;
Chris@0:     float m_value;
Chris@0:     float m_peakLeft;
Chris@0:     float m_peakRight;
Chris@0: 
Chris@187:     bool m_mousePressed;
Chris@187:     int m_mousePressX;
Chris@187:     float m_mousePressValue;
Chris@187: 
Chris@0:     QPixmap m_back;
Chris@0:     QPixmap m_leds;
Chris@0:     QPixmap m_knob;
Chris@0:     QPixmap m_clip;
Chris@0: };
Chris@0: 
Chris@0: #endif